37#if defined(NEKTAR_ENABLE_SYCL)
45#if defined(SYCL_ENABLE_CUDA) && defined(__ADAPTIVECPP__)
46#define sycl_backend sycl::backend::cuda
47#elif defined(SYCL_ENABLE_CUDA) && defined(__DPCPP_COMPILER)
48#define sycl_backend sycl::backend::ext_oneapi_cuda
49#elif defined(SYCL_ENABLE_HIP) && defined(__ADAPTIVECPP__)
50#define sycl_backend sycl::backend::hip
51#elif defined(SYCL_ENABLE_HIP) && defined(__DPCPP_COMPILER)
52#define sycl_backend sycl::backend::ext_oneapi_hip
55static void inline setSYCLDefaultExecutionDependency(
56 const unsigned int streamID, sycl::handler &cgh)
62 for (
auto &item : SYCLQueue::GetAllEvents())
66 cgh.depends_on(item.second);
79static inline std::vector<sycl::event> getSYCLDefaultExecutionDependencies(
80 const unsigned int streamID)
82 std::vector<sycl::event> dependencies;
85 for (
auto &item : SYCLQueue::GetAllEvents())
89 dependencies.push_back(item.second);
108#define DEVICE_1DGRID_KERNEL_LAUNCHER(KERNEL, GRIDSIZE, BLOCKSIZE, SHMEMSIZE, \
111 sycl::queue &Q = SYCLQueue::GetInstance(STREAMID); \
112 const auto syclSHMEMSIZE = SHMEMSIZE; \
113 const auto syclSTREAMID = STREAMID; \
114 const auto args = std::make_tuple(__VA_ARGS__); \
115 sycl::event e = Q.submit([=](sycl::handler &cgh) { \
116 setSYCLDefaultExecutionDependency(syclSTREAMID, cgh); \
117 sycl::local_accessor<unsigned char, 1> shmem( \
118 sycl::range<1>(syclSHMEMSIZE), cgh); \
120 sycl::nd_range<1>(GRIDSIZE * BLOCKSIZE, BLOCKSIZE), \
121 [=](sycl::nd_item<1> item_ct1) SYCL_SUBGROUP_SIZE( \
122 NektarSpaces::Device::warpSize) { \
123 auto shmemptr = shmem \
124 .template get_multi_ptr<sycl::access::decorated::yes>()\
127 [&](auto &&...args) { \
128 KERNEL(std::forward<decltype(args)>(args)..., \
129 shmemptr, item_ct1); \
134 SYCLQueue::SetEvent(STREAMID, e); \
145#define DEVICE_2DGRID_KERNEL_LAUNCHER(KERNEL, GRIDSIZEX, GRIDSIZEY, \
146 BLOCKSIZEX, BLOCKSIZEY, SHMEMSIZE, \
149 sycl::queue &Q = SYCLQueue::GetInstance(STREAMID); \
150 const auto syclSHMEMSIZE = SHMEMSIZE; \
151 const auto syclSTREAMID = STREAMID; \
152 const auto args = std::make_tuple(__VA_ARGS__); \
153 sycl::range<2> GRIDSIZE(GRIDSIZEY, GRIDSIZEX); \
154 sycl::range<2> BLOCKSIZE(BLOCKSIZEY, BLOCKSIZEX); \
155 sycl::event e = Q.submit([=](sycl::handler &cgh) { \
156 setSYCLDefaultExecutionDependency(syclSTREAMID, cgh); \
157 sycl::local_accessor<unsigned char, 1> shmem( \
158 sycl::range<1>(syclSHMEMSIZE), cgh); \
160 sycl::nd_range<2>(GRIDSIZE * BLOCKSIZE, BLOCKSIZE), \
161 [=](sycl::nd_item<2> item_ct1) SYCL_SUBGROUP_SIZE( \
162 NektarSpaces::Device::warpSize) { \
163 auto shmemptr = shmem \
164 .template get_multi_ptr<sycl::access::decorated::yes>()\
167 [&](auto &&...args) { \
168 KERNEL(std::forward<decltype(args)>(args)..., \
169 shmemptr, item_ct1); \
174 SYCLQueue::SetEvent(STREAMID, e); \
183#define DEVICE_3DGRID_KERNEL_LAUNCHER(KERNEL, GRIDSIZEX, GRIDSIZEY, GRIDSIZEZ, \
184 BLOCKSIZEX, BLOCKSIZEY, BLOCKSIZEZ, \
185 SHMEMSIZE, STREAMID, ...) \
187 sycl::queue &Q = SYCLQueue::GetInstance(STREAMID); \
188 const auto syclSHMEMSIZE = SHMEMSIZE; \
189 const auto syclSTREAMID = STREAMID; \
190 const auto args = std::make_tuple(__VA_ARGS__); \
191 sycl::range<3> GRIDSIZE(GRIDSIZEZ, GRIDSIZEY, GRIDSIZEX); \
192 sycl::range<3> BLOCKSIZE(BLOCKSIZEZ, BLOCKSIZEY, BLOCKSIZEX); \
193 sycl::event e = Q.submit([=](sycl::handler &cgh) { \
194 setSYCLDefaultExecutionDependency(syclSTREAMID, cgh); \
195 sycl::local_accessor<unsigned char, 1> shmem( \
196 sycl::range<1>(syclSHMEMSIZE), cgh); \
198 sycl::nd_range<3>(GRIDSIZE * BLOCKSIZE, BLOCKSIZE), \
199 [=](sycl::nd_item<3> item_ct1) SYCL_SUBGROUP_SIZE( \
200 NektarSpaces::Device::warpSize) { \
201 auto shmemptr = shmem \
202 .template get_multi_ptr<sycl::access::decorated::yes>()\
205 [&](auto &&...args) { \
206 KERNEL(std::forward<decltype(args)>(args)..., \
207 shmemptr, item_ct1); \
212 SYCLQueue::SetEvent(STREAMID, e); \
220#define DEVICE_1DGRID_KERNEL_LAUNCHER_NOSHMEM(KERNEL, GRIDSIZE, BLOCKSIZE, \
223 sycl::queue &Q = SYCLQueue::GetInstance(STREAMID); \
224 const auto syclSTREAMID = STREAMID; \
225 const auto args = std::make_tuple(__VA_ARGS__); \
226 sycl::event e = Q.submit([=](sycl::handler &cgh) { \
227 setSYCLDefaultExecutionDependency(syclSTREAMID, cgh); \
229 sycl::nd_range<1>(GRIDSIZE * BLOCKSIZE, BLOCKSIZE), \
230 [=](sycl::nd_item<1> item_ct1) SYCL_SUBGROUP_SIZE( \
231 NektarSpaces::Device::warpSize) { \
233 [&](auto &&...args) { \
234 KERNEL(std::forward<decltype(args)>(args)..., \
240 SYCLQueue::SetEvent(STREAMID, e); \
248#define DEVICE_2DGRID_KERNEL_LAUNCHER_NOSHMEM( \
249 KERNEL, GRIDSIZEX, GRIDSIZEY, BLOCKSIZEX, BLOCKSIZEY, STREAMID, ...) \
251 sycl::queue &Q = SYCLQueue::GetInstance(STREAMID); \
252 const auto syclSTREAMID = STREAMID; \
253 const auto args = std::make_tuple(__VA_ARGS__); \
254 sycl::range<2> GRIDSIZE(GRIDSIZEY, GRIDSIZEX); \
255 sycl::range<2> BLOCKSIZE(BLOCKSIZEY, BLOCKSIZEX); \
256 sycl::event e = Q.submit([=](sycl::handler &cgh) { \
257 setSYCLDefaultExecutionDependency(syclSTREAMID, cgh); \
259 sycl::nd_range<2>(GRIDSIZE * BLOCKSIZE, BLOCKSIZE), \
260 [=](sycl::nd_item<2> item_ct1) SYCL_SUBGROUP_SIZE( \
261 NektarSpaces::Device::warpSize) { \
263 [&](auto &&...args) { \
264 KERNEL(std::forward<decltype(args)>(args)..., \
270 SYCLQueue::SetEvent(STREAMID, e); \
278#define DEVICE_3DGRID_KERNEL_LAUNCHER_NOSHMEM( \
279 KERNEL, GRIDSIZEX, GRIDSIZEY, GRIDSIZEZ, BLOCKSIZEX, BLOCKSIZEY, \
280 BLOCKSIZEZ, STREAMID, ...) \
282 sycl::queue &Q = SYCLQueue::GetInstance(STREAMID); \
283 const auto syclSTREAMID = STREAMID; \
284 const auto args = std::make_tuple(__VA_ARGS__); \
285 sycl::range<3> GRIDSIZE(GRIDSIZEZ, GRIDSIZEY, GRIDSIZEX); \
286 sycl::range<3> BLOCKSIZE(BLOCKSIZEZ, BLOCKSIZEY, BLOCKSIZEX); \
287 sycl::event e = Q.submit([=](sycl::handler &cgh) { \
288 setSYCLDefaultExecutionDependency(syclSTREAMID, cgh); \
290 sycl::nd_range<3>(GRIDSIZE * BLOCKSIZE, BLOCKSIZE), \
291 [=](sycl::nd_item<3> item_ct1) SYCL_SUBGROUP_SIZE( \
292 NektarSpaces::Device::warpSize) { \
294 [&](auto &&...args) { \
295 KERNEL(std::forward<decltype(args)>(args)..., \
301 SYCLQueue::SetEvent(STREAMID, e); \
static sycl::event & GetEvent(unsigned int id)