CHECK(call) 函数在 Google Colab 中出错
CHECK(call) function get error in Google Colab
我刚刚从 CUDA 中的普通 CHECK(call)
函数和 运行 中复制了一个函数 Google Colab
中的 nvcc_plugin
#define CHECK(call)
{
const cudaError_t error = call;
if (error != cudaSuccess)
{
printf("Error: %s:%d, ", __FILE__, __LINE__);
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));
exit(1);
}
}
但它会引发错误
/tmp/tmpvc2kvnuh/9c0f913f-6a2c-420d-9e3a-94c6e3123f7f.cu(9): error: expected a declaration
我该怎么做?
#define CHECK(call) \
{\
const cudaError_t error = call;\
if (error != cudaSuccess)\
{\
printf("Error: %s:%d, ", __FILE__, __LINE__);\
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));\
exit(1);\
}\
}
如果你想有一个多行宏,你必须添加反斜杠。
我刚刚从 CUDA 中的普通 CHECK(call)
函数和 运行 中复制了一个函数 Google Colab
nvcc_plugin
#define CHECK(call)
{
const cudaError_t error = call;
if (error != cudaSuccess)
{
printf("Error: %s:%d, ", __FILE__, __LINE__);
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));
exit(1);
}
}
但它会引发错误
/tmp/tmpvc2kvnuh/9c0f913f-6a2c-420d-9e3a-94c6e3123f7f.cu(9): error: expected a declaration
我该怎么做?
#define CHECK(call) \
{\
const cudaError_t error = call;\
if (error != cudaSuccess)\
{\
printf("Error: %s:%d, ", __FILE__, __LINE__);\
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));\
exit(1);\
}\
}
如果你想有一个多行宏,你必须添加反斜杠。