| 1 |
========================= |
| 2 |
LLVM OpenMP CMake Modules |
| 3 |
========================= |
| 4 |
|
| 5 |
This directory contains CMake modules for OpenMP. These can be included into a |
| 6 |
project to include different OpenMP features. |
| 7 |
|
| 8 |
.. contents:: |
| 9 |
:local: |
| 10 |
|
| 11 |
Find OpenMP Target Support |
| 12 |
========================== |
| 13 |
|
| 14 |
This module will attempt to find OpenMP target offloading support for a given |
| 15 |
device. The module will attempt to compile a test program using known compiler |
| 16 |
flags for each requested architecture. If successful, the flags required for |
| 17 |
offloading will be loaded into the ``OpenMPTarget::OpenMPTarget_<device>`` |
| 18 |
target or the ``OpenMPTarget_<device>_FLAGS`` variable. Currently supported target |
| 19 |
devices are ``NVPTX`` and ``AMDGPU``. This module is still under development so |
| 20 |
some features may be missing. |
| 21 |
|
| 22 |
To use this module, simply add the path to CMake's current module path and call |
| 23 |
``find_package``. The module will be installed with your OpenMP installation by |
| 24 |
default. Including OpenMP offloading support in an application should now only |
| 25 |
require a few additions. |
| 26 |
|
| 27 |
.. code-block:: cmake |
| 28 |
|
| 29 |
cmake_minimum_required(VERSION 3.20.0) |
| 30 |
project(offloadTest VERSION 1.0 LANGUAGES CXX) |
| 31 |
|
| 32 |
list(APPEND CMAKE_MODULE_PATH "${PATH_TO_OPENMP_INSTALL}/lib/cmake/openmp") |
| 33 |
|
| 34 |
find_package(OpenMPTarget REQUIRED NVPTX) |
| 35 |
|
| 36 |
add_executable(offload) |
| 37 |
target_link_libraries(offload PRIVATE OpenMPTarget::OpenMPTarget_NVPTX) |
| 38 |
target_sources(offload PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/Main.cpp) |
| 39 |
|
| 40 |
Using this module requires at least CMake version 3.20.0. Supported languages |
| 41 |
are C and C++ with Fortran support planned in the future. If your application |
| 42 |
requires building for a specific device architecture you can set the |
| 43 |
``OpenMPTarget_<device>_ARCH=<flag>`` variable. Compiler support is best for |
| 44 |
Clang but this module should work for other compiler vendors such as IBM or GNU. |