Skip to content

Commit

Permalink
Merge branch 'main' into syssched-R6-work
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler authored Jan 25, 2025
2 parents 263c854 + 9514e7b commit d7498f8
Show file tree
Hide file tree
Showing 96 changed files with 480 additions and 414 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ImplementationFileExtensions:
- cpp
- cxx
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: eniebler
CheckOptions:
Expand Down
19 changes: 16 additions & 3 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,33 @@ If:

---

# Apply a config conditionally to all C++ files
# Apply a config conditionally to all C++ files except those in the
# include/execpools directory which need platform-dependent headers
If:
PathMatch: .*\.(c|h)pp
PathMatch: .*\.(c|h)pp$
PathExclude: .*/execpools/.*

---

# Apply a config conditionally to all CUDA files
If:
PathMatch: .*\.cuh?
PathMatch: .*\.cuh?$
CompileFlags:
Add:
# Allow variadic CUDA functions
- "-Xclang=-fcuda-allow-variadic-functions"

---

# The following file assumes a define.
If:
PathMatch: .*/__system_context_default_impl_entry\.hpp
CompileFlags:
Add:
- "-DSTDEXEC_SYSTEM_CONTEXT_INLINE=inline"

---

# Use clang++ in CUDA mode to provide intellisense for files with `nvexec` in their path
If:
PathMatch: (include|examples|test)/nvexec.*
Expand Down Expand Up @@ -70,3 +81,5 @@ Diagnostics:
# The NVHPC version of _NVCXX_EXPAND_PACK macro triggers this clang error.
# Temporarily suppressing it, but should probably fix
- "template_param_shadow"
- "pp_expr_bad_token_binop" # erroneous error from STDEXEC_ENABLE_EXTRA_TYPE_CHECKING()
- "#warnings"
91 changes: 61 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ endif()
# - Download and initialize RAPIDS CMake helpers -----------------------------

# Fetch rapids-cmake
if(NOT EXISTS ${CMAKE_BINARY_DIR}/RAPIDS.cmake)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake)
${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake)
endif()
# Initialize rapids-cmake
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake)
# utilities for generating export set package metadata
include(rapids-export)
# utilities for finding packages
Expand All @@ -37,11 +37,11 @@ include(rapids-cpm)
# - Project definition -------------------------------------------------------

# Define the project and set the version and languages
if(NOT EXISTS ${CMAKE_BINARY_DIR}/execution.bs)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/execution.bs)
file(DOWNLOAD "https://raw.githubusercontent.com/cplusplus/sender-receiver/main/execution.bs"
${CMAKE_BINARY_DIR}/execution.bs)
${CMAKE_CURRENT_BINARY_DIR}/execution.bs)
endif()
file(STRINGS "${CMAKE_BINARY_DIR}/execution.bs" STD_EXECUTION_BS_REVISION_LINE REGEX "Revision: [0-9]+")
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/execution.bs" STD_EXECUTION_BS_REVISION_LINE REGEX "Revision: [0-9]+")
string(REGEX REPLACE "Revision: ([0-9]+)" "\\1" STD_EXECUTION_BS_REVISION ${STD_EXECUTION_BS_REVISION_LINE})

# nvc++ isn't supported by (s)ccache yet, so unset these before the `project()`
Expand Down Expand Up @@ -151,19 +151,38 @@ set(stdexec_export_targets)
# Define the main library
add_library(stdexec INTERFACE)

file(GLOB_RECURSE exec_headers CONFIGURE_DEPENDS include/exec/*.hpp)
file(GLOB_RECURSE stdexec_headers CONFIGURE_DEPENDS include/stdexec/*.hpp)
target_sources(stdexec
PUBLIC
FILE_SET headers
TYPE HEADERS
BASE_DIRS include
FILES
${exec_headers}
${stdexec_headers}
# stdexec_version_config.hpp is generated by rapids' script
FILE_SET version_config
TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include
FILES
${CMAKE_CURRENT_BINARY_DIR}/include/stdexec_version_config.hpp
)
list(APPEND stdexec_export_targets stdexec)

# Set library version
set_target_properties(stdexec PROPERTIES
VERSION "${STDEXEC_VERSION}"
SOVERSION "${STDEXEC_VERSION_MAJOR}")

if (BUILD_TESTING)
# Test headers are self-contained
set_target_properties(stdexec PROPERTIES
VERIFY_INTERFACE_HEADER_SETS TRUE)
endif()

# Declare the public include directories
include(GNUInstallDirs)
target_include_directories(stdexec INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(stdexec INTERFACE Threads::Threads)

Expand Down Expand Up @@ -269,9 +288,15 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC")
endif()

if(STDEXEC_ENABLE_CUDA)

file(GLOB_RECURSE nvexec_sources include/nvexec/*.cuh)
add_library(nvexec INTERFACE ${nvexec_sources})
file(GLOB_RECURSE nvexec_headers CONFIGURE_DEPENDS include/nvexec/*.cuh)
add_library(nvexec INTERFACE)
target_sources(nvexec
PUBLIC
FILE_SET headers
TYPE HEADERS
BASE_DIRS include
FILES ${nvexec_headers}
)
list(APPEND stdexec_export_targets nvexec)
add_library(STDEXEC::nvexec ALIAS nvexec)

Expand All @@ -283,6 +308,10 @@ if(STDEXEC_ENABLE_CUDA)
target_link_options(nvexec INTERFACE
$<$<AND:$<CXX_COMPILER_ID:NVHPC>,$<COMPILE_LANGUAGE:CXX>>:-stdpar -gpu=cc${CMAKE_CUDA_ARCHITECTURES}>)

install(TARGETS nvexec
EXPORT stdexec-exports
FILE_SET headers)

if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC"))
include(rapids-cuda)
# Needs to run before `enable_language(CUDA)`
Expand Down Expand Up @@ -330,16 +359,29 @@ if (STDEXEC_ENABLE_TBB)
INSTALL_EXPORT_SET stdexec-exports
)

file(GLOB_RECURSE tbbpool_sources include/execpools/tbb/*.hpp)
add_library(tbbpool INTERFACE ${tbbpool_sources})
# CONFIGURE_DEPENDS ensures that CMake reconfigures when a relevant hpp file is
# added or removed.
file(GLOB_RECURSE tbbpool_headers CONFIGURE_DEPENDS include/execpools/tbb/*.hpp)
add_library(tbbpool INTERFACE)
list(APPEND stdexec_export_targets tbbpool)
add_library(STDEXEC::tbbpool ALIAS tbbpool)
target_sources(tbbpool
PUBLIC
FILE_SET headers
TYPE HEADERS
BASE_DIRS include
FILES ${tbbpool_headers}
)

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

install(TARGETS tbbpool
EXPORT stdexec-exports
FILE_SET headers)
endif()

option(STDEXEC_ENABLE_TASKFLOW "Enable TaskFlow targets" OFF)
Expand Down Expand Up @@ -436,10 +478,6 @@ endif()

set(SYSTEM_CONTEXT_SOURCES src/system_context/system_context.cpp)
add_library(system_context STATIC ${SYSTEM_CONTEXT_SOURCES})
target_include_directories(system_context PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_features(system_context PUBLIC cxx_std_20)
set_target_properties(system_context PROPERTIES
CXX_STANDARD 20
Expand All @@ -449,7 +487,7 @@ target_compile_options(system_context PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Zc:__cplusplus /Zc:preprocessor>
)
add_library(STDEXEC::system_context ALIAS system_context)

target_link_libraries(system_context PUBLIC stdexec)


if(CMAKE_CROSSCOMPILING)
Expand Down Expand Up @@ -500,16 +538,9 @@ endif()
include(CPack)

install(TARGETS stdexec system_context
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT stdexec-exports)

install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/stdexec_version_config.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
EXPORT stdexec-exports
FILE_SET headers
FILE_SET version_config)

##############################################################################
# Install exports ------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion include/exec/__detail/__bit_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#endif

#include <cstring>
#include <type_traits>

namespace exec {

Expand Down
1 change: 0 additions & 1 deletion include/exec/__detail/__bwos_lifo_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <new>
#include <utility>
#include <vector>

Expand Down
8 changes: 5 additions & 3 deletions include/exec/__detail/__numa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
#pragma once

#include "../../stdexec/__detail/__config.hpp"
#include "../scope.hpp"
#include "../../stdexec/__detail/__meta.hpp"
#include "../scope.hpp" // IWYU pragma: keep

#include <algorithm>
#include <algorithm> // IWYU pragma: keep
#include <cstddef>
#include <memory>
#include <new>
#include <new> // IWYU pragma: keep
#include <thread>
#include <utility>

// Work around a bug in the NVHPC compilers prior to version 24.03
#if STDEXEC_NVHPC()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# error "STDEXEC_SYSTEM_CONTEXT_INLINE must be defined before including this header"
#endif

#include "__system_context_default_impl.hpp"
#include "__system_context_default_impl.hpp" // IWYU pragma: keep

#define __STDEXEC_SYSTEM_CONTEXT_API extern STDEXEC_SYSTEM_CONTEXT_INLINE STDEXEC_ATTRIBUTE((weak))

Expand Down
26 changes: 16 additions & 10 deletions include/exec/__detail/__system_context_replaceability_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@

#include "stdexec/__detail/__execution_fwd.hpp"

#include <cstdint>
#include <exception>
#include <typeindex>
#include <type_traits>
#include <optional>

struct __uuid {
uint64_t __parts1;
uint64_t __parts2;
std::uint64_t __parts1;
std::uint64_t __parts2;

friend bool operator==(__uuid, __uuid) noexcept = default;
};
Expand Down Expand Up @@ -73,8 +76,8 @@ namespace exec::system_context_replaceability {
extern __system_context_backend_factory<_Interface>
set_system_context_backend_factory(__system_context_backend_factory<_Interface> __new_factory);

/// Interface for completing a sender operation.
/// Backend will call frontend though this interface for completing the `schedule` and `schedule_bulk` operations.
/// Interface for completing a sender operation. Backend will call frontend though this interface
/// for completing the `schedule` and `schedule_bulk` operations.
struct receiver {
virtual ~receiver() = default;

Expand Down Expand Up @@ -106,14 +109,14 @@ namespace exec::system_context_replaceability {
/// Receiver for bulk sheduling operations.
struct bulk_item_receiver : receiver {
/// Called for each item of a bulk operation, possible on different threads.
virtual void start(uint32_t) noexcept = 0;
virtual void start(std::uint32_t) noexcept = 0;
};

/// Describes a storage space.
/// Used to pass preallocated storage from the frontend to the backend.
struct storage {
void* __data;
uint32_t __size;
std::uint32_t __size;
};

/// Interface for the system scheduler
Expand All @@ -122,12 +125,15 @@ namespace exec::system_context_replaceability {

virtual ~system_scheduler() = default;

/// Schedule work on system scheduler, calling `__r` when done and using `__s` for preallocated memory.
/// Schedule work on system scheduler, calling `__r` when done and using `__s` for preallocated
/// memory.
virtual void schedule(storage __s, receiver* __r) noexcept = 0;
/// Schedule bulk work of size `__n` on system scheduler, calling `__r` for each item and then when done, and using `__s` for preallocated memory.
virtual void bulk_schedule(uint32_t __n, storage __s, bulk_item_receiver* __r) noexcept = 0;
/// Schedule bulk work of size `__n` on system scheduler, calling `__r` for each item and then
/// when done, and using `__s` for preallocated memory.
virtual void
bulk_schedule(std::uint32_t __n, storage __s, bulk_item_receiver* __r) noexcept = 0;
};

} // namespace exec::system_context_replaceability

#endif
#endif
1 change: 1 addition & 0 deletions include/exec/__detail/intrusive_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <cstddef>
#include <bit>
#include <utility>

STDEXEC_PRAGMA_PUSH()
STDEXEC_PRAGMA_IGNORE_EDG(not_used_in_partial_spec_arg_list)
Expand Down
Loading

0 comments on commit d7498f8

Please sign in to comment.