|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmake_minimum_required (VERSION 3.5) |
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX) |
|
|
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4) |
|
|
message(FATAL_ERROR |
|
|
"host compiler - Not found! (gcc version must be at least 5.4)") |
|
|
else() |
|
|
message(STATUS "host compiler - gcc ${CMAKE_CXX_COMPILER_VERSION}") |
|
|
endif() |
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") |
|
|
|
|
|
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.9) |
|
|
message(FATAL_ERROR |
|
|
"host compiler - Not found! (clang version must be at least 3.9)") |
|
|
else() |
|
|
message(STATUS "host compiler - clang ${CMAKE_CXX_COMPILER_VERSION}") |
|
|
endif() |
|
|
else() |
|
|
message(WARNING |
|
|
"host compiler - Not found! (triSYCL supports GCC and Clang)") |
|
|
endif() |
|
|
|
|
|
|
|
|
option(TRISYCL_OPENMP "triSYCL multi-threading with OpenMP" ON) |
|
|
option(TRISYCL_OPENCL "triSYCL OpenCL interoperability mode" OFF) |
|
|
option(TRISYCL_NO_ASYNC "triSYCL use synchronous kernel execution" OFF) |
|
|
option(TRISYCL_DEBUG "triSCYL use debug mode" OFF) |
|
|
option(TRISYCL_DEBUG_STRUCTORS "triSYCL trace of object lifetimes" OFF) |
|
|
option(TRISYCL_TRACE_KERNEL "triSYCL trace of kernel execution" OFF) |
|
|
|
|
|
mark_as_advanced(TRISYCL_OPENMP) |
|
|
mark_as_advanced(TRISYCL_OPENCL) |
|
|
mark_as_advanced(TRISYCL_NO_ASYNC) |
|
|
mark_as_advanced(TRISYCL_DEBUG) |
|
|
mark_as_advanced(TRISYCL_DEBUG_STRUCTORS) |
|
|
mark_as_advanced(TRISYCL_TRACE_KERNEL) |
|
|
|
|
|
|
|
|
set(CL_SYCL_LANGUAGE_VERSION 220 CACHE STRING |
|
|
"Host language version to be used by trisYCL (default is: 220)") |
|
|
set(TRISYCL_CL_LANGUAGE_VERSION 220 CACHE STRING |
|
|
"Device language version to be used by trisYCL (default is: 220)") |
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17) |
|
|
set(CXX_STANDARD_REQUIRED ON) |
|
|
|
|
|
|
|
|
|
|
|
include(CMakeFindDependencyMacro) |
|
|
if(TRISYCL_OPENCL) |
|
|
find_dependency(OpenCL REQUIRED) |
|
|
if(UNIX) |
|
|
set(BOOST_COMPUTE_INCPATH /usr/include/compute CACHE PATH |
|
|
"Path to Boost.Compute headers (default is: /usr/include/compute)") |
|
|
endif() |
|
|
endif() |
|
|
|
|
|
|
|
|
if(TRISYCL_OPENMP) |
|
|
find_dependency(OpenMP REQUIRED) |
|
|
endif() |
|
|
|
|
|
|
|
|
find_dependency(Boost 1.58 REQUIRED COMPONENTS chrono log) |
|
|
|
|
|
|
|
|
if(TRISYCL_DEBUG OR TRISYCL_DEBUG_STRUCTORS OR TRISYCL_TRACE_KERNEL) |
|
|
set(LOG_NEEDED ON) |
|
|
else() |
|
|
set(LOG_NEEDED OFF) |
|
|
endif() |
|
|
|
|
|
find_dependency(Threads REQUIRED) |
|
|
|
|
|
|
|
|
if (TRISYCL_INCLUDES AND TRISYCL_LIBRARIES) |
|
|
set(TRISYCL_FIND_QUIETLY TRUE) |
|
|
endif () |
|
|
|
|
|
find_path(TRISYCL_INCLUDE_DIR |
|
|
NAMES sycl.hpp |
|
|
PATHS $ENV{TRISYCLDIR} $ENV{TRISYCLDIR}/include ${INCLUDE_INSTALL_DIR} |
|
|
PATH_SUFFIXES triSYCL |
|
|
) |
|
|
|
|
|
include(FindPackageHandleStandardArgs) |
|
|
find_package_handle_standard_args(TriSYCL DEFAULT_MSG |
|
|
TRISYCL_INCLUDE_DIR) |
|
|
|
|
|
if(NOT TRISYCL_INCLUDE_DIR) |
|
|
message(FATAL_ERROR |
|
|
"triSYCL include directory - Not found! (please set TRISYCL_INCLUDE_DIR") |
|
|
else() |
|
|
message(STATUS "triSYCL include directory - Found ${TRISYCL_INCLUDE_DIR}") |
|
|
endif() |
|
|
|
|
|
include(CMakeParseArguments) |
|
|
|
|
|
|
|
|
|
|
|
function(add_sycl_to_target) |
|
|
set(options) |
|
|
set(one_value_args |
|
|
TARGET |
|
|
) |
|
|
set(multi_value_args |
|
|
SOURCES |
|
|
) |
|
|
cmake_parse_arguments(ADD_SYCL_ARGS |
|
|
"${options}" |
|
|
"${one_value_args}" |
|
|
"${multi_value_args}" |
|
|
${ARGN} |
|
|
) |
|
|
|
|
|
|
|
|
target_include_directories (${ADD_SYCL_ARGS_TARGET} PUBLIC |
|
|
${TRISYCL_INCLUDE_DIR} |
|
|
${Boost_INCLUDE_DIRS} |
|
|
$<$<BOOL:${TRISYCL_OPENCL}>:${OpenCL_INCLUDE_DIRS}> |
|
|
$<$<BOOL:${TRISYCL_OPENCL}>:${BOOST_COMPUTE_INCPATH}>) |
|
|
|
|
|
|
|
|
target_link_libraries(${ADD_SYCL_ARGS_TARGET} |
|
|
$<$<BOOL:${TRISYCL_OPENCL}>:${OpenCL_LIBRARIES}> |
|
|
Threads::Threads |
|
|
$<$<BOOL:${LOG_NEEDED}>:Boost::log> |
|
|
Boost::chrono) |
|
|
|
|
|
|
|
|
target_compile_definitions(${ADD_SYCL_ARGS_TARGET} PUBLIC |
|
|
EIGEN_SYCL_TRISYCL |
|
|
$<$<BOOL:${TRISYCL_NO_ASYNC}>:TRISYCL_NO_ASYNC> |
|
|
$<$<BOOL:${TRISYCL_OPENCL}>:TRISYCL_OPENCL> |
|
|
$<$<BOOL:${TRISYCL_DEBUG}>:TRISYCL_DEBUG> |
|
|
$<$<BOOL:${TRISYCL_DEBUG_STRUCTORS}>:TRISYCL_DEBUG_STRUCTORS> |
|
|
$<$<BOOL:${TRISYCL_TRACE_KERNEL}>:TRISYCL_TRACE_KERNEL> |
|
|
$<$<BOOL:${LOG_NEEDED}>:BOOST_LOG_DYN_LINK>) |
|
|
|
|
|
|
|
|
target_compile_options(${ADD_SYCL_ARGS_TARGET} PUBLIC |
|
|
${TRISYCL_COMPILE_OPTIONS} |
|
|
$<$<BOOL:${TRISYCL_OPENMP}>:${OpenMP_CXX_FLAGS}>) |
|
|
|
|
|
if(${TRISYCL_OPENMP} AND (NOT WIN32)) |
|
|
|
|
|
set_target_properties(${ADD_SYCL_ARGS_TARGET} |
|
|
PROPERTIES |
|
|
LINK_FLAGS ${OpenMP_CXX_FLAGS}) |
|
|
endif() |
|
|
|
|
|
endfunction() |
|
|
|