Loading...
Searching...
No Matches
Go to the documentation of this file.
38#include <hip/hiprtc.h>
44#define CHECK_HIPCUDA_DRIVER_ERROR(err) \
45 if (err != hipSuccess) \
47 std::cerr << "HIP Driver API Error at: " << __FILE__ << ":" \
48 << __LINE__ << std::endl; \
49 std::cerr << hipGetErrorString(err) << std::endl; \
53#define CHECK_NEKRTC_ERROR(err) \
55 if (err != HIPRTC_SUCCESS) \
57 std::cerr << "HIP Runtime Error at: " << __FILE__ << ":" \
58 << __LINE__ << std::endl; \
59 std::cerr << "HIPRTC error: " << hiprtcGetErrorString(err) \
64#define nekLaunchKernel hipModuleLaunchKernel
65#define nekModuleLoadData hipModuleLoadData
66#define nekModuleGetFunction hipModuleGetFunction
67#define nekModuleUnload hipModuleUnload
68#define NEKdevice hipDevice_t
69#define NEKmodule hipModule_t
70#define NEKfunction hipFunction_t
71#define nekrtcProgram hiprtcProgram
72#define nekrtcCreateProgram hiprtcCreateProgram
73#define nekrtcDestroyProgram hiprtcDestroyProgram
74#define nekrtcAddNameExpression hiprtcAddNameExpression
75#define nekrtcGetLoweredName hiprtcGetLoweredName
76#define nekrtcCompileProgram hiprtcCompileProgram
77#define nekrtcGetCodeSize hiprtcGetCodeSize
78#define nekrtcGetCode hiprtcGetCode
81#if defined(NEKTAR_ENABLE_HIP)
84template <
unsigned int ndim>
class hipcudaBlock
94#define DEVICE_1DGRID_KERNEL_LAUNCHER(KERNEL, GRIDSIZE, BLOCKSIZE, SHMEMSIZE, \
97 auto STREAM = HIPStream::GetInstance(STREAMID); \
98 unsigned char *shmemptr = nullptr; \
99 KERNEL<<<GRIDSIZE, BLOCKSIZE, SHMEMSIZE, STREAM>>>( \
100 __VA_ARGS__, shmemptr, hipcudaBlock<1>()); \
101 CHECK_LAST_HIPCUDA_ERROR(); \
110#define DEVICE_2DGRID_KERNEL_LAUNCHER(KERNEL, GRIDSIZEX, GRIDSIZEY, \
111 BLOCKSIZEX, BLOCKSIZEY, SHMEMSIZE, \
114 auto STREAM = HIPStream::GetInstance(STREAMID); \
115 unsigned char *shmemptr = nullptr; \
116 dim3 GRIDSIZE(GRIDSIZEX, GRIDSIZEY, 1); \
117 dim3 BLOCKSIZE(BLOCKSIZEX, BLOCKSIZEY, 1); \
118 KERNEL<<<GRIDSIZE, BLOCKSIZE, SHMEMSIZE, STREAM>>>( \
119 __VA_ARGS__, shmemptr, hipcudaBlock<2>()); \
120 CHECK_LAST_HIPCUDA_ERROR(); \
129#define DEVICE_3DGRID_KERNEL_LAUNCHER(KERNEL, GRIDSIZEX, GRIDSIZEY, GRIDSIZEZ, \
130 BLOCKSIZEX, BLOCKSIZEY, BLOCKSIZEZ, \
131 SHMEMSIZE, STREAMID, ...) \
133 auto STREAM = HIPStream::GetInstance(STREAMID); \
134 unsigned char *shmemptr = nullptr; \
135 dim3 GRIDSIZE(GRIDSIZEX, GRIDSIZEY, GRIDSIZEZ); \
136 dim3 BLOCKSIZE(BLOCKSIZEX, BLOCKSIZEY, BLOCKSIZEZ); \
137 KERNEL<<<GRIDSIZE, BLOCKSIZE, SHMEMSIZE, STREAM>>>( \
138 __VA_ARGS__, shmemptr, hipcudaBlock<3>()); \
139 CHECK_LAST_HIPCUDA_ERROR(); \
145#define DEVICE_1DGRID_KERNEL_LAUNCHER_NOSHMEM(KERNEL, GRIDSIZE, BLOCKSIZE, \
148 auto STREAM = HIPStream::GetInstance(STREAMID); \
149 KERNEL<<<GRIDSIZE, BLOCKSIZE, 0, STREAM>>>(__VA_ARGS__, \
150 hipcudaBlock<1>()); \
151 CHECK_LAST_HIPCUDA_ERROR(); \
157#define DEVICE_2DGRID_KERNEL_LAUNCHER_NOSHMEM( \
158 KERNEL, GRIDSIZEX, GRIDSIZEY, BLOCKSIZEX, BLOCKSIZEY, STREAMID, ...) \
160 auto STREAM = HIPStream::GetInstance(STREAMID); \
161 dim3 GRIDSIZE(GRIDSIZEX, GRIDSIZEY, 1); \
162 dim3 BLOCKSIZE(BLOCKSIZEX, BLOCKSIZEY, 1); \
163 KERNEL<<<GRIDSIZE, BLOCKSIZE, 0, STREAM>>>(__VA_ARGS__, \
164 hipcudaBlock<2>()); \
165 CHECK_LAST_HIPCUDA_ERROR(); \
171#define DEVICE_3DGRID_KERNEL_LAUNCHER_NOSHMEM( \
172 KERNEL, GRIDSIZEX, GRIDSIZEY, GRIDSIZEZ, BLOCKSIZEX, BLOCKSIZEY, \
173 BLOCKSIZEZ, STREAMID, ...) \
175 auto STREAM = HIPStream::GetInstance(STREAMID); \
176 dim3 GRIDSIZE(GRIDSIZEX, GRIDSIZEY, GRIDSIZEZ); \
177 dim3 BLOCKSIZE(BLOCKSIZEX, BLOCKSIZEY, BLOCKSIZEZ); \
178 KERNEL<<<GRIDSIZE, BLOCKSIZE, 0, STREAM>>>(__VA_ARGS__, \
179 hipcudaBlock<3>()); \
180 CHECK_LAST_HIPCUDA_ERROR(); \