// !!! This is a file automatically generated by hipify!!! #pragma once #include #include #ifdef __HIP_PLATFORM_AMD__ #include #include #include namespace cubns = hipcub; #else #include #include #include namespace cubns = cub; #endif namespace megablocks { #ifdef __HIP_PLATFORM_AMD__ using gpuError_t = hipError_t; using gpuStream_t = hipStream_t; constexpr gpuError_t kGpuSuccess = hipSuccess; inline gpuStream_t get_current_stream() { return c10::hip::getCurrentHIPStream(); } inline const char* get_error_string(gpuError_t status) { return hipGetErrorString(status); } inline gpuError_t get_last_error() { return hipGetLastError(); } template inline gpuError_t gpuMemcpyAsync(Args&&... args) { return hipMemcpyAsync(std::forward(args)...); } template inline gpuError_t gpuMemsetAsync(Args&&... args) { return hipMemsetAsync(std::forward(args)...); } #else using gpuError_t = hipError_t; using gpuStream_t = hipStream_t; constexpr gpuError_t kGpuSuccess = hipSuccess; inline gpuStream_t get_current_stream() { return c10::hip::getCurrentHIPStreamMasqueradingAsCUDA(); } inline const char* get_error_string(gpuError_t status) { return hipGetErrorString(status); } inline gpuError_t get_last_error() { return hipGetLastError(); } template inline gpuError_t gpuMemcpyAsync(Args&&... args) { return hipMemcpyAsync(std::forward(args)...); } template inline gpuError_t gpuMemsetAsync(Args&&... args) { return hipMemsetAsync(std::forward(args)...); } #endif inline void gpuCheck(gpuError_t status, const char* expr) { TORCH_CHECK(status == kGpuSuccess, get_error_string(status)); } } // namespace megablocks #define GPU_CALL(expr) ::megablocks::gpuCheck((expr), #expr)