45 lines · plain
1=========================2LLVM OpenMP CMake Modules3=========================4 5This directory contains CMake modules for OpenMP. These can be included into a6project to include different OpenMP features.7 8.. contents::9 :local:10 11Find OpenMP Target Support12==========================13 14This module will attempt to find OpenMP target offloading support for a given15device. The module will attempt to compile a test program using known compiler16flags for each requested architecture. If successful, the flags required for17offloading will be loaded into the ``OpenMPTarget::OpenMPTarget_<device>``18target or the ``OpenMPTarget_<device>_FLAGS`` variable. Currently supported target19devices are ``NVPTX`` and ``AMDGPU``. This module is still under development so20some features may be missing.21 22To use this module, simply add the path to CMake's current module path and call23``find_package``. The module will be installed with your OpenMP installation by24default. Including OpenMP offloading support in an application should now only25require a few additions.26 27.. code-block:: cmake28 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 40Using this module requires at least CMake version 3.20.0. Supported languages41are C and C++ with Fortran support planned in the future. If your application42requires building for a specific device architecture you can set the43``OpenMPTarget_<device>_ARCH=<flag>`` variable. Compiler support is best for44Clang but this module should work for other compiler vendors such as IBM or GNU.45