2017-01-26 05:27:24 +08:00
|
|
|
##===----------------------------------------------------------------------===##
|
2021-01-07 06:05:54 +08:00
|
|
|
#
|
2019-01-19 18:56:40 +08:00
|
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2021-01-07 06:05:54 +08:00
|
|
|
#
|
2017-01-26 05:27:24 +08:00
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
#
|
2017-12-07 05:59:04 +08:00
|
|
|
# Build offloading library and related plugins.
|
2017-01-26 05:27:24 +08:00
|
|
|
#
|
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
|
2017-11-30 03:31:43 +08:00
|
|
|
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
message(FATAL_ERROR "Direct configuration not supported, please use parent directory!")
|
|
|
|
endif()
|
2017-01-26 05:27:24 +08:00
|
|
|
|
|
|
|
# Add cmake directory to search for custom cmake functions.
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
|
|
|
|
|
2021-01-07 06:05:54 +08:00
|
|
|
# Set the path of all resulting libraries to a unified location so that it can
|
|
|
|
# be used for testing.
|
|
|
|
set(LIBOMPTARGET_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR})
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBOMPTARGET_LIBRARY_DIR})
|
2017-01-26 05:27:24 +08:00
|
|
|
|
|
|
|
# Message utilities.
|
|
|
|
include(LibomptargetUtils)
|
|
|
|
|
|
|
|
# Get dependencies for the different components of the project.
|
|
|
|
include(LibomptargetGetDependencies)
|
|
|
|
|
2020-10-22 01:52:53 +08:00
|
|
|
# LLVM source tree is required at build time for libomptarget
|
2021-01-13 03:32:27 +08:00
|
|
|
if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
|
|
|
|
message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS")
|
2020-10-22 01:52:53 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-26 05:27:24 +08:00
|
|
|
# This is a list of all the targets that are supported/tested right now.
|
2017-03-07 05:00:07 +08:00
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} aarch64-unknown-linux-gnu")
|
2021-04-28 14:53:46 +08:00
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} amdgcn-amd-amdhsa")
|
2017-01-26 05:27:24 +08:00
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64le-ibm-linux-gnu")
|
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} powerpc64-ibm-linux-gnu")
|
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} x86_64-pc-linux-gnu")
|
|
|
|
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda")
|
|
|
|
|
|
|
|
# Once the plugins for the different targets are validated, they will be added to
|
|
|
|
# the list of supported targets in the current system.
|
|
|
|
set (LIBOMPTARGET_SYSTEM_TARGETS "")
|
2019-11-28 15:46:18 +08:00
|
|
|
set (LIBOMPTARGET_TESTED_PLUGINS "")
|
2017-01-26 05:27:24 +08:00
|
|
|
|
2021-08-04 23:17:10 +08:00
|
|
|
# Check OMPT support
|
|
|
|
set(OMPT_DEFAULT_IN_LIBOMPTARGET FALSE)
|
|
|
|
if ((LIBOMP_HAVE_OMPT_SUPPORT) AND (NOT WIN32))
|
|
|
|
set(OMPT_DEFAULT_IN_LIBOMPTARGET TRUE)
|
|
|
|
endif()
|
|
|
|
set(LIBOMP_OMPT_SUPPORT_IN_LIBOMPTARGET ${OMPT_DEFAULT_IN_LIBOMPTARGET} CACHE BOOL
|
|
|
|
"OMPT-support in libomptarget?")
|
|
|
|
if(LIBOMP_OMPT_SUPPORT_IN_LIBOMPTARGET)
|
|
|
|
message(STATUS "OMPT enabled in libomptarget")
|
|
|
|
else()
|
|
|
|
message(STATUS "OMPT disabled in libomptarget")
|
|
|
|
endif()
|
|
|
|
|
2019-03-26 23:19:15 +08:00
|
|
|
# Check whether using debug mode. In debug mode, allow dumping progress
|
|
|
|
# messages at runtime by default. Otherwise, it can be enabled
|
|
|
|
# independently using the LIBOMPTARGET_ENABLE_DEBUG option.
|
2017-11-30 03:31:48 +08:00
|
|
|
string( TOLOWER "${CMAKE_BUILD_TYPE}" LIBOMPTARGET_CMAKE_BUILD_TYPE)
|
|
|
|
if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
|
2019-03-26 23:19:15 +08:00
|
|
|
option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" ON)
|
|
|
|
else()
|
|
|
|
option(LIBOMPTARGET_ENABLE_DEBUG "Allow debug output with the environment variable LIBOMPTARGET_DEBUG=1" OFF)
|
|
|
|
endif()
|
|
|
|
if(LIBOMPTARGET_ENABLE_DEBUG)
|
2017-11-30 03:31:48 +08:00
|
|
|
add_definitions(-DOMPTARGET_DEBUG)
|
|
|
|
endif()
|
|
|
|
|
2020-12-06 10:41:09 +08:00
|
|
|
set(LIBOMPTARGET_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
include_directories(${LIBOMPTARGET_INCLUDE_DIR})
|
2017-11-30 03:31:48 +08:00
|
|
|
|
2017-12-07 05:59:04 +08:00
|
|
|
# Build target agnostic offloading library.
|
2020-12-06 10:41:09 +08:00
|
|
|
set(LIBOMPTARGET_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
|
|
add_subdirectory(${LIBOMPTARGET_SRC_DIR})
|
2017-11-30 03:31:48 +08:00
|
|
|
|
2018-09-28 23:05:43 +08:00
|
|
|
# Definitions for testing, for reuse when testing libomptarget-nvptx.
|
2021-01-26 01:48:12 +08:00
|
|
|
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMP_INCLUDE_DIR}" CACHE STRING
|
|
|
|
"Path to folder containing omp.h")
|
|
|
|
set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${LIBOMP_LIBRARY_DIR}" CACHE STRING
|
|
|
|
"Path to folder containing libomp.so, and libLLVMSupport.so with profiling enabled")
|
2018-09-28 23:05:43 +08:00
|
|
|
|
|
|
|
|
2017-11-30 03:31:48 +08:00
|
|
|
# Build offloading plugins and device RTLs if they are available.
|
|
|
|
add_subdirectory(plugins)
|
2018-01-29 21:59:35 +08:00
|
|
|
add_subdirectory(deviceRTLs)
|
2021-07-26 02:26:44 +08:00
|
|
|
add_subdirectory(DeviceRTL)
|
2021-07-28 10:38:27 +08:00
|
|
|
add_subdirectory(tools)
|
2017-11-30 03:31:48 +08:00
|
|
|
|
|
|
|
# Add tests.
|
|
|
|
add_subdirectory(test)
|