Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assign and bind to deal with different const of functions #118

Merged
merged 1 commit into from
Jul 9, 2024
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
17 changes: 14 additions & 3 deletions include/pando-lib-galois/graphs/dist_local_csr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ class DistLocalCSR {

private:
constexpr static pando::GlobalRef<CSR> getCachedCSR(CSRCache cache, std::uint64_t i) {
return fmap(cache.getLocalRef(), operator[], i);
return applyFunc(cache.getLocalRef(), [i](HostIndexedMap<CSR> map) {
return map[i];
});
}

template <typename T>
Expand Down Expand Up @@ -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);
}
Expand Down
16 changes: 16 additions & 0 deletions include/pando-lib-galois/utility/gptr_monad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,20 @@
*ptrComputed##__LINE__ = tmp; \
} while (0)

#include <pando-rt/memory/global_ptr.hpp>

template <typename T, typename F>
auto bindFunc(pando::GlobalRef<T> ref, F func) {
T obj = ref;
auto ret = func(obj);
ref = obj;
return ret;
}

template <typename T, typename F>
auto applyFunc(pando::GlobalRef<T> ref, F func) {
T obj = ref;
return func(obj);
}

#endif // PANDO_LIB_GALOIS_UTILITY_GPTR_MONAD_HPP_
Loading