Reputation: 61289
I'm trying to compile the following simple OpenMP GPU offloading program with G++ 9.3.0:
#include <iostream>
int main(){
const int N=1000;
int d[N];
for(auto i=0;i<N;i++)
d[i] = 1;
#pragma omp target teams distribute parallel for map(tofrom:d[0:N])
for(size_t i=0;i<N;i++){
d[i] *= 3*i+1;
}
for(int i=0;i<N;i++)
std::cout<<d[i]<<" ";
std::cout<<std::endl;
}
I'm compiling with
g++ -fopenmp -O3 gpu_test.cpp
However, when I try to compile, I get the following error message:
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’)
How can I fix this?
Upvotes: 3
Views: 2301
Reputation: 61289
You haven't installed GCC's offloading capabilities. On Ubuntu/Debian systems you can do so with:
sudo apt install gcc-offload-nvptx
Or install for a specific version of GCC with, e.g.
sudo apt install gcc-9-offload-nvptx
Upvotes: 2