Skip to content

Commit

Permalink
Support C++23 & test with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
jbigot committed Jun 21, 2023
1 parent 21142f7 commit e345df1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 41 deletions.
69 changes: 36 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
name: test
on:
push:
branches: [ main ]
push: { branches: [ main ] }
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.13
with:
source: 'include/ddc/ tests/ examples/'
exclude: ''
extensions: 'hpp,cpp'
clangFormatVersion: 12

id_repo:
runs-on: ubuntu-latest
outputs:
in_base_repo: ${{ steps.identify_repo.outputs.in_base_repo }}
outputs: { in_base_repo: '${{ steps.identify_repo.outputs.in_base_repo }}' }
steps:
- name: Identify repository
id: identify_repo
Expand All @@ -17,15 +26,13 @@ jobs:
docker-build-env:
strategy:
fail-fast: false
matrix:
image: ['test_env', 'jammy_env']
matrix: { image: ['test_env', 'jammy_env'] }
needs: id_repo
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.2.0
with: { tool-cache: true, large-packages: false}
with: { tool-cache: true, large-packages: false }
- name: Checkout built branch
uses: actions/checkout@v3
- name: Build
Expand Down Expand Up @@ -57,42 +64,31 @@ jobs:
path: ${{matrix.image}}.tar
retention-days: 1

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.13
with:
source: 'include/ddc/ tests/ examples/'
exclude: ''
extensions: 'hpp,cpp'
clangFormatVersion: 12

test-build-and-run:
strategy:
fail-fast: false
matrix:
cxx_version: ['17', '20', '23']
cmake_build_type: ['Debug', 'Release']
kokkos_backend: ['CPU', 'HIP', 'CUDA']
kokkos_backend: ['CPU-gnu', 'CPU-clang', 'GPU-HIP', 'GPU-Cuda']
image: ['test_env', 'jammy_env']
exclude:
- cxx_version: '23'
image: 'test_env'
- kokkos_backend: 'CUDA'
- kokkos_backend: 'GPU-Cuda'
image: 'test_env'
- kokkos_backend: 'CUDA'
- kokkos_backend: 'GPU-Cuda'
image: 'jammy_env'
cxx_version: '20'
- kokkos_backend: 'CUDA'
- kokkos_backend: 'GPU-Cuda'
image: 'jammy_env'
cxx_version: '23'
runs-on: ubuntu-latest
needs: [docker-build-env, id_repo]
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.2.0
with: { tool-cache: true, large-packages: false}
with: { tool-cache: true, large-packages: false }
- name: Checkout built branch
uses: actions/checkout@v3
with: { submodules: recursive }
Expand All @@ -110,39 +106,46 @@ jobs:
cat<<-'EOF' > run.sh
set -xe
git config --global --add safe.directory '*'
CMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror=vla"
case "${{matrix.kokkos_backend}}" in
'CUDA')
'GPU-Cuda')
export CC=gcc-10
export CXX=g++-10
export FC=gfortran-10
EXTRA_CMAKE_FLAGS="-DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON -DKokkos_ENABLE_LIBDL=OFF"
;;
'HIP')
'GPU-HIP')
export CC=/opt/rocm/hip/bin/hipcc
export CXX=/opt/rocm/hip/bin/hipcc
EXTRA_CMAKE_FLAGS="-DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON -DCMAKE_PREFIX_PATH=/opt/rocm"
;;
*)
'CPU-clang')
export CC=clang
export CXX=clang++
CMAKE_CXX_FLAGS="-Wno-gnu-zero-variadic-macro-arguments"
;;
'CPU-gnu')
if [ 'Debug' = '${{matrix.cmake_build_type}}' ]
then
CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address"
CMAKE_CXX_FLAGS="-fno-omit-frame-pointer -fsanitize=address"
fi
;;
esac
cmake \
-DBUILD_BENCHMARKS=ON \
-DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
-DMDSPAN_CXX_STANDARD=${{matrix.cxx_version}} \
-DKokkos_ENABLE_DEPRECATED_CODE_3=OFF \
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror=vla ${CMAKE_CXX_FLAGS}" \
${EXTRA_CMAKE_FLAGS} \
/src
make -j 2 VERBOSE=1
if [ 'xCPU' = "x${{matrix.kokkos_backend}}" ]
then ctest -j 2 --output-on-failure --timeout 5 --output-junit tests.xml
fi
case "${{matrix.kokkos_backend}}" in
CPU-*)
ctest -j 2 --output-on-failure --timeout 5 --output-junit tests.xml
;;
esac
EOF
docker run -v ${PWD}:/src:ro ghcr.io/maison-de-la-simulation/ddc/${{matrix.image}}:${GITHUB_SHA:0:7} bash /src/run.sh
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ target_include_directories(DDC
)
target_link_libraries(DDC
INTERFACE std::mdspan Kokkos::kokkos)
target_compile_definitions(DDC INTERFACE MDSPAN_USE_PAREN_OPERATOR=1)
add_library(DDC::DDC ALIAS DDC)
install(
TARGETS DDC
Expand Down
1 change: 1 addition & 0 deletions docker/jammy_env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN chmod +x /bin/bash_run \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
clang \
clang-format \
cmake \
gcc-10 \
Expand Down
1 change: 1 addition & 0 deletions docker/test_env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN chmod +x /bin/bash_run \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
clang \
clang-format \
cmake \
pkg-config \
Expand Down
14 changes: 6 additions & 8 deletions include/ddc/chunk_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ class ChunkSpan<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy, Memo
: public ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
{
protected:
/// the raw mdspan underlying this, with the same indexing (0 might no be dereferenceable)
using internal_mdspan_type = std::experimental::mdspan<
ElementType,
std::experimental::dextents<sizeof...(DDims)>,
std::experimental::layout_stride>;

using base_type = ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>;

/// the raw mdspan underlying this, with the same indexing (0 might no be dereferenceable)
using typename base_type::internal_mdspan_type;

public:
/// type of a span of this full chunk
using span_type
Expand All @@ -63,8 +60,9 @@ class ChunkSpan<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy, Memo
using memory_space = MemorySpace;

/// The dereferenceable part of the co-domain but with a different domain, starting at 0
using allocation_mdspan_type = std::experimental::
mdspan<ElementType, std::experimental::dextents<sizeof...(DDims)>, LayoutStridedPolicy>;
using allocation_mdspan_type = typename base_type::allocation_mdspan_type;

using const_allocation_mdspan_type = typename base_type::const_allocation_mdspan_type;

using discrete_element_type = typename mdomain_type::discrete_element_type;

Expand Down

0 comments on commit e345df1

Please sign in to comment.