mirror of
https://github.com/sgjzfzzf/triton-tvm-ffi.git
synced 2026-05-02 03:52:11 +08:00
use templates to substitute parts of macros
Signed-off-by: jinjieliu <jinjie.liu@usc.edu>
This commit is contained in:
22
include/triton_tvm_ffi/macro.h
Normal file
22
include/triton_tvm_ffi/macro.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef TRITON_TVM_FFI_MACRO_H_
|
||||
#define TRITON_TVM_FFI_MACRO_H_
|
||||
|
||||
#include <cuda.h>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#define __CUDA_CHECK(__code) \
|
||||
do { \
|
||||
if ((__code) != CUDA_SUCCESS) { \
|
||||
const char *errorName = nullptr, *errorStr = nullptr; \
|
||||
cuGetErrorName((__code), &errorName); \
|
||||
cuGetErrorString((__code), &errorStr); \
|
||||
std::ostringstream __oss; \
|
||||
__oss << "[" << errorName << "] " << errorStr << ", at " << __FILE__ \
|
||||
<< ":" << __LINE__; \
|
||||
throw std::runtime_error(__oss.str()); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user