Skip to content

Commit

Permalink
compiles with hacked version of kokkos 4.5.01
Browse files Browse the repository at this point in the history
  • Loading branch information
cwsmith committed Jan 15, 2025
1 parent 90b5218 commit d449f68
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if (PCMS_ENABLE_OMEGA_H)
endif()
#adios2 adds C and Fortran depending on how it was built
find_package(ADIOS2 2.5 REQUIRED)
find_package(Kokkos 3.0 REQUIRED)
find_package(Kokkos 4.4 REQUIRED) #we need kokkos with vendored mdspan

## use pkgconfig since the fftw autoconf install produces
## broken cmake config files
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ if (spdlog_FOUND)
target_link_libraries(pcms_core PUBLIC spdlog::spdlog)
endif()


## export the library
set_target_properties(pcms_core PROPERTIES
PUBLIC_HEADER "${PCMS_HEADERS}")
Expand Down
31 changes: 16 additions & 15 deletions src/pcms/arrays.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef PCMS_COUPLING_ARRAYS_H
#define PCMS_COUPLING_ARRAYS_H
#include "pcms/external/mdspan.hpp"
#include "mdspan/mdspan.hpp" //from kokkos
#include "mdspan/mdarray.hpp" //from kokkos
#include "pcms/types.h"
#include "pcms/coordinate.h"
#include "pcms/external/span.h"
Expand All @@ -14,7 +15,7 @@ namespace detail

template <typename ElementType, typename MemorySpace>
struct memory_space_accessor
: public std::experimental::default_accessor<ElementType>
: public Kokkos::default_accessor<ElementType>
{
using memory_space = MemorySpace;
};
Expand All @@ -39,7 +40,7 @@ nonstd::span<typename ArrayType::value_type> GetSpan(ArrayType /* unused */)
template <typename ContainerType, typename ElementType, typename Extents,
typename LayoutPolicy, typename AccessorPolicy>
auto make_mdspan(const ContainerType& /* unused */)
-> std::experimental::mdspan<ElementType, Extents, LayoutPolicy,
-> Kokkos::mdspan<ElementType, Extents, LayoutPolicy,
AccessorPolicy>
{
static_assert(detail::dependent_always_false<ContainerType>::type,
Expand Down Expand Up @@ -96,38 +97,38 @@ class ScalarArray
};

template <typename ElementType, typename CoordinateSystem,
typename LayoutPolicy = std::experimental::layout_right,
typename LayoutPolicy = Kokkos::layout_right,
typename Container =
std::vector<CoordinateElement<CoordinateSystem, ElementType>>,
size_t N = 3>

using CoordinateMDArray = std::experimental::mdarray<
using CoordinateMDArray = Kokkos::Experimental::mdarray<
CoordinateElement<CoordinateSystem, ElementType>,
std::experimental::extents<int, std::experimental::dynamic_extent, N>,
Kokkos::extents<int, Kokkos::dynamic_extent, N>,
LayoutPolicy, Container>;

template <typename ElementType,
typename LayoutPolicy = std::experimental::layout_right,
typename LayoutPolicy = Kokkos::layout_right,
typename Container = std::vector<ElementType>>
using MDArray = std::experimental::mdarray<
using MDArray = Kokkos::Experimental::mdarray<
ElementType,
std::experimental::extents<int, std::experimental::dynamic_extent, 1>,
Kokkos::extents<int, Kokkos::dynamic_extent, 1>,
LayoutPolicy, Container>;

template <typename ElementType, typename CoordinateSystem, typename MemorySpace,
size_t N = 1>
using CoordinateArrayView = std::experimental::mdspan<
using CoordinateArrayView = Kokkos::mdspan<
CoordinateElement<ElementType, CoordinateSystem>,
std::experimental::extents<LO, std::experimental::dynamic_extent, N>,
std::experimental::layout_right,
Kokkos::extents<LO, Kokkos::dynamic_extent, N>,
Kokkos::layout_right,
detail::memory_space_accessor<ElementType, MemorySpace>>;

// TODO make_mdspan

template <typename ElementType, typename MemorySpace>
using ScalarArrayView = std::experimental::mdspan<
ElementType, std::experimental::dextents<LO, 1>,
std::experimental::layout_right,
using ScalarArrayView = Kokkos::mdspan<
ElementType, Kokkos::dextents<LO, 1>,
Kokkos::layout_right,
detail::memory_space_accessor<std::remove_reference_t<ElementType>,
MemorySpace>>;

Expand Down
2 changes: 1 addition & 1 deletion src/pcms/xgc_reverse_classification.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "pcms/types.h"
#include <unordered_map>
#include <set>
#include "pcms/external/mdspan.hpp"
#include "mdspan/mdspan.hpp" //from kokkos
#include "pcms/arrays.h"
#include "pcms/memory_spaces.h"
//#include <filesystem>
Expand Down
2 changes: 1 addition & 1 deletion test/test_coordinate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <catch2/catch_approx.hpp>
#include <pcms/coordinate.h>
#include <pcms/coordinate_systems.h>
#include <pcms/external/mdspan.hpp>
#include "mdspan/mdspan.hpp" //from kokkos
#include <pcms/arrays.h>

using pcms::Cartesian;
Expand Down

0 comments on commit d449f68

Please sign in to comment.