diff --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst --- a/openmp/docs/SupportAndFAQ.rst +++ b/openmp/docs/SupportAndFAQ.rst @@ -53,11 +53,12 @@ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To build an *effective* OpenMP offload capable compiler, only one extra CMake option, `LLVM_ENABLE_RUNTIMES="openmp"`, is needed when building LLVM (Generic -information about building LLVM is available `here `__.). -Make sure all backends that are targeted by OpenMP to be enabled. By default, -Clang will be built with all backends enabled. -When building with `LLVM_ENABLE_RUNTIMES="openmp"` OpenMP should not be enabled -in `LLVM_ENABLE_PROJECTS` because it is enabled by default. +information about building LLVM is available `here +`__.). Make sure all backends that +are targeted by OpenMP to be enabled. By default, Clang will be built with all +backends enabled. When building with `LLVM_ENABLE_RUNTIMES="openmp"` OpenMP +should not be enabled in `LLVM_ENABLE_PROJECTS` because it is enabled by +default. For Nvidia offload, please see :ref:`_build_nvidia_offload_capable_compiler`. For AMDGPU offload, please see :ref:`_build_amdgpu_offload_capable_compiler`. @@ -153,8 +154,8 @@ Q: Does Clang support `` and `` operations in OpenMP target on GPUs? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Yes, LLVM/Clang allows math functions and complex arithmetic inside of OpenMP target regions -that are compiled for GPUs. +Yes, LLVM/Clang allows math functions and complex arithmetic inside of OpenMP +target regions that are compiled for GPUs. Clang provides a set of wrapper headers that are found first when `math.h` and `complex.h`, for C, `cmath` and `complex`, for C++, or similar headers are @@ -202,8 +203,8 @@ Currently, the only solution is to change how the application is built and avoid the use of static libraries. -Q: Can I use dynamically linked libraries with OpenMP offloading -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Q: Can I use dynamically linked libraries with OpenMP offloading? +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Dynamically linked libraries can be only used if there is no device code split between the library and application. Anything declared on the device inside the @@ -220,3 +221,30 @@ For example, if your system-wide GCC installation is too old to build LLVM and you would like to use a newer GCC, set the CMake variable `GCC_INSTALL_PREFIX` to inform clang of the GCC installation you would like to use in the second stage. + +Q: How can I include OpenMP offloading support in my CMake project? +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Currently, there is a CMake find module for OpenMP target offloading provided by +LLVM. It will attempt to find OpenMP target offloading support for your +compiler. Currently supported targets are ``AMDGCN`` and ``NVPTX``. Including +OpenMP offloading support in your application should now only require a few +additions. + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.13.4) + project(offloadTest VERSION 1.0 LANGUAGES CXX) + + list(APPEND CMAKE_MODULE_PATH "${PATH_TO_OPENMP_INSTALL}/lib/cmake/openmp") + + find_package(OpenMPTarget REQUIRED NVPTX) + + add_executable(offload) + target_link_libraries(offload PRIVATE OpenMPTarget::OpenMPTarget_NVPTX) + target_sources(offload PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp) + +Using this module requires at least CMake version 3.13.4. Supported languages +are C and C++ with Fortran support planned in the future. Compiler support is +best for Clang but this module should work for other compiler vendors such as +IBM or GNU. diff --git a/openmp/tools/Modules/FindOpenMPTarget.cmake b/openmp/tools/Modules/FindOpenMPTarget.cmake --- a/openmp/tools/Modules/FindOpenMPTarget.cmake +++ b/openmp/tools/Modules/FindOpenMPTarget.cmake @@ -140,10 +140,6 @@ # Get flags for setting the device's architecture for each compiler. function(_OPENMP_TARGET_DEVICE_ARCH_CANDIDATES LANG DEVICE DEVICE_FLAG) - # AMD requires the architecture, default to gfx908 if not provided. - if((NOT OpenMPTarget_${DEVICE}_ARCH) AND ("${DEVICE}" STREQUAL "AMDGCN")) - set(OpenMPTarget_${DEVICE}_ARCH "gfx908") - endif() if(OpenMPTarget_${DEVICE}_ARCH) # Only Clang supports selecting the architecture for now. set(OMPTarget_ARCH_Clang "-Xopenmp-target=${DEVICE_FLAG} -march=${OpenMPTarget_${DEVICE}_ARCH}")