Can anyone explain how to use Openacc in gcc?

  c++, gcc, linux

I am using WSL Ubuntu. And use GCC to compile my C++ code.

I am trying to use openacc to parallelize my code. I heard that I can use openacc with gcc

So after I install Ubuntu, I installed gcc.

And then I typed as follows.

$ g++ -fopenacc -o t testfile.cpp

As far as I know, -fopenacc should enable me to use openacc inside my code.

However, I got an message saying
lto-wrapper: fatal error: could not find accel/nvptx-none/mkoffload in /usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/ (consider using ‘-B’)

So I guess I missed something.

Does anyone know how to use openacc with gcc?

Thanks in advance


I tried
sudo apt-get install gcc-9-offload-nvptx

And then the error message is now changed to

lto1: 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

Source: Windows Questions C++