From 0c38f0f01da38b8297e471748cb5ab81dbfe7ea9 Mon Sep 17 00:00:00 2001 From: AdityaAtulTewari Date: Thu, 13 Jun 2024 14:40:47 +0000 Subject: [PATCH] assign and bind to deal with different types of objects --- .../pando-lib-galois/graphs/dist_local_csr.hpp | 17 ++++++++++++++--- include/pando-lib-galois/utility/gptr_monad.hpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/pando-lib-galois/graphs/dist_local_csr.hpp b/include/pando-lib-galois/graphs/dist_local_csr.hpp index d879e848..2136f4d1 100644 --- a/include/pando-lib-galois/graphs/dist_local_csr.hpp +++ b/include/pando-lib-galois/graphs/dist_local_csr.hpp @@ -329,7 +329,9 @@ class DistLocalCSR { private: constexpr static pando::GlobalRef getCachedCSR(CSRCache cache, std::uint64_t i) { - return fmap(cache.getLocalRef(), operator[], i); + return applyFunc(cache.getLocalRef(), [i](HostIndexedMap map) { + return map[i]; + }); } template @@ -500,9 +502,18 @@ class DistLocalCSR { } VertexDataRange vertexDataRange() noexcept { - return VertexDataRange{arrayOfCSRs, lift(getCSR(0), vertexData.begin), - lift(getCSR(arrayOfCSRs.size() - 1), vertexData.end), numVertices}; + return VertexDataRange{arrayOfCSRs, + applyFunc(getCSR(0), + [](CSR csr) { + return csr.vertexData.begin(); + }), + applyFunc(getCSR(arrayOfCSRs.size() - 1), + [](CSR csr) { + return csr.vertexData.end(); + }), + numVertices}; } + EdgeDataRange edgeDataRange(VertexTopologyID vertex) noexcept { return fmap(getCSR(vertex), edgeDataRange, vertex); } diff --git a/include/pando-lib-galois/utility/gptr_monad.hpp b/include/pando-lib-galois/utility/gptr_monad.hpp index e4e254d8..0d0c7872 100644 --- a/include/pando-lib-galois/utility/gptr_monad.hpp +++ b/include/pando-lib-galois/utility/gptr_monad.hpp @@ -54,4 +54,20 @@ *ptrComputed##__LINE__ = tmp; \ } while (0) +#include + +template +auto bindFunc(pando::GlobalRef ref, F func) { + T obj = ref; + auto ret = func(obj); + ref = obj; + return ret; +} + +template +auto applyFunc(pando::GlobalRef ref, F func) { + T obj = ref; + return func(obj); +} + #endif // PANDO_LIB_GALOIS_UTILITY_GPTR_MONAD_HPP_