25namespace alpaka::onHost::internal
27 struct MemcpyDeviceGlobal;
31#define ALPAKA_DEVICE_GLOBAL_DATA_HOST(attributes, dataType, name, ...) \
32 namespace alpaka_onHost \
34 [[maybe_unused]] attributes alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper< \
35 ALPAKA_PP_REMOVE_BRACKETS(dataType)> name __VA_OPT__({__VA_ARGS__}); \
39#define ALPAKA_DEVICE_GLOBAL_DATA_HOST_EXTERN(attributes, dataType, name) \
40 namespace alpaka_onHost \
42 extern attributes alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper<ALPAKA_PP_REMOVE_BRACKETS(dataType)> \
46#if ALPAKA_LANG_CUDA || ALPAKA_LANG_HIP
48# define ALPAKA_DEVICE_GLOBAL_DATA_CUDA_HIP(attributes, dataType, name, ...) \
49 namespace alpaka_onAccCudaHip \
51 __device__ attributes \
52 alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper<ALPAKA_PP_REMOVE_BRACKETS(dataType)> \
53 name __VA_OPT__({__VA_ARGS__}); \
57# define ALPAKA_DEVICE_GLOBAL_GET_CUDA_HIP(attributes, dataType, name, ...) \
58 template<typename T_Api> \
59 requires(std::is_same_v<alpaka::api::Cuda, T_Api> || std::is_same_v<alpaka::api::Hip, T_Api>) \
60 constexpr auto& get(T_Api) const \
62 return alpaka_onAccCudaHip::name.value; \
64 template<typename T_Api> \
65 requires(std::is_same_v<alpaka::api::Cuda, T_Api> || std::is_same_v<alpaka::api::Hip, T_Api>) \
66 constexpr auto& getHandle(T_Api) const \
68 return alpaka_onAccCudaHip::name.value; \
72# define ALPAKA_DEVICE_GLOBAL_DATA_CUDA_HIP(attributes, dataType, name, ...)
73# define ALPAKA_DEVICE_GLOBAL_GET_CUDA_HIP(attributes, dataType, name, ...)
76#if ALPAKA_LANG_CUDA || ALPAKA_LANG_HIP
81# if defined(__CUDACC_RDC__) || defined(__CLANG_RDC__)
82# define ALPAKA_DEVICE_GLOBAL_DATA_CUDA_HIP_EXTERN(attributes, dataType, name) \
83 namespace alpaka_onAccCudaHip \
85 extern __device__ attributes \
86 alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper<ALPAKA_PP_REMOVE_BRACKETS(dataType)> \
91# define ALPAKA_DEVICE_GLOBAL_DATA_CUDA_HIP_EXTERN(attributes, dataType, name)
94# define ALPAKA_DEVICE_GLOBAL_DATA_CUDA_HIP_EXTERN(attributes, dataType, name)
99# define ALPAKA_DEVICE_GLOBAL_DATA_ONEAPI(attributes, dataType, name, ...) \
100 namespace alpaka_onAccOneAPI \
102 [[maybe_unused]] attributes sycl::ext::oneapi::experimental::device_global< \
103 alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper<ALPAKA_PP_REMOVE_BRACKETS(dataType)>> name \
105 {alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper<ALPAKA_PP_REMOVE_BRACKETS(dataType)>{ \
110# define ALPAKA_DEVICE_GLOBAL_DATA_ONEAPI_EXTERN(attributes, dataType, name) \
111 namespace alpaka_onAccOneAPI \
113 extern attributes sycl::ext::oneapi::experimental::device_global< \
114 alpaka::onAcc::internal::GlobalDeviceMemoryDataWrapper<ALPAKA_PP_REMOVE_BRACKETS(dataType)>> \
119# define ALPAKA_DEVICE_GLOBAL_GET_ONEAPI(attributes, dataType, name, ...) \
120 template<typename T_Api> \
121 requires(std::is_same_v<alpaka::api::OneApi, T_Api>) \
122 constexpr auto& get(T_Api) const \
124 return alpaka_onAccOneAPI::name.get().value; \
126 template<typename T_Api> \
127 requires(std::is_same_v<alpaka::api::OneApi, T_Api>) \
128 constexpr auto& getHandle(T_Api) const \
130 return alpaka_onAccOneAPI::name; \
133# define ALPAKA_DEVICE_GLOBAL_DATA_ONEAPI(attributes, dataType, name, ...)
134# define ALPAKA_DEVICE_GLOBAL_DATA_ONEAPI_EXTERN(attributes, dataType, name)
135# define ALPAKA_DEVICE_GLOBAL_GET_ONEAPI(attributes, dataType, name, ...)
138namespace alpaka::onAcc::internal
146 struct GlobalDeviceMemoryDataWrapper
148 constexpr GlobalDeviceMemoryDataWrapper(
auto const&... args) : value{
ALPAKA_FORWARD(args)...}
159 T
const* data()
const
170 template<alpaka::concepts::CStaticArray T>
171 struct GlobalDeviceMemoryDataWrapper<T>
174 using value_type = std::remove_all_extents_t<T>;
178 return reinterpret_cast<value_type*
>(&value);
181 value_type
const* data()
const
183 return reinterpret_cast<value_type const*
>(&value);
188 template<
typename T_Storage,
typename T_Type>
189 struct GlobalDeviceMemoryWrapper :
private T_Storage
192 friend struct onHost::internal::MemcpyDeviceGlobal;
200 template<alpaka::concepts::Api T_Api>
201 constexpr decltype(
auto) getHandle(T_Api api)
const
203 return T_Storage::getHandle(api);
209 constexpr decltype(
auto) get()
const
211 return T_Storage::get(
thisApi());
214 constexpr decltype(
auto) get()
const requires(std::is_array_v<type>)
220 constexpr operator type&()
222 return T_Storage::get(
thisApi());
225 constexpr operator type
const&()
const
227 return T_Storage::get(
thisApi());
#define ALPAKA_FORWARD(instance)
Perfectly forward an instance as argument.
constexpr auto thisApi()
provides the API used during the execution of the current code path