alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
GridSyncGpuCudaHip.hpp
Go to the documentation of this file.
1/* Copyright 2026 Mykhailo Varvarin, Andrea Bocci
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
11
12#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
13
14# if defined(ALPAKA_ACC_GPU_CUDA_ENABLED)
15// The cooperative groups headers from CUDA 12.0.0 use PTX register names with a single '%' in an inline asm statement
16// with operands, which clang rejects ("invalid % escape in inline assembly string"). The asm is only used for the
17// multi-warp scratch space in the reserved shared memory, which the grid synchronization does not need, so disable it.
18# if ALPAKA_COMP_CLANG_CUDA && defined(CUDART_VERSION) && (CUDART_VERSION == 12000) \
19 && !defined(_CG_USER_PROVIDED_SHARED_MEMORY)
20# pragma clang diagnostic push
21# pragma clang diagnostic ignored "-Wreserved-macro-identifier"
22# define _CG_USER_PROVIDED_SHARED_MEMORY
23# pragma clang diagnostic pop
24# endif
25# include <cooperative_groups.h>
26# endif
27
28# if defined(ALPAKA_ACC_GPU_HIP_ENABLED)
29# include <hip/hip_cooperative_groups.h>
30# endif
31
32
33namespace alpaka
34{
35 //! The GPU CUDA/HIP grid synchronization.
36 class GridSyncCudaHipBuiltIn : public interface::Implements<ConceptGridSync, GridSyncCudaHipBuiltIn>
37 {
38 };
39
40# if !defined(ALPAKA_HOST_ONLY)
41
42# if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && !ALPAKA_LANG_CUDA
43# error If ALPAKA_ACC_GPU_CUDA_ENABLED is set, the compiler has to support CUDA!
44# endif
45
46# if defined(ALPAKA_ACC_GPU_HIP_ENABLED) && !ALPAKA_LANG_HIP
47# error If ALPAKA_ACC_GPU_HIP_ENABLED is set, the compiler has to support HIP!
48# endif
49
50 namespace trait
51 {
52 template<>
54 {
55 __device__ static auto syncGridThreads(GridSyncCudaHipBuiltIn const& /*gridSync*/) -> void
56 {
57 cooperative_groups::this_grid().sync();
58 }
59 };
60
61 } // namespace trait
62
63# endif
64
65} // namespace alpaka
66
67#endif
The GPU CUDA/HIP grid synchronization.
The alpaka accelerator library.
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
Definition Interface.hpp:15
static __device__ auto syncGridThreads(GridSyncCudaHipBuiltIn const &) -> void
The grid synchronization operation trait.
Definition Traits.hpp:21