diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be207aec..291c3bdd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -409,15 +409,17 @@ if(BUILD_TESTING) osh_add_exe(arrayops_test) osh_add_exe(sort_test) osh_add_exe(unit_math) + + osh_add_exe(test_patches) + if(Omega_h_USE_MPI) + test_func(run_test_patches_par 4 ./test_patches) + else() + test_func(run_test_patches 1 ./test_patches) + endif() + if (Omega_h_USE_Kokkos) osh_add_exe(bbox_reduce_test) osh_add_exe(initKokkosAndLib) - osh_add_exe(test_patches) - if(Omega_h_USE_MPI) - test_func(run_test_patches_par 4 ./test_patches) - else() - test_func(run_test_patches 1 ./test_patches) - endif() endif() list(APPEND TEST_EXES unit_math) test_basefunc(run_unit_math 1 ./unit_math) @@ -852,7 +854,7 @@ if(Omega_h_USE_STK) endif() if(Omega_h_USE_Kokkos) - list(APPEND Omega_h_HEADERS Omega_h_memory.hpp) + list(APPEND Omega_h_HEADERS Omega_h_memory.hpp) list(APPEND Omega_h_HEADERS Omega_h_pool_kokkos.hpp) list(APPEND Omega_h_HEADERS Omega_h_array_kokkos.hpp) else() diff --git a/src/Omega_h_mesh.hpp b/src/Omega_h_mesh.hpp index d81b3af2..175f307f 100644 --- a/src/Omega_h_mesh.hpp +++ b/src/Omega_h_mesh.hpp @@ -169,7 +169,6 @@ class Mesh { std::string const& name, Read array); friend class ScopedChangeRCFieldsToMesh; - #if defined(OMEGA_H_USE_KOKKOS) /** * \brief form a patch of at least minPatchSize elements surrounding each mesh * vertex @@ -183,7 +182,6 @@ class Mesh { * an empty graph upon failure */ [[nodiscard]] Graph get_vtx_patches(Int minPatchSize, Int tgtDim = -1); - #endif private: @@ -471,3 +469,4 @@ OMEGA_H_EXPL_INST_DECL(Real) } // namespace Omega_h #endif + diff --git a/src/Omega_h_patches.cpp b/src/Omega_h_patches.cpp index ee271a31..4d20081d 100644 --- a/src/Omega_h_patches.cpp +++ b/src/Omega_h_patches.cpp @@ -7,8 +7,13 @@ using namespace Omega_h; #if defined(OMEGA_H_USE_KOKKOS) #include //sort_team +#endif + +#include //std::sort namespace { + +#if defined(OMEGA_H_USE_KOKKOS) [[nodiscard]] Graph adj_segment_sort(Graph& g) { using ExecSpace = Kokkos::DefaultExecutionSpace; using TeamPol = Kokkos::TeamPolicy; @@ -25,6 +30,22 @@ namespace { Kokkos::parallel_for(TeamPol(g.nnodes(), Kokkos::AUTO()), segment_sort); return Graph(offsets,Write(elms)); } +#else +[[nodiscard]] Graph adj_segment_sort(Graph& g) { + auto offsets = g.a2ab; + auto elms_r = HostRead(g.ab2b); //read only + HostWrite elms(elms_r.size(), "elms"); + for (LO i = 0; i < elms.size(); ++i) { + elms[i] = elms_r[i]; + } + + for(LO i = 0; i < g.nnodes(); ++i) { + std::sort(elms.begin() + offsets[i], elms.begin() + offsets[i+1]); + } + + return Graph(offsets, Read(elms)); +} +#endif [[nodiscard]] Graph remove_duplicate_edges(Graph g) { auto offsets = g.a2ab; @@ -131,4 +152,4 @@ namespace { } return Graph(); } -#endif + diff --git a/src/Omega_h_shared_alloc.hpp b/src/Omega_h_shared_alloc.hpp index e85efee9..5b8fd319 100644 --- a/src/Omega_h_shared_alloc.hpp +++ b/src/Omega_h_shared_alloc.hpp @@ -133,6 +133,7 @@ struct SharedAlloc { } OMEGA_H_INLINE std::size_t size() const noexcept { #ifndef __CUDA_ARCH__ + if (alloc == nullptr) return 0; if (!(reinterpret_cast(alloc) & IN_PARALLEL)) { #if defined(__GNUC__) && (__GNUC__ >= 7) && (!defined(__clang__)) #pragma GCC diagnostic push