From 2262c31dbd4ab6bc1400a80ba42333b82876ad9b Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Tue, 9 Apr 2024 11:50:17 -0400 Subject: [PATCH] Remove mdspan support --- .github/workflows/linux-mdspan.yaml | 42 ---------- .github/workflows/osx-mdspan.yaml | 42 ---------- CMakeLists.txt | 29 +------ cmake/flags.cmake | 20 +---- docs/api/core.rst | 11 ++- docs/api/traits.rst | 6 +- docs/design.rst | 4 - docs/usage/getting_started.rst | 20 ----- src/CMakeLists.txt | 5 +- src/KokkosComm.hpp | 6 +- src/KokkosComm_collective.hpp | 2 +- src/KokkosComm_pack_traits.hpp | 16 ---- src/KokkosComm_traits.hpp | 119 ---------------------------- src/impl/KokkosComm_concepts.hpp | 13 --- src/impl/KokkosComm_isend.hpp | 4 +- src/impl/KokkosComm_mdspan.hpp | 60 -------------- src/impl/KokkosComm_packer.hpp | 4 +- src/impl/KokkosComm_recv.hpp | 7 +- src/impl/KokkosComm_reduce.hpp | 6 +- src/impl/KokkosComm_send.hpp | 4 +- unit_tests/test_isendrecv.cpp | 83 ------------------- 21 files changed, 27 insertions(+), 476 deletions(-) delete mode 100644 .github/workflows/linux-mdspan.yaml delete mode 100644 .github/workflows/osx-mdspan.yaml delete mode 100644 src/impl/KokkosComm_mdspan.hpp diff --git a/.github/workflows/linux-mdspan.yaml b/.github/workflows/linux-mdspan.yaml deleted file mode 100644 index 5e793726..00000000 --- a/.github/workflows/linux-mdspan.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Linux (mdspan) -run-name: Linux (mdspan) -on: - pull_request: - paths-ignore: - - README.md - - 'docs/**' - types: [ opened, reopened, synchronize ] - -jobs: - Kokkos-040200-OpenMPI-OpenMP-kokkosmdspan-Release: - env: - KOKKOS_SRC: ${{ github.workspace }}/_deps/kokkos - KOKKOS_BUILD: ${{ github.workspace }}/_deps/kokkos-build - KOKKOS_INSTALL: ${{ github.workspace }}/_deps/kokkos-install - COMM_SRC: ${{ github.workspace }} - COMM_BUILD: ${{ github.workspace }}/build - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Install MPI - run: | - sudo apt-get update && sudo apt-get install -y libopenmpi-dev openmpi-bin cmake - which mpirun - mpirun --version - which mpicxx - mpicxx --version - - name: Check out repository code - uses: actions/checkout@v4 - - name: Build Kokkos - run: | - git clone https://github.com/kokkos/kokkos.git "$KOKKOS_SRC" - cd "$KOKKOS_SRC" && git checkout 4.2.00 - cmake -S "$KOKKOS_SRC" -B "$KOKKOS_BUILD" -DCMAKE_INSTALL_PREFIX="$KOKKOS_INSTALL" -DCMAKE_BUILD_TYPE=Release -DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_OPENMP=ON -DKokkos_ARCH_NATIVE=ON - cmake --build "$KOKKOS_BUILD" --parallel $(nproc) -t install - - name: Build KokkosComm - run: | - cmake -S "$COMM_SRC" -B "$COMM_BUILD" -DKokkos_DIR="$KOKKOS_INSTALL/lib/cmake/Kokkos" -DCMAKE_BUILD_TYPE=Release -DKokkosComm_ENABLE_MDSPAN=ON -DKokkosComm_USE_KOKKOS_MDSPAN=ON - VERBOSE=1 cmake --build "$COMM_BUILD" - - name: Test KokkosComm - run: | - ctest -V --test-dir "$COMM_BUILD" diff --git a/.github/workflows/osx-mdspan.yaml b/.github/workflows/osx-mdspan.yaml deleted file mode 100644 index 400051cc..00000000 --- a/.github/workflows/osx-mdspan.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: macOS (mdspan) -run-name: macOS (mdspan) -on: - pull_request: - paths-ignore: - - README.md - - 'docs/**' - types: [ opened, reopened, synchronize ] - -jobs: - Kokkos-040200-MPICH-Threads-kokkosmdspan-Release: - env: - KOKKOS_SRC: ${{ github.workspace }}/_deps/kokkos - KOKKOS_BUILD: ${{ github.workspace }}/_deps/kokkos-build - KOKKOS_INSTALL: ${{ github.workspace }}/_deps/kokkos-install - COMM_SRC: ${{ github.workspace }} - COMM_BUILD: ${{ github.workspace }}/build - runs-on: macos-latest - timeout-minutes: 5 - steps: - - name: Install MPI - run: | - brew install mpich cmake - which mpirun - mpirun --version - which mpicxx - mpicxx --version - - name: Check out repository code - uses: actions/checkout@v4 - - name: Build Kokkos - run: | - git clone https://github.com/kokkos/kokkos.git "$KOKKOS_SRC" - cd "$KOKKOS_SRC" && git checkout 4.2.00 - cmake -S "$KOKKOS_SRC" -B "$KOKKOS_BUILD" -DCMAKE_INSTALL_PREFIX="$KOKKOS_INSTALL" -DCMAKE_BUILD_TYPE=Release -DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_THREADS=ON -DKokkos_ARCH_NATIVE=ON - cmake --build "$KOKKOS_BUILD" --parallel $(nproc) -t install - - name: Build KokkosComm - run: | - cmake -S "$COMM_SRC" -B "$COMM_BUILD" -DKokkos_DIR="$KOKKOS_INSTALL/lib/cmake/Kokkos" -DCMAKE_BUILD_TYPE=Release -DKokkosComm_ENABLE_MDSPAN=ON -DKokkosComm_USE_KOKKOS_MDSPAN=ON - VERBOSE=1 cmake --build "$COMM_BUILD" - - name: Test KokkosComm - run: | - ctest -V --test-dir "$COMM_BUILD" diff --git a/CMakeLists.txt b/CMakeLists.txt index 27abad89..74804c19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,18 +6,11 @@ project(KokkosComm VERSION 0.0.2) option(KokkosComm_ENABLE_PERFTESTS "Build KokkosComm perf tests" ON) option(KokkosComm_ENABLE_TESTS "Build KokkosComm perf tests" ON) -option(KokkosComm_ENABLE_MDSPAN "Build mdspan overloads" OFF) -option(KokkosComm_MDSPAN_IMPL "mdspan implementation to use [std, kokkos]" "kokkos") -option(KokkosComm_USE_STD_MDSPAN "Use std::mdspan (requires c++23)" OFF) -option(KokkosComm_USE_KOKKOS_MDSPAN "Use Kokkos mdspan implementation" OFF) ## resolve options set(KOKKOSCOMM_ENABLE_PERFTESTS ${KokkosComm_ENABLE_PERFTESTS} CACHE BOOL "" FORCE) set(KOKKOSCOMM_ENABLE_TESTS ${KokkosComm_ENABLE_TESTS} CACHE BOOL "" FORCE) -set(KOKKOSCOMM_ENABLE_MDSPAN ${KokkosComm_ENABLE_MDSPAN} CACHE BOOL "" FORCE) -set(KOKKOSCOMM_USE_KOKKOS_MDSPAN ${KokkosComm_USE_KOKKOS_MDSPAN} CACHE BOOL "" FORCE) -set(KOKKOSCOMM_USE_STD_MDSPAN ${KokkosComm_USE_STD_MDSPAN} CACHE BOOL "" FORCE) find_package(Kokkos REQUIRED) find_package(MPI REQUIRED) @@ -29,26 +22,6 @@ message(STATUS "Kokkos MPI: MPI_CXX_COMPILE_DEFINITIONS = ${MPI_CXX_COMPILE_DEFI message(STATUS "Kokkos MPI: MPI_CXX_INCLUDE_DIRS = ${MPI_CXX_INCLUDE_DIRS}") message(STATUS "Kokkos MPI: MPI_CXX_LINK_FLAGS = ${MPI_CXX_LINK_FLAGS}") message(STATUS "Kokkos MPI: MPI_CXX_LIBRARIES = ${MPI_CXX_LIBRARIES}") -if (KOKKOSCOMM_ENABLE_MDSPAN) - if (KOKKOSCOMM_USE_STD_MDSPAN) - message(STATUS "Kokkos MPI: mdspan support enabled (std::mdspan)") - elseif(KOKKOSCOMM_USE_KOKKOS_MDSPAN) - message(STATUS "Kokkos MPI: mdspan support enabled (kokkos/mdspan)") - else() - message(FATAL_ERROR "Kokkos MPI: mdspan support enabled but no MDSPAN implementation enabled!") - endif() -endif() - -include(FetchContent) -if(KOKKOSCOMM_ENABLE_MDSPAN AND KOKKOSCOMM_USE_KOKKOS_MDSPAN) - message(STATUS "retrieving kokkos/mdspan...") - FetchContent_Declare( - kokkos_mdspan - GIT_REPOSITORY https://github.com/kokkos/mdspan.git - GIT_TAG 9ceface91483775a6c74d06ebf717bbb2768452f # mdspan-0.6.0 - ) - FetchContent_MakeAvailable(kokkos_mdspan) -endif() include(cmake/flags.cmake) @@ -126,4 +99,4 @@ endif() if(KOKKOSCOMM_ENABLE_PERFTESTS) enable_testing() add_subdirectory(perf_tests) -endif() \ No newline at end of file +endif() diff --git a/cmake/flags.cmake b/cmake/flags.cmake index f8f1473b..7badcf83 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -59,24 +59,8 @@ function(kokkoscomm_add_cxx_flags) target_compile_options(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_OPTIONS_KEYWORD} $) endif() - # mdspan-related definitions - if (KOKKOSCOMM_ENABLE_MDSPAN) - target_compile_definitions(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_OPTIONS_KEYWORD} KOKKOSCOMM_ENABLE_MDSPAN) - if(KOKKOSCOMM_USE_STD_MDSPAN) - target_compile_definitions(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_OPTIONS_KEYWORD} KOKKOSCOMM_USE_STD_MDSPAN) - elseif(KOKKOSCOMM_USE_KOKKOS_MDSPAN) - target_compile_definitions(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_OPTIONS_KEYWORD} KOKKOSCOMM_USE_KOKKOS_MDSPAN) - target_compile_definitions(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_OPTIONS_KEYWORD} KOKKOSCOMM_MDSPAN_IN_EXPERIMENTAL) - endif() - endif() - # choose cxx standard set_target_properties(${ADD_CXX_FLAGS_TARGET} PROPERTIES CXX_EXTENSIONS OFF) - if (KOKKOSCOMM_ENABLE_MDSPAN AND KOKKOSCOMM_USE_STD_MDSPAN) - target_compile_features(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_FEATURES_KEYWORD} cxx_std_23) - else() - target_compile_features(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_FEATURES_KEYWORD} cxx_std_20) - endif() - + target_compile_features(${ADD_CXX_FLAGS_TARGET} ${TARGET_COMPILE_FEATURES_KEYWORD} cxx_std_20) -endfunction() \ No newline at end of file +endfunction() diff --git a/docs/api/core.rst b/docs/api/core.rst index a7172f5a..cc67b8f0 100644 --- a/docs/api/core.rst +++ b/docs/api/core.rst @@ -8,7 +8,6 @@ Core * - MPI - ``KokkosComm::`` - ``Kokkos::View`` - - mdspan * - MPI_Send - send - ✓ @@ -29,7 +28,7 @@ Core Point-to-point -------------- -.. cpp:function:: template \ +.. cpp:function:: template \ Req KokkosComm::isend(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) MPI_Isend wrapper @@ -43,7 +42,7 @@ Point-to-point :tparam ExecSpace: A Kokkos execution space to operate in :returns: A KokkosComm::Req representing the asynchronous communication and any lifetime-extended views. -.. cpp:function:: template \ +.. cpp:function:: template \ void KokkosComm::send(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) MPI_Send wrapper @@ -56,7 +55,7 @@ Point-to-point :tparam SendView: A Kokkos::View to send :tparam ExecSpace: A Kokkos execution space to operate in -.. cpp:function:: template \ +.. cpp:function:: template \ void KokkosComm::recv(const ExecSpace &space, RecvView &rv, int src, int tag, MPI_Comm comm) MPI_Recv wrapper @@ -73,7 +72,7 @@ Point-to-point Collective ---------- -.. cpp:function:: template \ +.. cpp:function:: template \ void KokkosComm::reduce(const ExecSpace &space, const SendView &sv, const RecvView &rv, MPI_Op op, int root, MPI_Comm comm) MPI_Reduce wrapper @@ -107,4 +106,4 @@ Related Types void KokkosComm::Req::keep_until_wait(const View &v) Extend the lifetime of v at least until Req::wait() is called. - This is useful to prevent a View from being destroyed during an asynchronous MPI operation. \ No newline at end of file + This is useful to prevent a View from being destroyed during an asynchronous MPI operation. diff --git a/docs/api/traits.rst b/docs/api/traits.rst index e92a5a59..5c299447 100644 --- a/docs/api/traits.rst +++ b/docs/api/traits.rst @@ -7,7 +7,7 @@ Basic Traits .. cpp:type:: template \ KokkosComm::Traits - A common interface to access Kokkos::View- and std::mdspan-like types. + A common interface to access Kokkos::View-like types. .. cpp:function:: static bool is_contiguous(const View &v) @@ -41,7 +41,7 @@ Strategies for handling non-contiguous views .. cpp:type:: template \ KokkosComm::PackTraits - A common packing-related interface for Kokkos::View- and std::mdspan-like types. + A common packing-related interface for Kokkos::View-like types. .. cpp:type:: packer_type @@ -53,4 +53,4 @@ Strategies for handling non-contiguous views .. cpp:function:: static bool needs_pack(const View &v) - :returns: true iff ``View`` ``v`` needs to be unpacked after being passed from MPI \ No newline at end of file + :returns: true iff ``View`` ``v`` needs to be unpacked after being passed from MPI diff --git a/docs/design.rst b/docs/design.rst index 30ea2a83..aa169280 100644 --- a/docs/design.rst +++ b/docs/design.rst @@ -9,7 +9,6 @@ Asynchronous MPI operations and view lifetimes Non-contiguous Data ------------------- -- Packer::MpiDatatype which just constructs an MPI Datatype matching the mdspan and hands it off to MPI to deal with the non-contiguous data - Packer::DeepCopy uses `Kokkos::deep_copy` to handle packing and unpacking of non-contiguous `Kokkos::View`. This requires an intermediate allocation, which only works for Kokkos Views, see `Device Data`_. Device Data @@ -18,6 +17,3 @@ Device Data Contiguous device data is handed to MPI as-is. For non-contiguous Kokkos::Views in a non-``Kokkos::HostSpace``, any temporary buffers are allocated in the same memory space as the view being operated on. - -For non-contiguous mdspan, there is no standards-compliant way to get an allocator that can produce the same kind of allocation as the mdspan. -In that case, the Packer::MpiDatatype packer needs to be used, where a datatype is created to describe the mdspan (without accessing any of the mdspan's data!) and then that is handed off to the MPI implementation. \ No newline at end of file diff --git a/docs/usage/getting_started.rst b/docs/usage/getting_started.rst index f99d257e..39438090 100644 --- a/docs/usage/getting_started.rst +++ b/docs/usage/getting_started.rst @@ -16,29 +16,9 @@ A basic build: ctest -V --test-dir /path/to/build/directory -A build with ``mdspan`` support through kokkos/mdspan. -You need to turn on ONE of ``KokkosComm_USE_STD_MDSPAN`` or ``KokkosComm_USE_KOKKOS_MDSPAN``. -As of March 2024, only Clang 18 has full ``std::mdspan`` support, so you will probably want ``KokkosComm_USE_KOKKOS_MDSPAN``. - -.. code-block:: bash - - cmake -S /path/to/kokkos-comm \ - -B /path/to/build/directory \ - -DKokkos_ROOT=/path/to/kokkos-install/ \ - -DKokkosComm_ENABLE_MDSPAN=ON \ - -DKokkosComm_USE_KOKKOS_MDSPAN=ON - - Configuration Options --------------------- -* ``KokkosComm_ENABLE_MDSPAN``: (default=OFF) build with mdspan support - * Causes ``KOKKOSCOMM_ENABLE_MDSPAN`` to be defined in source files -* ``KokkosComm_USE_STD_MDSPAN``: (default=OFF) use std::mdspan as the mdspan implementation (if KokkosComm_ENABLE_MDSPAN) - * Causes ``KOKKOSCOMM_USE_STD_MDSPAN`` to be defined in source files -* ``KokkosComm_USE_KOKKOS_MDSPAN``: (default=OFF) retrieve and use kokkos/mdspan as the mdspan implementation (if KokkosComm_ENABLE_MDSPAN) - * Causes ``KOKKOSCOMM_USE_KOKKOS_MDSPAN`` to be defined in source files - * Causes ``KOKKOSCOMM_MDSPAN_IN_EXPERIMENTAL`` to be defined in source files * ``KokkosComm_ENABLE_PERFTESTS``: (default=ON) build performance tests * ``KokkosComm_ENABLE_TESTS``: (default=ON) build unit tests diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31874e9f..ea088ba1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,9 +11,6 @@ target_include_directories(KokkosComm INTERFACE $ ) target_link_libraries(KokkosComm INTERFACE MPI::MPI_CXX Kokkos::kokkos) -if(KOKKOSCOMM_USE_KOKKOS_MDSPAN) - target_link_libraries(KokkosComm INTERFACE mdspan) -endif() file(GLOB_RECURSE KOKKOSCOMM_PUBLIC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/*.hpp) -set(KOKKOSCOMM_PUBLIC_HEADERS ${KOKKOSCOMM_PUBLIC_HEADERS} PARENT_SCOPE) \ No newline at end of file +set(KOKKOSCOMM_PUBLIC_HEADERS ${KOKKOSCOMM_PUBLIC_HEADERS} PARENT_SCOPE) diff --git a/src/KokkosComm.hpp b/src/KokkosComm.hpp index 15f7f2e7..70c87a29 100644 --- a/src/KokkosComm.hpp +++ b/src/KokkosComm.hpp @@ -27,19 +27,19 @@ namespace KokkosComm { -template +template Req isend(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) { return Impl::isend(space, sv, dest, tag, comm); } -template +template void send(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) { return Impl::send(space, sv, dest, tag, comm); } -template +template void recv(const ExecSpace &space, RecvView &sv, int src, int tag, MPI_Comm comm) { return Impl::recv(space, sv, src, tag, comm); diff --git a/src/KokkosComm_collective.hpp b/src/KokkosComm_collective.hpp index 52dd5f1d..582a604f 100644 --- a/src/KokkosComm_collective.hpp +++ b/src/KokkosComm_collective.hpp @@ -23,7 +23,7 @@ namespace KokkosComm { -template void reduce(const ExecSpace &space, const SendView &sv, const RecvView &rv, MPI_Op op, int root, MPI_Comm comm) { diff --git a/src/KokkosComm_pack_traits.hpp b/src/KokkosComm_pack_traits.hpp index 177e561e..a1ed8612 100644 --- a/src/KokkosComm_pack_traits.hpp +++ b/src/KokkosComm_pack_traits.hpp @@ -19,7 +19,6 @@ #include "KokkosComm_traits.hpp" #include "KokkosComm_concepts.hpp" -#include "KokkosComm_mdspan.hpp" #include "KokkosComm_packer.hpp" /*! \brief Defines a common interface for packing and unpacking @@ -47,19 +46,4 @@ struct PackTraits { } }; -#if KOKKOSCOMM_ENABLE_MDSPAN - -template -struct PackTraits { - using packer_type = Impl::Packer::MpiDatatype; - - static bool needs_unpack(const Span &v) { - return !Traits::is_contiguous(v); - } - static bool needs_pack(const Span &v) { - return !Traits::is_contiguous(v); - } -}; - -#endif // KOKKOSCOMM_ENABLE_MDSPAN } // namespace KokkosComm diff --git a/src/KokkosComm_traits.hpp b/src/KokkosComm_traits.hpp index 565ff631..96d232d6 100644 --- a/src/KokkosComm_traits.hpp +++ b/src/KokkosComm_traits.hpp @@ -20,8 +20,6 @@ #pragma once -#include "KokkosComm_mdspan.hpp" - #include "KokkosComm_concepts.hpp" namespace KokkosComm { @@ -67,122 +65,5 @@ struct Traits { static constexpr size_t rank() { return View::rank; } }; -#if KOKKOSCOMM_ENABLE_MDSPAN - -template -struct Traits { - static auto data_handle(const Span &v) { return v.data_handle(); } - - using non_const_packed_view_type = std::vector; - using packed_view_type = std::vector; - - static auto data_handle(non_const_packed_view_type &v) { return v.data(); } - - static constexpr size_t rank() { return Span::extents_type::rank(); } - - static size_t extent(const Span &v, const int i) { - return v.extents().extent(i); - } - static size_t stride(const Span &v, const int i) { return v.stride(i); } - - static size_t span(const packed_view_type &packed) { return packed.size(); } - static size_t span(const Span &v) { - std::array first, last; - for (size_t i = 0; i < rank(); ++i) { - first[i] = 0; - last[i] = v.extents().extent(i) - 1; - } - return &v[last] - &v[first] + sizeof(typename Span::value_type); - } - - static bool is_contiguous(const Span &v) { - size_t prod = 1; - for (size_t i = 0; i < rank(); ++i) { - prod *= v.extents().extent(i); - } - return prod == span(v); - } - - template - static void pack(const ExecSpace &space, non_const_packed_view_type &dst, - const Span &src) { - using md_index = std::array; - - md_index index, ext; - index = {0}; - for (size_t i = 0; i < rank(); ++i) { - ext[i] = src.extents().extent(i); - } - size_t offset = 0; - - auto index_lt = [](const md_index &a, const md_index &b) -> bool { - for (size_t i = 0; i < rank(); ++i) { - if (!(a[i] < b[i])) { - return false; - } - } - return true; - }; - - auto increment = [&]() -> void { - for (size_t i = 0; i < rank(); ++i) { - ++index[i]; - if (index[i] >= ext[i] && i != rank() - 1 /* don't wrap final index*/) { - index[i] = 0; - } else { - break; - } - } - - ++offset; - }; - - for (; index_lt(index, ext); increment()) { - dst[offset] = src[index]; - } - } - - template - static void unpack(const ExecSpace &space, Span &dst, - const non_const_packed_view_type &src) { - using md_index = std::array; - - md_index index, ext; - index = {0}; - for (size_t i = 0; i < rank(); ++i) { - ext[i] = dst.extents().extent(i); - } - size_t offset = 0; - - auto index_lt = [](const md_index &a, const md_index &b) -> bool { - for (size_t i = 0; i < rank(); ++i) { - if (!(a[i] < b[i])) { - return false; - } - } - return true; - }; - - auto increment = [&]() -> void { - for (size_t i = 0; i < rank(); ++i) { - ++index[i]; - if (index[i] >= ext[i] && i != rank() - 1 /* don't wrap final index*/) { - index[i] = 0; - } else { - break; - } - } - - ++offset; - }; - - for (; index_lt(index, ext); increment()) { - dst[index] = src[offset]; - } - } - - static constexpr bool is_reference_counted() { return true; } -}; -#endif // KOKKOSCOMM_ENABLE_MDSPAN } // namespace KokkosComm diff --git a/src/impl/KokkosComm_concepts.hpp b/src/impl/KokkosComm_concepts.hpp index 5db5a595..1eb36996 100644 --- a/src/impl/KokkosComm_concepts.hpp +++ b/src/impl/KokkosComm_concepts.hpp @@ -18,8 +18,6 @@ #include -#include "KokkosComm_mdspan.hpp" - namespace KokkosComm { template @@ -28,15 +26,4 @@ concept KokkosView = Kokkos::is_view_v; template concept KokkosExecutionSpace = Kokkos::is_execution_space_v; -#if KOKKOSCOMM_ENABLE_MDSPAN -template -concept Mdspan = is_mdspan_v; - -template -concept ViewOrMdspan = KokkosView || Mdspan; -#else -template -concept ViewOrMdspan = KokkosView; -#endif - } // namespace KokkosComm diff --git a/src/impl/KokkosComm_isend.hpp b/src/impl/KokkosComm_isend.hpp index 90538cdd..33164003 100644 --- a/src/impl/KokkosComm_isend.hpp +++ b/src/impl/KokkosComm_isend.hpp @@ -30,7 +30,7 @@ namespace KokkosComm::Impl { -template +template KokkosComm::Req isend(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) { Kokkos::Tools::pushRegion("KokkosComm::Impl::isend"); @@ -63,4 +63,4 @@ KokkosComm::Req isend(const ExecSpace &space, const SendView &sv, int dest, return req; } -} // namespace KokkosComm::Impl \ No newline at end of file +} // namespace KokkosComm::Impl diff --git a/src/impl/KokkosComm_mdspan.hpp b/src/impl/KokkosComm_mdspan.hpp deleted file mode 100644 index 8a05fc30..00000000 --- a/src/impl/KokkosComm_mdspan.hpp +++ /dev/null @@ -1,60 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#pragma once - -#if KOKKOSCOMM_ENABLE_MDSPAN -#if KOKKOSCOMM_MDSPAN_IN_EXPERIMENTAL -#include -namespace KokkosComm::Impl { -template -using mdspan = std::experimental::mdspan; - -template -using extents = std::experimental::extents; - -template -using dextents = std::experimental::dextents; -} // namespace KokkosComm::Impl -#else -#include -namespace KokkosComm::Impl { -template -using mdspan = std::mdspan; - -template -using extents = std::extents; - -template -using dextents = std::dextents; -} // namespace KokkosComm::Impl -#endif - -template -struct is_mdspan : std::false_type {}; - -template -struct is_mdspan> : std::true_type {}; - -template -constexpr bool is_mdspan_v = is_mdspan::value; - -static_assert(is_mdspan_v>>, - ""); -static_assert(!is_mdspan_v>, ""); - -#endif // KOKKOSCOMM_ENABLE_MDSPAN \ No newline at end of file diff --git a/src/impl/KokkosComm_packer.hpp b/src/impl/KokkosComm_packer.hpp index 0f43ff0f..a9693497 100644 --- a/src/impl/KokkosComm_packer.hpp +++ b/src/impl/KokkosComm_packer.hpp @@ -23,7 +23,7 @@ namespace KokkosComm::Impl { namespace Packer { -template +template struct MpiArgs { View view; MPI_Datatype datatype; @@ -82,7 +82,7 @@ struct DeepCopy { } }; -template +template struct MpiDatatype { using non_const_packed_view_type = View; using args_type = MpiArgs; diff --git a/src/impl/KokkosComm_recv.hpp b/src/impl/KokkosComm_recv.hpp index 84606486..867009a4 100644 --- a/src/impl/KokkosComm_recv.hpp +++ b/src/impl/KokkosComm_recv.hpp @@ -25,11 +25,8 @@ // impl #include "KokkosComm_include_mpi.hpp" -/* FIXME: If RecvView is a Kokkos view, it can be a const ref - same is true for an mdspan? -*/ namespace KokkosComm::Impl { -template +template void recv(const ExecSpace &space, RecvView &rv, int src, int tag, MPI_Comm comm) { Kokkos::Tools::pushRegion("KokkosComm::Impl::recv"); @@ -54,4 +51,4 @@ void recv(const ExecSpace &space, RecvView &rv, int src, int tag, Kokkos::Tools::popRegion(); } -} // namespace KokkosComm::Impl \ No newline at end of file +} // namespace KokkosComm::Impl diff --git a/src/impl/KokkosComm_reduce.hpp b/src/impl/KokkosComm_reduce.hpp index 76a296d2..fe0fa2bb 100644 --- a/src/impl/KokkosComm_reduce.hpp +++ b/src/impl/KokkosComm_reduce.hpp @@ -26,8 +26,8 @@ #include "KokkosComm_types.hpp" namespace KokkosComm::Impl { -template +template void reduce(const ExecSpace &space, const SendView &sv, const RecvView &rv, MPI_Op op, int root, MPI_Comm comm) { Kokkos::Tools::pushRegion("KokkosComm::Impl::reduce"); @@ -72,4 +72,4 @@ void reduce(const ExecSpace &space, const SendView &sv, const RecvView &rv, Kokkos::Tools::popRegion(); } -} // namespace KokkosComm::Impl \ No newline at end of file +} // namespace KokkosComm::Impl diff --git a/src/impl/KokkosComm_send.hpp b/src/impl/KokkosComm_send.hpp index 76c781fa..0015f71a 100644 --- a/src/impl/KokkosComm_send.hpp +++ b/src/impl/KokkosComm_send.hpp @@ -24,7 +24,7 @@ #include "KokkosComm_include_mpi.hpp" namespace KokkosComm::Impl { -template +template void send(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Comm comm) { Kokkos::Tools::pushRegion("KokkosComm::Impl::send"); @@ -42,4 +42,4 @@ void send(const ExecSpace &space, const SendView &sv, int dest, int tag, Kokkos::Tools::popRegion(); } -} // namespace KokkosComm::Impl \ No newline at end of file +} // namespace KokkosComm::Impl diff --git a/unit_tests/test_isendrecv.cpp b/unit_tests/test_isendrecv.cpp index 709acf0a..f220084b 100644 --- a/unit_tests/test_isendrecv.cpp +++ b/unit_tests/test_isendrecv.cpp @@ -14,21 +14,6 @@ // //@HEADER -#if KOKKOSCOMM_ENABLE_MDSPAN -#if KOKKOSCOMM_MDSPAN_IN_EXPERIMENTAL -#include -#define MDSPAN_PREFIX() experimental:: -#else -#include -#define MDSPAN_PREFIX() -#endif - -using std::MDSPAN_PREFIX() dextents; -using std::MDSPAN_PREFIX() extents; -using std::MDSPAN_PREFIX() layout_stride; -using std::MDSPAN_PREFIX() mdspan; -#endif // KOKKOSCOMM_ENABLE_MDSPAN - #include #include "KokkosComm.hpp" @@ -107,71 +92,3 @@ TYPED_TEST(IsendRecv, 1D_noncontig) { ASSERT_EQ(errs, 0); } } - -#if KOKKOSCOMM_ENABLE_MDSPAN - -TYPED_TEST(IsendRecv, 1D_mdspan_contig) { - using ScalarType = typename TestFixture::Scalar; - - std::vector v(100); - auto a = mdspan(&v[2], 13); // 13 scalars starting at index 2 - - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (0 == rank) { - int dst = 1; - for (size_t i = 0; i < a.extent(0); ++i) { - a[i] = i; - } - KokkosComm::Req req = KokkosComm::isend(Kokkos::DefaultExecutionSpace(), a, - dst, 0, MPI_COMM_WORLD); - req.wait(); - } else if (1 == rank) { - int src = 0; - KokkosComm::recv(Kokkos::DefaultExecutionSpace(), a, src, 0, - MPI_COMM_WORLD); - int errs = 0; - for (size_t i = 0; i < a.extent(0); ++i) { - errs += (a[i] != ScalarType(i)); - } - ASSERT_EQ(errs, 0); - } -} - -TYPED_TEST(IsendRecv, 1D_mdspan_noncontig) { - using ScalarType = typename TestFixture::Scalar; - - std::vector v(100); - - using ExtentsType = dextents; - ExtentsType shape{10}; - std::array strides{10}; - - mdspan a( - &v[2], layout_stride::mapping{shape, strides}); - - int rank; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - - if (0 == rank) { - int dst = 1; - for (size_t i = 0; i < a.extent(0); ++i) { - a[i] = i; - } - KokkosComm::Req req = KokkosComm::isend(Kokkos::DefaultExecutionSpace(), a, - dst, 0, MPI_COMM_WORLD); - req.wait(); - } else if (1 == rank) { - int src = 0; - KokkosComm::recv(Kokkos::DefaultExecutionSpace(), a, src, 0, - MPI_COMM_WORLD); - int errs = 0; - for (size_t i = 0; i < a.extent(0); ++i) { - errs += (a[i] != ScalarType(i)); - } - ASSERT_EQ(errs, 0); - } -} - -#endif // KOKKOSCOMM_ENABLE_MDSPAN \ No newline at end of file