0

我在 Ubuntu 20.04 上使用 GCC 9.3。我想使用 OpenMP 将著名的 SAXPY 示例卸载到 GPU。我安装了 GCC 的卸载功能sudo apt install gcc-9-offload-nvptx 。然后编译以下代码g++ -fopenmp main.cpp

int main()
{
    const size_t kNumel = 999999;

    float x[kNumel];
    float y[kNumel];

    for (size_t i=0 ;i <kNumel; i++)
    {
        x[i] = i;
        y[i] = i;
    }


    const float kCoef = 1.23f;

    #pragma omp target teams distribute parallel for
    for (size_t i=0; i < kNumel; i++)
    {
        y[i] = kCoef*x[i] + y[i];
    }

    return 0;
}

但它没有编译并显示此错误:

to1: error: ‘-fcf-protection=full’ is not supported for this target
mkoffload: fatal error: x86_64-linux-gnu-accel-nvptx-none-gcc-9 returned 1 exit status
compilation terminated.
lto-wrapper: fatal error: /usr/lib/gcc/x86_64-linux-gnu/9//accel/nvptx-none/mkoffload 
returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

我添加了-fno-stack-protector但同样的错误被重现。

4

0 回答 0