From 91b1cd2329df79169cf2a5ceb1cd8d37c0c62758 Mon Sep 17 00:00:00 2001 From: Fuad Hasan Date: Thu, 6 Aug 2026 16:59:51 -0400 Subject: [PATCH 1/3] alternative get_vtx_patches without kokkos - all other code in the file works without kokkos excect this. - moved the kokkos linking guards only wrapping this. - passes all tests locally (including python) - fixes issue #230 --- src/Omega_h_mesh.hpp | 3 +-- src/Omega_h_patches.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Omega_h_mesh.hpp b/src/Omega_h_mesh.hpp index d81b3af28..175f307fe 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 ee271a316..71c72adbb 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 = Read(g.ab2b); //read only + Write elms(elms_r.size(), "elms"); + auto copyFn = OMEGA_H_LAMBDA(LO i) { + elms[i] = elms_r[i]; + }; + parallel_for(elms.size(), copyFn); + auto sortFn = OMEGA_H_LAMBDA(LO i) { + std::sort(elms.begin() + offsets[i], elms.begin() + offsets[i+1]); + }; + parallel_for(g.nnodes(), sortFn); + return Graph(offsets, elms); +} +#endif [[nodiscard]] Graph remove_duplicate_edges(Graph g) { auto offsets = g.a2ab; @@ -131,4 +152,4 @@ namespace { } return Graph(); } -#endif + From 18fb8c49caea98c47f36907c8602fba78122d5a3 Mon Sep 17 00:00:00 2001 From: Fuad Hasan Date: Wed, 12 Aug 2026 15:07:23 -0400 Subject: [PATCH 2/3] test patches without kokkos removed parallel_for and Read/Write moved test_patch out of kokkos condition --- src/CMakeLists.txt | 16 +++++++++------- src/Omega_h_patches.cpp | 18 +++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be207aec8..291c3bdd6 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_patches.cpp b/src/Omega_h_patches.cpp index 71c72adbb..4d20081df 100644 --- a/src/Omega_h_patches.cpp +++ b/src/Omega_h_patches.cpp @@ -33,17 +33,17 @@ namespace { #else [[nodiscard]] Graph adj_segment_sort(Graph& g) { auto offsets = g.a2ab; - auto elms_r = Read(g.ab2b); //read only - Write elms(elms_r.size(), "elms"); - auto copyFn = OMEGA_H_LAMBDA(LO i) { + 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]; - }; - parallel_for(elms.size(), copyFn); - auto sortFn = OMEGA_H_LAMBDA(LO i) { + } + + for(LO i = 0; i < g.nnodes(); ++i) { std::sort(elms.begin() + offsets[i], elms.begin() + offsets[i+1]); - }; - parallel_for(g.nnodes(), sortFn); - return Graph(offsets, elms); + } + + return Graph(offsets, Read(elms)); } #endif From 50fb275f7c1a3f877363928ad29e4cebc494f790 Mon Sep 17 00:00:00 2001 From: Fuad Hasan Date: Wed, 12 Aug 2026 16:50:00 -0400 Subject: [PATCH 3/3] SharedAlloc::size() returns zero if nullptr --- src/Omega_h_shared_alloc.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Omega_h_shared_alloc.hpp b/src/Omega_h_shared_alloc.hpp index e85efee9a..5b8fd319b 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