【问题标题】:CHECK(call) function get error in Google Colab [duplicate]CHECK(调用)函数在Google Colab中出错[重复]
【发布时间】:2020-11-01 18:12:25
【问题描述】:

我刚刚从 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 

我该怎么做?

【问题讨论】:

    标签: c++ cuda google-colaboratory nvidia


    【解决方案1】:
    #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);\
        }\
    }
    

    如果你想要一个多行宏,你必须添加反斜杠。

    【讨论】:

      猜你喜欢
      • 2021-07-05
      • 1970-01-01
      • 2019-07-18
      • 2021-05-07
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 1970-01-01
      相关资源
      最近更新 更多