Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
620 changes: 341 additions & 279 deletions CMakeLists.txt

Large diffs are not rendered by default.

56 changes: 32 additions & 24 deletions cmake/Modules/CompilerHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
#=============================================================================
# =============================================================================
# Copyright 2023 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# =============================================================================

include_guard(GLOBAL)

# nvhpc_find_libcudacxx_include_dir(<out_var>)
# Invokes nvc++ -stdpar to locate the libcudacxx include root (the directory
# that contains cuda/std/bit) and stores it in <out_var>.
# nvhpc_find_libcudacxx_include_dir(<out_var>) Invokes nvc++ -stdpar to locate
# the libcudacxx include root (the directory that contains cuda/std/bit) and
# stores it in <out_var>.
function(nvhpc_find_libcudacxx_include_dir out_var)
set(_src "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/find_libcudacxx.cu")
file(WRITE "${_src}" "#include <cuda/std/bit>\n")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -stdpar -E -M "${_src}"
OUTPUT_VARIABLE _output
ERROR_STRIP_TRAILING_WHITESPACE
)
COMMAND ${CMAKE_CXX_COMPILER} -stdpar -E -M "${_src}"
OUTPUT_VARIABLE _output
ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "(/[^\n]*/cuda/std/bit) " _match "${_output}")
if(CMAKE_MATCH_1)
string(REGEX REPLACE "/cuda/std/bit$" "" _dir "${CMAKE_MATCH_1}")
set(${out_var} "${_dir}" PARENT_SCOPE)
set(${out_var}
"${_dir}"
PARENT_SCOPE)
else()
set(${out_var} "" PARENT_SCOPE)
set(${out_var}
""
PARENT_SCOPE)
endif()
endfunction()

# cuda_archs_to_gpu_list(<archs> <out_var>) Converts a list of CUDA architectures (e.g.
# 80, 86, 90) to a comma-separated list of GPU names (e.g. cc80, cc86, cc90) and stores it
# in <out_var>. This is useful for passing to the -gpu option of nvc++.
# cuda_archs_to_gpu_list(<archs> <out_var>) Converts a list of CUDA
# architectures (e.g. 80, 86, 90) to a comma-separated list of GPU names (e.g.
# cc80, cc86, cc90) and stores it in <out_var>. This is useful for passing to
# the -gpu option of nvc++.
function(cuda_archs_to_gpu_list archs out_var)
set(_gpus)
foreach(_arch IN LISTS archs)
Expand All @@ -47,7 +51,9 @@ function(cuda_archs_to_gpu_list archs out_var)
list(APPEND _gpus "${_arch}")
endforeach()
list(JOIN _gpus "," _gpus)
set(${out_var} "${_gpus}" PARENT_SCOPE)
set(${out_var}
"${_gpus}"
PARENT_SCOPE)
endfunction()

function(disable_compiler)
Expand All @@ -66,6 +72,8 @@ function(disable_compiler)
endif()

if(_VAR)
set(${_VAR} "${_val}" PARENT_SCOPE)
set(${_VAR}
"${_val}"
PARENT_SCOPE)
endif()
endfunction()
106 changes: 59 additions & 47 deletions cmake/Modules/ConfigureASIO.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
option(STDEXEC_ENABLE_ASIO "Enable ASIO targets" OFF)
set(STDEXEC_ASIO_IMPLEMENTATION "boost" CACHE STRING "boost")
set_property(CACHE STDEXEC_ASIO_IMPLEMENTATION PROPERTY STRINGS boost standalone)
set(STDEXEC_ASIO_IMPLEMENTATION
"boost"
CACHE STRING "boost")
set_property(CACHE STDEXEC_ASIO_IMPLEMENTATION PROPERTY STRINGS boost
standalone)

if(STDEXEC_ENABLE_ASIO)
set(STDEXEC_ASIO_USES_BOOST FALSE)
Expand All @@ -11,95 +14,104 @@ if(STDEXEC_ENABLE_ASIO)
elseif(${STDEXEC_ASIO_IMPLEMENTATION} STREQUAL "standalone")
set(STDEXEC_ASIO_USES_STANDALONE TRUE)
else()
message(FATAL_ERROR "Unknown configuration for ASIO implementation: " ${STDEXEC_ASIO_IMPLEMENTATION})
message(FATAL_ERROR "Unknown configuration for ASIO implementation: "
${STDEXEC_ASIO_IMPLEMENTATION})
endif()

set(STDEXEC_ASIO_CONFIG_HPP ${CMAKE_CURRENT_BINARY_DIR}/include/exec/asio/asio_config.hpp)
set(STDEXEC_ASIO_CONFIG_HPP
${CMAKE_CURRENT_BINARY_DIR}/include/exec/asio/asio_config.hpp)

configure_file(
include/exec/asio/asio_config.hpp.in
${STDEXEC_ASIO_CONFIG_HPP}
)
configure_file(include/exec/asio/asio_config.hpp.in
${STDEXEC_ASIO_CONFIG_HPP})

file(GLOB_RECURSE asioexec_sources CONFIGURE_DEPENDS include/exec/asio/*.hpp)

if(${STDEXEC_ASIO_USES_BOOST})
set(BOOST_INCLUDE_LIBRARIES asio system)
set(BOOST_VERSION 1.86.0)
rapids_cpm_find(Boost ${BOOST_VERSION}
rapids_cpm_find(
Boost
${BOOST_VERSION}
CPM_ARGS
URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz
OPTIONS "BOOST_SKIP_INSTALL_RULES OFF"
)
URL
https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz
OPTIONS
"BOOST_SKIP_INSTALL_RULES OFF")

add_library(asioexec INTERFACE)
list(APPEND stdexec_export_targets asioexec)
add_library(STDEXEC::asioexec ALIAS asioexec)

# These aliases are provided for backwards compatibility with the old target names
# These aliases are provided for backwards compatibility with the old target
# names
add_library(asioexec_boost ALIAS asioexec)
add_library(stdexec_boost_pool ALIAS asioexec)
add_library(STDEXEC::asio_pool ALIAS asioexec)
add_library(STDEXEC::asioexec_boost ALIAS asioexec)

target_sources(asioexec PUBLIC
FILE_SET headers
TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES ${asioexec_sources}
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include
FILES ${STDEXEC_ASIO_CONFIG_HPP}
)
target_sources(
asioexec
PUBLIC FILE_SET
headers
TYPE
HEADERS
BASE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
FILES
${asioexec_sources}
BASE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/include
FILES
${STDEXEC_ASIO_CONFIG_HPP})

target_compile_definitions(asioexec INTERFACE STDEXEC_ASIO_USES_BOOST)

target_link_libraries(asioexec INTERFACE
STDEXEC::stdexec
Boost::asio
)
target_link_libraries(asioexec INTERFACE STDEXEC::stdexec Boost::asio)
if(STDEXEC_INSTALL)
install(TARGETS asioexec
install(
TARGETS asioexec
EXPORT stdexec-exports
FILE_SET headers
)
FILE_SET headers)
endif()

elseif(${STDEXEC_ASIO_USES_STANDALONE})
include(cmake/import_standalone_asio.cmake)
import_standalone_asio(
TAG "asio-1-31-0"
VERSION "1.31.0")
import_standalone_asio(TAG "asio-1-31-0" VERSION "1.31.0")

add_library(asioexec INTERFACE)
list(APPEND stdexec_export_targets asioexec)
add_library(STDEXEC::asioexec ALIAS asioexec)

# These aliases are provided for backwards compatibility with the old target names
# These aliases are provided for backwards compatibility with the old target
# names
add_library(asioexec_asio ALIAS asioexec)
add_library(stdexec_asio_pool ALIAS asioexec)
add_library(STDEXEC::asio_pool ALIAS asioexec)
add_library(STDEXEC::asioexec_asio ALIAS asioexec)

target_sources(asioexec PUBLIC
FILE_SET headers
TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES ${asioexec_sources}
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include
FILES ${STDEXEC_ASIO_CONFIG_HPP}
)
target_sources(
asioexec
PUBLIC FILE_SET
headers
TYPE
HEADERS
BASE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
FILES
${asioexec_sources}
BASE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/include
FILES
${STDEXEC_ASIO_CONFIG_HPP})

target_compile_definitions(asioexec INTERFACE STDEXEC_ASIO_USES_STANDALONE)

target_link_libraries(asioexec INTERFACE
STDEXEC::stdexec
asio
)
target_link_libraries(asioexec INTERFACE STDEXEC::stdexec asio)
if(STDEXEC_INSTALL)
install(TARGETS asioexec asio
install(
TARGETS asioexec asio
EXPORT stdexec-exports
FILE_SET headers
)
FILE_SET headers)
endif()

else()
Expand Down
80 changes: 43 additions & 37 deletions cmake/Modules/ConfigureTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,75 @@ option(STDEXEC_ENABLE_TBB "Enable TBB targets" OFF)

include(CheckIncludeFileCXX)
rapids_find_package(
TBB QUIET
COMPONENTS tbb
BUILD_EXPORT_SET stdexec-exports
INSTALL_EXPORT_SET stdexec-exports
)
TBB
QUIET
COMPONENTS
tbb
BUILD_EXPORT_SET
stdexec-exports
INSTALL_EXPORT_SET
stdexec-exports)

# If TBB is available and the stdlib is libstdc++, then a #include of <execution> will
# pull in TBB headers, creating a link-time dependency on TBB.
if (TBB_FOUND)
if (NOT STDEXEC_ENABLE_TBB)
# If TBB is available and the stdlib is libstdc++, then a #include of
# <execution> will pull in TBB headers, creating a link-time dependency on TBB.
if(TBB_FOUND)
if(NOT STDEXEC_ENABLE_TBB)
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(__GLIBCXX__ "ciso646" _glibcxx_version_defined)
if (_glibcxx_version_defined)
if(_glibcxx_version_defined)
set(STDEXEC_ENABLE_TBB ON)
message(STATUS "Enabling TBB support in stdexec because <tbb/tbb.h> is available and libstdc++ is used.")
message(
STATUS
"Enabling TBB support in stdexec because <tbb/tbb.h> is available and libstdc++ is used."
)
endif()
endif()
else()
set(STDEXEC_ENABLE_TBB OFF)
endif()

# TBB does not sanitize cleanly. Disable TBB support if any sanitizer is enabled.
# TBB does not sanitize cleanly. Disable TBB support if any sanitizer is
# enabled.
string(FIND "${CMAKE_CXX_FLAGS}" "-fsanitize" _fsanitize_flag_index)
if (_fsanitize_flag_index GREATER -1)
message(STATUS "Disabling TBB support in stdexec because sanitizers are enabled.")
if(_fsanitize_flag_index GREATER -1)
message(
STATUS "Disabling TBB support in stdexec because sanitizers are enabled.")
set(STDEXEC_ENABLE_TBB OFF)
endif()

if (STDEXEC_ENABLE_TBB)
# CONFIGURE_DEPENDS ensures that CMake reconfigures when a relevant hpp file is
# added or removed.
if(STDEXEC_ENABLE_TBB)
# CONFIGURE_DEPENDS ensures that CMake reconfigures when a relevant hpp file
# is added or removed.
file(GLOB_RECURSE tbbexec_headers CONFIGURE_DEPENDS include/exec/tbb/*.hpp)
add_library(tbbexec INTERFACE)
list(APPEND stdexec_export_targets tbbexec)
add_library(STDEXEC::tbbexec ALIAS tbbexec)

# These aliases are provided for backwards compatibility with the old target names
# These aliases are provided for backwards compatibility with the old target
# names
add_library(tbbpool ALIAS tbbexec)
add_library(STDEXEC::tbbpool ALIAS tbbexec)

target_sources(tbbexec
PUBLIC
FILE_SET headers
TYPE HEADERS
BASE_DIRS include
FILES ${tbbexec_headers}
)
target_compile_definitions(tbbexec INTERFACE
STDEXEC_ENABLE_TBB
)
target_sources(
tbbexec
PUBLIC FILE_SET
headers
TYPE
HEADERS
BASE_DIRS
include
FILES
${tbbexec_headers})
target_compile_definitions(tbbexec INTERFACE STDEXEC_ENABLE_TBB)

target_link_libraries(stdexec INTERFACE
TBB::tbb
)
target_link_libraries(stdexec INTERFACE TBB::tbb)

target_link_libraries(tbbexec INTERFACE
STDEXEC::stdexec
)
target_link_libraries(tbbexec INTERFACE STDEXEC::stdexec)

if(STDEXEC_INSTALL)
install(TARGETS tbbexec
install(
TARGETS tbbexec
EXPORT stdexec-exports
FILE_SET headers
)
FILE_SET headers)
endif()
endif()
Loading
Loading