Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions src/Omega_h_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ class Mesh {
std::string const& name, Read<T> array);
friend class ScopedChangeRCFieldsToMesh;

#if defined(OMEGA_H_USE_KOKKOS)
/**
* \brief form a patch of at least minPatchSize elements surrounding each mesh
* vertex
Expand All @@ -183,7 +182,6 @@ class Mesh {
* an empty graph upon failure
*/
[[nodiscard]] Graph get_vtx_patches(Int minPatchSize, Int tgtDim = -1);
#endif


private:
Expand Down Expand Up @@ -471,3 +469,4 @@ OMEGA_H_EXPL_INST_DECL(Real)
} // namespace Omega_h

#endif

23 changes: 22 additions & 1 deletion src/Omega_h_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ using namespace Omega_h;

#if defined(OMEGA_H_USE_KOKKOS)
#include <Kokkos_NestedSort.hpp> //sort_team
#endif

#include <algorithm> //std::sort

namespace {

#if defined(OMEGA_H_USE_KOKKOS)
[[nodiscard]] Graph adj_segment_sort(Graph& g) {
using ExecSpace = Kokkos::DefaultExecutionSpace;
using TeamPol = Kokkos::TeamPolicy<ExecSpace>;
Expand All @@ -25,6 +30,22 @@ namespace {
Kokkos::parallel_for(TeamPol(g.nnodes(), Kokkos::AUTO()), segment_sort);
return Graph(offsets,Write<LO>(elms));
}
#else
[[nodiscard]] Graph adj_segment_sort(Graph& g) {
auto offsets = g.a2ab;
auto elms_r = HostRead(g.ab2b); //read only
HostWrite<LO> 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<LO>(elms));
}
#endif

[[nodiscard]] Graph remove_duplicate_edges(Graph g) {
auto offsets = g.a2ab;
Expand Down Expand Up @@ -131,4 +152,4 @@ namespace {
}
return Graph();
}
#endif

1 change: 1 addition & 0 deletions src/Omega_h_shared_alloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::uintptr_t>(alloc) & IN_PARALLEL)) {
#if defined(__GNUC__) && (__GNUC__ >= 7) && (!defined(__clang__))
#pragma GCC diagnostic push
Expand Down
Loading