|
1 | 1 | /*! |
2 | 2 | * Copyright(C) 2023 Advanced Micro Devices, Inc. All rights reserved. |
3 | 3 | */ |
4 | | -#ifdef USE_CUDA |
| 4 | +#if defined(USE_CUDA) || defined(USE_ROCM) |
5 | 5 |
|
6 | 6 | #if defined(__HIP_PLATFORM_AMD__) || defined(__HIP__) |
7 | 7 | // ROCm doesn't have __shfl_down_sync, only __shfl_down without mask. |
|
12 | 12 | #define WARPSIZE warpSize |
13 | 13 | // ROCm doesn't have atomicAdd_block, but it should be semantically the same as atomicAdd |
14 | 14 | #define atomicAdd_block atomicAdd |
15 | | -#else |
| 15 | +// hipify |
| 16 | +#include <hip/hip_runtime.h> |
| 17 | +#define cudaDeviceProp hipDeviceProp_t |
| 18 | +#define cudaDeviceSynchronize hipDeviceSynchronize |
| 19 | +#define cudaError_t hipError_t |
| 20 | +#define cudaFree hipFree |
| 21 | +#define cudaFreeHost hipFreeHost |
| 22 | +#define cudaGetDevice hipGetDevice |
| 23 | +#define cudaGetDeviceProperties hipGetDeviceProperties |
| 24 | +#define cudaGetErrorName hipGetErrorName |
| 25 | +#define cudaGetErrorString hipGetErrorString |
| 26 | +#define cudaGetLastError hipGetLastError |
| 27 | +#define cudaHostAlloc hipHostAlloc |
| 28 | +#define cudaHostAllocPortable hipHostAllocPortable |
| 29 | +#define cudaMalloc hipMalloc |
| 30 | +#define cudaMemcpy hipMemcpy |
| 31 | +#define cudaMemcpyAsync hipMemcpyAsync |
| 32 | +#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice |
| 33 | +#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost |
| 34 | +#define cudaMemcpyHostToDevice hipMemcpyHostToDevice |
| 35 | +#define cudaMemoryTypeHost hipMemoryTypeHost |
| 36 | +#define cudaMemset hipMemset |
| 37 | +#define cudaPointerAttributes hipPointerAttribute_t |
| 38 | +#define cudaPointerGetAttributes hipPointerGetAttributes |
| 39 | +#define cudaSetDevice hipSetDevice |
| 40 | +#define cudaStreamCreate hipStreamCreate |
| 41 | +#define cudaStreamDestroy hipStreamDestroy |
| 42 | +#define cudaStream_t hipStream_t |
| 43 | +#define cudaSuccess hipSuccess |
| 44 | +#else // __HIP_PLATFORM_AMD__ || __HIP__ |
16 | 45 | // CUDA warpSize is not a constexpr, but always 32 |
17 | 46 | #define WARPSIZE 32 |
18 | 47 | #endif |
19 | 48 |
|
20 | | -#endif |
| 49 | +#endif // USE_CUDA || USE_ROCM |
0 commit comments