Skip to content

Commit

Permalink
Merge branch 'main' into ci-for-nvhpc-debug-build
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler authored Dec 26, 2023
2 parents cd1ebb4 + 5dee1bc commit 511a1b5
Show file tree
Hide file tree
Showing 193 changed files with 21,390 additions and 16,422 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: [
'STDEXEC_ATTRIBUTE',
'STDEXEC_NO_UNIQUE_ADDRESS',
'STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS',
'STDEXEC_DETAIL_CUDACC_HOST_DEVICE',
]
BinPackArguments: false
BinPackParameters: false
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# Fixed access modifier offset
9150f682444f8f45c02bf858b767c1a0db81e548

# Put all tests in anonymous namespaces and reformat
5d6b265c3b7ebcf49a725ce17c399b1e9666118d
30 changes: 30 additions & 0 deletions .github/workflows/ci.cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,33 @@ jobs:
- build-cpu
steps:
- run: echo "CI (CPU) success"

build-cpu-windows:
runs-on: windows-latest
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- { compiler: "cl", build: "Debug", name: "CPU (Windows) (msvc, Debug)" }
- { compiler: "cl", build: "Release", name: "CPU (Windows) (msvc, Release)" }
#- { compiler: "clang++", build: "Debug", name: "CPU (Windows) (clang, Debug)" }
#- { compiler: "clang++", build: "Release", name: "CPU (Windows) (clang, Release)" }
#- { compiler: "clang-cl", build: "Debug", name: "CPU (Windows) (clang-cl, Debug)" }
#- { compiler: "clang-cl", build: "Release", name: "CPU (Windows) (clang-cl, Release)" }
steps:
- name: Checkout stdexec (Windows)
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Build and test CPU schedulers (Windows)
shell: pwsh
run: .github/workflows/test-windows.ps1 -Compiler '${{ matrix.compiler }}' -Config '${{ matrix.build }}'

ci-cpu-windows:
runs-on: windows-latest
name: CI (CPU) (Windows)
needs:
- build-cpu-windows
steps:
- run: echo "CI (CPU) (Windows) success"
7 changes: 6 additions & 1 deletion .github/workflows/ci.gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ jobs:
-DCMAKE_CUDA_COMPILER:FILEPATH="$cxx" \
-DCMAKE_CUDA_ARCHITECTURES:STRING=${{ matrix.sm }};
# Compile
cmake --build build;
cmake --build build -v;
# Print sccache stats
sccache -s
# Tests
ctest --test-dir build --verbose --output-on-failure --timeout 60;
# Examples
./build/examples/nvexec/maxwell_cpu_st --iterations=1000 --N=512 --run-cpp --run-inline-scheduler
./build/examples/nvexec/maxwell_cpu_mt --iterations=1000 --N=512 --run-std --run-stdpar --run-thread-pool-scheduler
./build/examples/nvexec/maxwell_gpu_s --iterations=1000 --N=512 --run-cuda --run-stdpar --run-stream-scheduler
ci-gpu:
runs-on: ubuntu-latest
name: CI (GPU)
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/test-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
param(
[string]$BuildDirectory="build",
[string]$Compiler="cl",
[string]$Config="Debug"
)

function Invoke-NativeCommand($Command) {
& $Command $Args

if (!$?) {
throw "${Command}: $LastExitCode"
}
}

$VSVersion = 2022
$VSEdition = 'Enterprise'
$Architecture = 'x64'

Push-Location "C:/Program Files/Microsoft Visual Studio/$VSVersion/$VSEdition/VC/Auxiliary/Build"
$VCVersion = Get-Content 'Microsoft.VCToolsVersion.default.txt'
cmd /c "vcvarsall.bat $Architecture -vcvars_ver=$VCVersion > nul & set" | ForEach-Object {
if ($_ -match '^(.+?)=(.*)') {
Set-Item -Force -Path "ENV:$($matches[1])" -Value $matches[2]
}
}
Pop-Location

if ($Compiler -ne "cl") {
$ENV:CXX=$Compiler
}

if (Test-Path -PathType Container $BuildDirectory) {
Remove-Item -Recurse $BuildDirectory | Out-Null
}
New-Item -ItemType Directory $BuildDirectory | Out-Null

Invoke-NativeCommand cmake -B $BuildDirectory -G Ninja "-DCMAKE_BUILD_TYPE=$Config" .
Invoke-NativeCommand cmake --build $BuildDirectory
Invoke-NativeCommand ctest --test-dir $BuildDirectory
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
"initCommands": ["settings set target.disable-aslr false"],
"args": "${input:CXX_PROGRAM_ARGS}",
},
{
"name": "CUDA Current Target (cuda-gdb)",
"type": "cuda-gdb",
"request": "launch",
"stopAtEntry": false,
"breakOnLaunch": false,
"internalConsoleOptions": "neverOpen",
"program": "${command:cmake.launchTargetPath}",
"cwd": "${command:cmake.launchTargetDirectory}",
"args": "${input:CXX_PROGRAM_ARGS}",
},
],
"inputs": [
{
Expand Down
73 changes: 55 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ rapids_cpm_find(Catch2 ${Catch2_VERSION}
URL https://github.com/catchorg/Catch2/archive/refs/tags/v${Catch2_VERSION}.zip
)

# Add ICM
set(icm_VERSION 1.5.0)
# Always download it, don't attempt to do `find_package(ICM)` first
set(CPM_DOWNLOAD_icm TRUE)
rapids_cpm_find(icm ${icm_VERSION}
CPM_ARGS
GITHUB_REPOSITORY iboB/icm
GIT_TAG v${icm_VERSION}
VERSION ${icm_VERSION}
PATCH_COMMAND git restore -- . && git apply ${CMAKE_CURRENT_LIST_DIR}/cmake/cpm/patches/icm/regex-build-error.diff
)

# Ensure that we link with the threading library
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
rapids_find_package(Threads REQUIRED
Expand All @@ -102,6 +114,13 @@ rapids_find_package(Threads REQUIRED
##############################################################################
# - Main library targets -----------------------------------------------------

# Detect the compiler frontend (GNU, Clang, MSVC, etc.)
if(DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
set(stdexec_compiler_frontend ${CMAKE_CXX_COMPILER_FRONTEND_VARIANT})
else()
set(stdexec_compiler_frontend ${CMAKE_CXX_COMPILER_ID})
endif()

set(stdexec_export_targets)

# Define the main library
Expand Down Expand Up @@ -139,10 +158,22 @@ target_compile_options(stdexec INTERFACE
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-fcoroutines>
)

# Increase the concepts diagnostics depth for GCC
target_compile_options(stdexec INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-fconcepts-diagnostics-depth=10>
)

# Do you want a preprocessor that works? Picky, picky.
target_compile_options(stdexec INTERFACE
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Zc:__cplusplus /Zc:preprocessor>
)

option(STDEXEC_ENABLE_EXTRA_TYPE_CHECKING "Enable extra type checking that is costly at compile-time" OFF)

if (STDEXEC_ENABLE_EXTRA_TYPE_CHECKING)
target_compile_definitions(stdexec INTERFACE STDEXEC_ENABLE_EXTRA_TYPE_CHECKING)
endif()

add_library(STDEXEC::stdexec ALIAS stdexec)

# Don't require building everything when installing
Expand All @@ -153,35 +184,28 @@ add_library(stdexec_executable_flags INTERFACE)

# Enable warnings
target_compile_options(stdexec_executable_flags INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall>
$<$<CXX_COMPILER_ID:MSVC>:
/W4>)
$<$<STREQUAL:${stdexec_compiler_frontend},GNU>:-Wall>
$<$<STREQUAL:${stdexec_compiler_frontend},AppleClang>:-Wall>
$<$<STREQUAL:${stdexec_compiler_frontend},MSVC>:/W4>)

# Increase the error limit with NVC++
target_compile_options(stdexec_executable_flags INTERFACE
$<$<CXX_COMPILER_ID:NVHPC>:-e1000>
)
$<$<CXX_COMPILER_ID:NVHPC>:-e1000>)

# Silence warnings with GCC
# Silence warnings
target_compile_options(stdexec_executable_flags INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-Wno-non-template-friend>
)

# Silence warnings with NVHPC
target_compile_options(stdexec_executable_flags INTERFACE
$<$<CXX_COMPILER_ID:NVHPC>:--diag_suppress177,550,111,497,554>
)
$<$<CXX_COMPILER_ID:MSVC>:/wd4100 /wd4101 /wd4127 /wd4324 /wd4456 /wd4459>)

# Template backtrace limit
target_compile_options(stdexec_executable_flags INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-ferror-limit=0
-fmacro-backtrace-limit=0
-ftemplate-backtrace-limit=0>
$<$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},MSVC>:/clang:>-ferror-limit=0
$<$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},MSVC>:/clang:>-fmacro-backtrace-limit=0
$<$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},MSVC>:/clang:>-ftemplate-backtrace-limit=0>
$<$<AND:$<CXX_COMPILER_ID:NVHPC>,$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,23.3.0>>:
-ftemplate-backtrace-limit 0>
)
-ftemplate-backtrace-limit 0>)

# # Always enable colored output
# target_compile_options(stdexec_executable_flags INTERFACE
Expand All @@ -199,6 +223,10 @@ target_compile_options(stdexec_executable_flags INTERFACE
-include stdexec/__detail/__force_include.hpp>
)

target_compile_definitions(
stdexec_executable_flags INTERFACE
$<$<NOT:$<AND:$<CXX_COMPILER_ID:NVHPC>,$<COMPILE_LANGUAGE:CXX>>>:STDEXEC_ENABLE_EXTRA_TYPE_CHECKING>)

# Support target for examples and tests
add_library(nvexec_executable_flags INTERFACE)

Expand Down Expand Up @@ -290,7 +318,16 @@ if (STDEXEC_ENABLE_TBB)
)
endif ()

option (STDEXEC_ENABLE_IO_URING_TESTS "Enable io_uring tests" ON)
option (STDEXEC_ENABLE_NUMA "Enable NUMA affinity for static_thread_pool" OFF)
if (STDEXEC_ENABLE_NUMA)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(numa REQUIRED)
target_link_libraries(stdexec INTERFACE numa::numa)
target_compile_definitions(stdexec INTERFACE STDEXEC_ENABLE_NUMA)
endif()
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX("linux/io_uring.h" STDEXEC_FOUND_IO_URING)
option (STDEXEC_ENABLE_IO_URING_TESTS "Enable io_uring tests" ${STDEXEC_FOUND_IO_URING})

option(STDEXEC_BUILD_EXAMPLES "Build stdexec examples" ON)
option(STDEXEC_BUILD_TESTS "Build stdexec tests" ON)
Expand Down
95 changes: 95 additions & 0 deletions cmake/Modules/Findnuma.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# Copyright (c) 2023 Maikel Nadolski
# Copyright (c) 2023 NVIDIA Corporation
#
# Licensed under the Apache License Version 2.0 with LLVM Exceptions
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://llvm.org/LICENSE.txt
#
# 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.
#

#[=======================================================================[.rst:
Findnuma
-------
Finds the numa library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``numa::numa``
The numa library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``numa_FOUND``
True if the system has the Foo library.
``numa_VERSION``
The version of the Foo library which was found.
``numa_INCLUDE_DIRS``
Include directories needed to use Foo.
``numa_LIBRARIES``
Libraries needed to link to Foo.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``numa_INCLUDE_DIR``
The directory containing ``numa.h``.
``numa_LIBRARY``
The path to the Foo library.
#]=======================================================================]

find_path(numa_INCLUDE_DIR
NAMES numa.h
PATHS ${PC_Foo_INCLUDE_DIRS}
PATH_SUFFIXES numa
)
find_library(numa_LIBRARY
NAMES numa
PATHS ${PC_Foo_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(numa
FOUND_VAR numa_FOUND
REQUIRED_VARS
numa_LIBRARY
numa_INCLUDE_DIR
VERSION_VAR numa_VERSION
)

if(numa_FOUND)
set(numa_LIBRARIES ${numa_LIBRARY})
set(numa_INCLUDE_DIRS ${numa_INCLUDE_DIR})
set(numa_DEFINITIONS ${PC_numa_CFLAGS_OTHER})
endif()

if(numa_FOUND AND NOT TARGET numa::numa)
add_library(numa::numa UNKNOWN IMPORTED)
set_target_properties(numa::numa PROPERTIES
IMPORTED_LOCATION "${numa_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_numa_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${numa_INCLUDE_DIR}"
)
endif()

mark_as_advanced(
numa_INCLUDE_DIR
numa_LIBRARY
)
28 changes: 28 additions & 0 deletions cmake/cpm/patches/icm/regex-build-error.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/icm_build_failure_parse_and_run.cmake b/icm_build_failure_parse_and_run.cmake
index 0e62f6c..2ea5f0a 100644
--- a/icm_build_failure_parse_and_run.cmake
+++ b/icm_build_failure_parse_and_run.cmake
@@ -29,14 +29,15 @@ endif()

# collect possible errors from source
file(READ "@parsedSourcePath@" sourceText)
+
string(REGEX MATCHALL "//[ ]*build error:[^\n]+" matchErrors ${sourceText})

# look for collected errors in output
foreach(possibleError ${matchErrors})
string(REGEX MATCH "//[ ]*build error:[ \t]*(.+)$" _ "${possibleError}")
set(possibleError "${CMAKE_MATCH_1}")
- string(FIND "${out}" "${possibleError}" pos)
- if(NOT pos EQUAL -1)
+ string(REGEX MATCH "${possibleError}" actualError "${out}")
+ if(NOT "${actualError}" STREQUAL "")
message("Success: output when building '@ARG_TARGET@' contains '${possibleError}'")
return()
endif()
@@ -48,4 +49,4 @@ endforeach()
# print execute_process output for debugging purposes
message("${out}")
# print error
-message(FATAL_ERROR "Error: Building '@ARG_TARGET@' failed, but output doesn't contain any of the expected errors:${outErrors}")
+message(FATAL_ERROR "Error: Building '@ARG_TARGET@' failed, but output doesn't match the expected errors:${outErrors}")
Loading

0 comments on commit 511a1b5

Please sign in to comment.