Gcc offload compilation options

纵饮孤独 提交于 2020-12-13 03:33:32

问题


I'm trying to build the simplest OpenMP or OpenACC C++ program with GPU offload using gcc-10, CUDA 11 on Ubuntu 18.04 and this CMakeLists.txt file (or OpenMP version):

cmake_minimum_required(VERSION 3.18)
project(hello VERSION 0.1.0)
find_package(OpenACC REQUIRED)
add_executable(hello main.cpp)
target_compile_options(hello PRIVATE -O3 -fopenacc -foffload=nvptx-none)
target_link_libraries (hello OpenACC::OpenACC_CXX)

The build fails with:

[build] [100%] Linking CXX executable hello
[build] /usr/local/bin/cmake -E cmake_link_script CMakeFiles/hello.dir/link.txt --verbose=1
[build] /usr/bin/g++-10 -O3 -DNDEBUG -fopenacc CMakeFiles/hello.dir/main.cpp.o -o hello 
[build] ptxas fatal   : Value 'sm_30' is not defined for option 'gpu-name'
[build] nvptx-as: ptxas returned 255 exit status
[build] mkoffload: fatal error: /usr/bin/x86_64-linux-gnu-accel-nvptx-none-gcc-10 returned 1 exit status
[build] compilation terminated.

I suspect that a flag defining GPU architecture is missing, but I can't find relevant documentation. Offloading Support in GCC: Compilation options don't have Nvidia example and when I try my best guess -foffload="-arch=sm_75" or -foffload=nvidia-"-arch=sm_75", I get:

[build] [ 50%] Building CXX object CMakeFiles/hello.dir/main.cpp.o
[build] /usr/local/bin/cmake -E time /usr/bin/g++-10 -DFMT_LOCALE -O3 -DNDEBUG -O3 -fopenacc -foffload=nvptx-none -foffload=\"-arch=sm_75\" -std=gnu++2a -o CMakeFiles/hello.dir/main.cpp.o -c /home/paul/st/hello/main.cpp
[build] g++-10: fatal error: GCC is not configured to support "-arch as offload target
[build] compilation terminated.

Any clues or relevant links will be highly appreciated.

来源:https://stackoverflow.com/questions/64781646/gcc-offload-compilation-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!