|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define_property(TARGET PROPERTY _THRUST_HOST |
|
BRIEF_DOCS "A target's host system: CPP, TBB, or OMP." |
|
FULL_DOCS "A target's host system: CPP, TBB, or OMP." |
|
) |
|
define_property(TARGET PROPERTY _THRUST_DEVICE |
|
BRIEF_DOCS "A target's device system: CUDA, CPP, TBB, or OMP." |
|
FULL_DOCS "A target's device system: CUDA, CPP, TBB, or OMP." |
|
) |
|
define_property(TARGET PROPERTY _THRUST_DIALECT |
|
BRIEF_DOCS "A target's C++ dialect: 11, 14, or 17." |
|
FULL_DOCS "A target's C++ dialect: 11, 14, or 17." |
|
) |
|
define_property(TARGET PROPERTY _THRUST_PREFIX |
|
BRIEF_DOCS "A prefix describing the config, eg. 'thrust.cpp.cuda.cpp14'." |
|
FULL_DOCS "A prefix describing the config, eg. 'thrust.cpp.cuda.cpp14'." |
|
) |
|
|
|
function(thrust_set_target_properties target_name host device dialect prefix) |
|
set_target_properties(${target_name} |
|
PROPERTIES |
|
_THRUST_HOST ${host} |
|
_THRUST_DEVICE ${device} |
|
_THRUST_DIALECT ${dialect} |
|
_THRUST_PREFIX ${prefix} |
|
) |
|
|
|
get_property(langs GLOBAL PROPERTY ENABLED_LANGUAGES) |
|
set(standard_features) |
|
if (CUDA IN_LIST langs) |
|
list(APPEND standard_features cuda_std_${dialect}) |
|
endif() |
|
if (CXX IN_LIST langs) |
|
list(APPEND standard_features cxx_std_${dialect}) |
|
endif() |
|
|
|
get_target_property(type ${target_name} TYPE) |
|
if (${type} STREQUAL "INTERFACE_LIBRARY") |
|
target_compile_features(${target_name} INTERFACE |
|
${standard_features} |
|
) |
|
else() |
|
target_compile_features(${target_name} PUBLIC |
|
${standard_features} |
|
) |
|
set_target_properties(${target_name} |
|
PROPERTIES |
|
CXX_STANDARD ${dialect} |
|
CUDA_STANDARD ${dialect} |
|
|
|
|
|
|
|
|
|
|
|
|
|
CXX_STANDARD_REQUIRED ON |
|
CUDA_STANDARD_REQUIRED ON |
|
ARCHIVE_OUTPUT_DIRECTORY "${THRUST_LIBRARY_OUTPUT_DIR}" |
|
LIBRARY_OUTPUT_DIRECTORY "${THRUST_LIBRARY_OUTPUT_DIR}" |
|
RUNTIME_OUTPUT_DIRECTORY "${THRUST_EXECUTABLE_OUTPUT_DIR}" |
|
) |
|
|
|
|
|
|
|
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) |
|
set_target_properties(${target_name} |
|
PROPERTIES |
|
CUDA_ARCHITECTURES OFF |
|
) |
|
endif() |
|
|
|
if ("CUDA" STREQUAL "${device}" AND |
|
"NVCXX" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") |
|
set_target_properties(${target_name} PROPERTIES |
|
CUDA_RESOLVE_DEVICE_SYMBOLS OFF |
|
) |
|
endif() |
|
endif() |
|
endfunction() |
|
|
|
|
|
|
|
macro(thrust_get_target_property prop_var target_name prop) |
|
get_property(${prop_var} TARGET ${target_name} PROPERTY _THRUST_${prop}) |
|
endmacro() |
|
|
|
|
|
|
|
|
|
|
|
|
|
macro(thrust_get_target_properties target_name) |
|
thrust_get_target_property(${target_name}_HOST ${target_name} HOST) |
|
thrust_get_target_property(${target_name}_DEVICE ${target_name} DEVICE) |
|
thrust_get_target_property(${target_name}_DIALECT ${target_name} DIALECT) |
|
thrust_get_target_property(${target_name}_PREFIX ${target_name} PREFIX) |
|
endmacro() |
|
|
|
|
|
function(thrust_clone_target_properties dst_target src_target) |
|
thrust_get_target_properties(${src_target}) |
|
thrust_set_target_properties(${dst_target} |
|
${${src_target}_HOST} |
|
${${src_target}_DEVICE} |
|
${${src_target}_DIALECT} |
|
${${src_target}_PREFIX} |
|
) |
|
endfunction() |
|
|
|
|
|
function(_thrust_is_config_valid var_name host device dialect) |
|
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_${host} AND |
|
THRUST_MULTICONFIG_ENABLE_SYSTEM_${device} AND |
|
THRUST_MULTICONFIG_ENABLE_DIALECT_CPP${dialect} AND |
|
"${host}_${device}" IN_LIST THRUST_MULTICONFIG_WORKLOAD_${THRUST_MULTICONFIG_WORKLOAD}_CONFIGS) |
|
set(${var_name} TRUE PARENT_SCOPE) |
|
else() |
|
set(${var_name} FALSE PARENT_SCOPE) |
|
endif() |
|
endfunction() |
|
|
|
function(_thrust_init_target_list) |
|
set(THRUST_TARGETS "" CACHE INTERNAL "" FORCE) |
|
endfunction() |
|
|
|
function(_thrust_add_target_to_target_list target_name host device dialect prefix) |
|
thrust_set_target_properties(${target_name} ${host} ${device} ${dialect} ${prefix}) |
|
|
|
target_link_libraries(${target_name} INTERFACE |
|
thrust.compiler_interface |
|
) |
|
|
|
|
|
if (TARGET thrust.compiler_interface_cpp${dialect}) |
|
target_link_libraries(${target_name} INTERFACE |
|
thrust.compiler_interface_cpp${dialect} |
|
) |
|
endif() |
|
|
|
|
|
|
|
if ((NOT host STREQUAL "TBB") OR (NOT device STREQUAL "CUDA")) |
|
target_link_libraries(${target_name} INTERFACE |
|
thrust.promote_cudafe_warnings |
|
) |
|
endif() |
|
|
|
set(THRUST_TARGETS ${THRUST_TARGETS} ${target_name} CACHE INTERNAL "" FORCE) |
|
|
|
set(label "${host}.${device}.cpp${dialect}") |
|
string(TOLOWER "${label}" label) |
|
message(STATUS "Enabling Thrust configuration: ${label}") |
|
endfunction() |
|
|
|
function(_thrust_build_target_list_multiconfig) |
|
|
|
|
|
if (THRUST_MULTICONFIG_ENABLE_DIALECT_ALL OR |
|
THRUST_MULTICONFIG_ENABLE_DIALECT_LATEST) |
|
message(STATUS "Testing for supported language standards...") |
|
include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/DetectSupportedStandards.cmake") |
|
detect_supported_standards(THRUST CXX ${THRUST_CPP_DIALECT_OPTIONS}) |
|
if (THRUST_CUDA_FOUND) |
|
detect_supported_standards(THRUST CUDA ${THRUST_CPP_DIALECT_OPTIONS}) |
|
endif() |
|
|
|
|
|
set(supported_dialects) |
|
set(latest_dialect 11) |
|
foreach(standard IN LISTS THRUST_CPP_DIALECT_OPTIONS) |
|
if ((THRUST_CXX_${standard}_SUPPORTED) AND |
|
((NOT THRUST_CUDA_FOUND) OR THRUST_CUDA_${standard}_SUPPORTED)) |
|
|
|
|
|
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) AND (standard EQUAL 11)) |
|
continue() |
|
endif() |
|
|
|
list(APPEND supported_dialects ${standard}) |
|
if (latest_dialect LESS standard) |
|
set(latest_dialect ${standard}) |
|
endif() |
|
endif() |
|
endforeach() |
|
|
|
if (THRUST_MULTICONFIG_ENABLE_DIALECT_ALL) |
|
foreach(standard IN LISTS THRUST_CPP_DIALECT_OPTIONS) |
|
if (standard IN_LIST supported_dialects) |
|
set(THRUST_MULTICONFIG_ENABLE_DIALECT_CPP${standard} ON CACHE BOOL |
|
"Generate C++${dialect} build configurations." FORCE |
|
) |
|
else() |
|
set(THRUST_MULTICONFIG_ENABLE_DIALECT_CPP${standard} OFF CACHE BOOL |
|
"Generate C++${dialect} build configurations." FORCE |
|
) |
|
endif() |
|
endforeach() |
|
elseif(THRUST_MULTICONFIG_ENABLE_DIALECT_LATEST) |
|
foreach(standard IN LISTS THRUST_CPP_DIALECT_OPTIONS) |
|
if (standard EQUAL latest_dialect) |
|
set(THRUST_MULTICONFIG_ENABLE_DIALECT_CPP${standard} ON CACHE BOOL |
|
"Generate C++${dialect} build configurations." FORCE |
|
) |
|
else() |
|
set(THRUST_MULTICONFIG_ENABLE_DIALECT_CPP${standard} OFF CACHE BOOL |
|
"Generate C++${dialect} build configurations." FORCE |
|
) |
|
endif() |
|
endforeach() |
|
endif() |
|
endif() |
|
|
|
|
|
|
|
|
|
if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}" AND |
|
THRUST_MULTICONFIG_ENABLE_DIALECT_CPP11) |
|
message(WARNING |
|
"Supported versions of MSVC (2017+) do not distinguish between C++11 " |
|
"and C++14. The requested C++11 targets may be redundant." |
|
) |
|
endif() |
|
|
|
|
|
foreach(host IN LISTS THRUST_HOST_SYSTEM_OPTIONS) |
|
foreach(device IN LISTS THRUST_DEVICE_SYSTEM_OPTIONS) |
|
foreach(dialect IN LISTS THRUST_CPP_DIALECT_OPTIONS) |
|
_thrust_is_config_valid(config_valid ${host} ${device} ${dialect}) |
|
if (config_valid) |
|
set(prefix "thrust.${host}.${device}.cpp${dialect}") |
|
string(TOLOWER "${prefix}" prefix) |
|
|
|
|
|
set(target_name "${prefix}") |
|
thrust_create_target(${target_name} |
|
HOST ${host} |
|
DEVICE ${device} |
|
${THRUST_TARGET_FLAGS} |
|
) |
|
|
|
|
|
_thrust_add_target_to_target_list(${target_name} |
|
${host} ${device} ${dialect} ${prefix} |
|
) |
|
|
|
|
|
add_custom_target(${prefix}.all) |
|
add_dependencies(thrust.all ${prefix}.all) |
|
endif() |
|
endforeach() |
|
endforeach() |
|
endforeach() |
|
|
|
list(LENGTH THRUST_TARGETS count) |
|
message(STATUS "${count} unique thrust.host.device.dialect configurations generated") |
|
endfunction() |
|
|
|
function(_thrust_build_target_list_singleconfig) |
|
set(host ${THRUST_HOST_SYSTEM}) |
|
set(device ${THRUST_DEVICE_SYSTEM}) |
|
set(dialect ${THRUST_CPP_DIALECT}) |
|
set(prefix "thrust") |
|
|
|
_thrust_add_target_to_target_list(thrust ${host} ${device} ${dialect} ${prefix}) |
|
endfunction() |
|
|
|
|
|
|
|
function(thrust_build_target_list) |
|
|
|
_thrust_init_target_list() |
|
|
|
|
|
set(THRUST_TARGET_FLAGS) |
|
macro(add_flag_option flag docstring default) |
|
set(opt "THRUST_${flag}") |
|
option(${opt} "${docstring}" "${default}") |
|
mark_as_advanced(${opt}) |
|
if (${${opt}}) |
|
list(APPEND THRUST_TARGET_FLAGS ${flag}) |
|
endif() |
|
endmacro() |
|
add_flag_option(IGNORE_DEPRECATED_CPP_DIALECT "Don't warn about any deprecated C++ standards and compilers." OFF) |
|
add_flag_option(IGNORE_DEPRECATED_CPP_11 "Don't warn about deprecated C++11." OFF) |
|
add_flag_option(IGNORE_DEPRECATED_COMPILER "Don't warn about deprecated compilers." OFF) |
|
add_flag_option(IGNORE_CUB_VERSION_CHECK "Don't warn about mismatched CUB versions." OFF) |
|
add_flag_option(IGNORE_DEPRECATED_API "Don't warn about deprecated Thrust or CUB APIs." OFF) |
|
|
|
|
|
|
|
|
|
file(GLOB_RECURSE all_sources |
|
RELATIVE "${CMAKE_CURRENT_LIST_DIR}" |
|
"${Thrust_SOURCE_DIR}/thrust/*.h" |
|
"${Thrust_SOURCE_DIR}/thrust/*.inl" |
|
) |
|
add_custom_target(thrust.all SOURCES ${all_sources}) |
|
|
|
if (THRUST_ENABLE_MULTICONFIG) |
|
_thrust_build_target_list_multiconfig() |
|
else() |
|
_thrust_build_target_list_singleconfig() |
|
endif() |
|
endfunction() |
|
|