From 68d064e683afcd31e597dfe4effb180bf5a92b42 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 30 Oct 2023 12:51:41 -0700 Subject: [PATCH 01/12] #291: build benchmarks and compiler benchmarks in the CI --- .github/workflows/cmake.yml | 12 ++++++------ comp_bench/CMakeLists.txt | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c3c22b99..1d8da8ef 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -44,27 +44,27 @@ jobs: - name: Create Build Environment run: cmake -E make_directory ${{github.workspace}}/mdspan-build - + - name: Check Out uses: actions/checkout@v2 with: path: ${{github.workspace}}/mdspan-src - + - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/mdspan-build - run: CXX=${{ matrix.compiler_prefix}}/${{ matrix.compiler_driver }} cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install -DMDSPAN_ENABLE_TESTS=ON -DMDSPAN_ENABLE_EXAMPLES=ON -DCMAKE_CXX_FLAGS=${{matrix.cxx_flags_extra}} - + run: CXX=${{ matrix.compiler_prefix}}/${{ matrix.compiler_driver }} cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install -DMDSPAN_ENABLE_TESTS=ON -DMDSPAN_ENABLE_EXAMPLES=ON -DMDSPAN_ENABLE_BENCHMARKS=ON -DMDSPAN_ENABLE_COMP_BENCH=ON -DCMAKE_CXX_FLAGS=${{matrix.cxx_flags_extra}} + - name: Build shell: bash working-directory: ${{github.workspace}}/mdspan-build run: make -j - + - name: Test working-directory: ${{github.workspace}}/mdspan-build shell: bash run: ctest - + - name: Install shell: bash working-directory: ${{github.workspace}}/mdspan-build diff --git a/comp_bench/CMakeLists.txt b/comp_bench/CMakeLists.txt index 667b94f6..cfd27195 100644 --- a/comp_bench/CMakeLists.txt +++ b/comp_bench/CMakeLists.txt @@ -1,10 +1,23 @@ include(metabench) +# C++ standards that our benchmark will actually support +set(_cbench_supported_standards 17 20 23) + +# Obtain the subset that are actually supported by the compiler +set(_cbench_standards "") +foreach(_std IN LISTS _cbench_supported_standards) + if ("cxx_std_${_std}" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + list(APPEND _cbench_standards "${_std}") + endif() +endforeach() + +message(STATUS "Using the following C++ standards for compiler benchmarking: ${_cbench_standards}") + function(add_cxx_comparison name template range) set(all_datasets) - foreach(std IN ITEMS 11 14 17) + foreach(std IN LISTS _cbench_standards) metabench_add_dataset( ${name}_${std} ${template} From 3ed90cf4b1103549bbee8cc73c5714e09af098e6 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 30 Oct 2023 13:05:07 -0700 Subject: [PATCH 02/12] #291: make sure benchmark is installed --- .github/workflows/cmake.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 1d8da8ef..117aa12e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -40,7 +40,9 @@ jobs: curl --url ${{ matrix.compiler_url }} --output download.sh sudo sh -x download.sh -s -a -s --action install --eula accept - name: Install gtest manually - run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a + run: | + sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a + apt install libbenchmark1 libbenchmark-dev - name: Create Build Environment run: cmake -E make_directory ${{github.workspace}}/mdspan-build From 0b12c2933d8130cdcb6792d314cc63e9da66eaa3 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 30 Oct 2023 13:10:38 -0700 Subject: [PATCH 03/12] #291: only run CI on branches that are main or target main --- .github/workflows/cmake.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 117aa12e..9b934fd9 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,6 +1,12 @@ name: CMake -on: [push, pull_request] +on: + push: + branches: + - stable + pull_request: + branches: + - stable env: BUILD_TYPE: RelWithDebInfo From 9d7dbdaf284355a7700dbf524a5cddb0a202622f Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 30 Oct 2023 13:11:16 -0700 Subject: [PATCH 04/12] #291: use superuser to install libbenchmark --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9b934fd9..1e867a06 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -48,7 +48,7 @@ jobs: - name: Install gtest manually run: | sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp lib/*.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a - apt install libbenchmark1 libbenchmark-dev + sudo apt install libbenchmark1 libbenchmark-dev - name: Create Build Environment run: cmake -E make_directory ${{github.workspace}}/mdspan-build From 4148d28ad9d00acc21507e53320e075a8ef03af7 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 30 Oct 2023 16:03:56 -0700 Subject: [PATCH 05/12] #291: output ctest failure --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 1e867a06..96b454a0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -71,7 +71,7 @@ jobs: - name: Test working-directory: ${{github.workspace}}/mdspan-build shell: bash - run: ctest + run: ctest --output-on-failure - name: Install shell: bash From 4fabfd7d42c5c77bb4c7c89d06bfd43963432163 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Tue, 31 Oct 2023 11:49:20 -0700 Subject: [PATCH 06/12] #291: fix incorrect extents usage in compiler benchmark --- comp_bench/cbench_submdspan.cpp.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comp_bench/cbench_submdspan.cpp.erb b/comp_bench/cbench_submdspan.cpp.erb index 1f789dad..7c894b28 100644 --- a/comp_bench/cbench_submdspan.cpp.erb +++ b/comp_bench/cbench_submdspan.cpp.erb @@ -4,13 +4,13 @@ int test(int* data) { #if defined(METABENCH) auto sub0 = Kokkos::mdspan > >(data); <% (32/n).times do |k| %> auto <%= "sub0_#{k}" %> = Kokkos::mdspan > >(data); From f2507e5732615ccdcc1fac5dd8b7eb99219a9f98 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 2 Nov 2023 09:10:52 -0700 Subject: [PATCH 07/12] #291: remove the filter on push/pull_request and force C++17 build mode (will add more standard versions in a future PR) --- .github/workflows/cmake.yml | 10 ++-------- benchmarks/copy/copy_layout_stride.cpp | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 96b454a0..563bda5f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,12 +1,6 @@ name: CMake -on: - push: - branches: - - stable - pull_request: - branches: - - stable +on: [push, pull_request] env: BUILD_TYPE: RelWithDebInfo @@ -61,7 +55,7 @@ jobs: - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/mdspan-build - run: CXX=${{ matrix.compiler_prefix}}/${{ matrix.compiler_driver }} cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install -DMDSPAN_ENABLE_TESTS=ON -DMDSPAN_ENABLE_EXAMPLES=ON -DMDSPAN_ENABLE_BENCHMARKS=ON -DMDSPAN_ENABLE_COMP_BENCH=ON -DCMAKE_CXX_FLAGS=${{matrix.cxx_flags_extra}} + run: CXX=${{ matrix.compiler_prefix}}/${{ matrix.compiler_driver }} cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install -DMDSPAN_ENABLE_TESTS=ON -DMDSPAN_ENABLE_EXAMPLES=ON -DMDSPAN_ENABLE_BENCHMARKS=ON -DMDSPAN_ENABLE_COMP_BENCH=ON -DCMAKE_CXX_FLAGS=${{matrix.cxx_flags_extra}} - name: Build shell: bash diff --git a/benchmarks/copy/copy_layout_stride.cpp b/benchmarks/copy/copy_layout_stride.cpp index fe0e3c5a..6373979b 100644 --- a/benchmarks/copy/copy_layout_stride.cpp +++ b/benchmarks/copy/copy_layout_stride.cpp @@ -13,6 +13,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER +#define MDSPAN_USE_PAREN_OPERATOR #include #include From 48b98aeb9c7b21afb5fc3a1c15eaaa24d10b5fb3 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 2 Nov 2023 09:15:44 -0700 Subject: [PATCH 08/12] #291: fix errant macro definition --- benchmarks/copy/copy_layout_stride.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/copy/copy_layout_stride.cpp b/benchmarks/copy/copy_layout_stride.cpp index 6373979b..fe0e3c5a 100644 --- a/benchmarks/copy/copy_layout_stride.cpp +++ b/benchmarks/copy/copy_layout_stride.cpp @@ -13,7 +13,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER -#define MDSPAN_USE_PAREN_OPERATOR #include #include From 02abddab54d547b2eefe4edd6f0cb86d031024be Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 2 Nov 2023 09:41:47 -0700 Subject: [PATCH 09/12] #291: make sure parenthesis operator is enabled for benchmarks --- benchmarks/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 708cc9f3..3b1ee911 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -5,6 +5,8 @@ function(mdspan_add_benchmark EXENAME) target_include_directories(${EXENAME} PUBLIC $ ) + # Set flag to build with parenthesis enabled + target_compile_definitions(${EXENAME} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1) endfunction() find_package(benchmark REQUIRED) From 0983da472762bc59ba268b0412585b3c994756df Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 2 Nov 2023 09:47:42 -0700 Subject: [PATCH 10/12] #291: also enable parenthesis operator to cuda and openmp benchmarks --- benchmarks/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 3b1ee911..ce0b7453 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -44,6 +44,7 @@ function(mdspan_add_cuda_benchmark EXENAME) string(REPLACE "-pthread" "" _benchmark_libs "${_benchmark_libs_old}") target_include_directories(${EXENAME} PUBLIC "${_benchmark_include}") target_link_libraries(${EXENAME} PUBLIC "${_benchmark_libs};${_benchmark_libs_imported}") + target_compile_definitions(${EXENAME} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1) if(_benchmark_libs_old MATCHES "-pthread") target_compile_options(${EXENAME} PUBLIC "-Xcompiler=-pthread") endif() @@ -61,6 +62,7 @@ function(mdspan_add_openmp_benchmark EXENAME) target_include_directories(${EXENAME} PUBLIC $ ) + target_compile_definitions(${EXENAME} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1) else() message(WARNING "Not adding target ${EXENAME} because OpenMP was not found") endif() From 4c0b41e1aff2de4c91158d28c4eaa032a00adc01 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 2 Nov 2023 09:52:13 -0700 Subject: [PATCH 11/12] #291: also enable parenthesis for compiler benchmarks --- comp_bench/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/comp_bench/CMakeLists.txt b/comp_bench/CMakeLists.txt index cfd27195..c9c65a38 100644 --- a/comp_bench/CMakeLists.txt +++ b/comp_bench/CMakeLists.txt @@ -25,6 +25,7 @@ function(add_cxx_comparison name template range) MEDIAN_OF 3 ) target_link_libraries(${name}_${std} mdspan) + target_compile_definitions(${name}_${std} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1) set_property(TARGET ${name}_${std} PROPERTY CXX_STANDARD ${std}) set(all_datasets ${all_datasets} ${name}_${std}) endforeach() From 73efb07c3d00354e809cfacacfeb35e88025d6d0 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 2 Nov 2023 09:59:43 -0700 Subject: [PATCH 12/12] #291: fix CMAKE_CXX_STANDARD -> MDSPAN_CXX_STANDARD in CI workflow --- .github/workflows/cmake.yml | 2 +- comp_bench/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 563bda5f..8cd10d92 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -55,7 +55,7 @@ jobs: - name: Configure CMake shell: bash working-directory: ${{github.workspace}}/mdspan-build - run: CXX=${{ matrix.compiler_prefix}}/${{ matrix.compiler_driver }} cmake $GITHUB_WORKSPACE/mdspan-src -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install -DMDSPAN_ENABLE_TESTS=ON -DMDSPAN_ENABLE_EXAMPLES=ON -DMDSPAN_ENABLE_BENCHMARKS=ON -DMDSPAN_ENABLE_COMP_BENCH=ON -DCMAKE_CXX_FLAGS=${{matrix.cxx_flags_extra}} + run: CXX=${{ matrix.compiler_prefix}}/${{ matrix.compiler_driver }} cmake $GITHUB_WORKSPACE/mdspan-src -DMDSPAN_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/mdspan-install -DMDSPAN_ENABLE_TESTS=ON -DMDSPAN_ENABLE_EXAMPLES=ON -DMDSPAN_ENABLE_BENCHMARKS=ON -DMDSPAN_ENABLE_COMP_BENCH=ON -DCMAKE_CXX_FLAGS=${{matrix.cxx_flags_extra}} - name: Build shell: bash diff --git a/comp_bench/CMakeLists.txt b/comp_bench/CMakeLists.txt index c9c65a38..b58adf2a 100644 --- a/comp_bench/CMakeLists.txt +++ b/comp_bench/CMakeLists.txt @@ -25,6 +25,8 @@ function(add_cxx_comparison name template range) MEDIAN_OF 3 ) target_link_libraries(${name}_${std} mdspan) + # Set parenthesis operator regardless of which standard we are using + # so we don't have to ifdef target_compile_definitions(${name}_${std} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1) set_property(TARGET ${name}_${std} PROPERTY CXX_STANDARD ${std}) set(all_datasets ${all_datasets} ${name}_${std})