From b599e06f791a572178c48d054ca6f7c89dc69e81 Mon Sep 17 00:00:00 2001 From: AdityaAtulTewari Date: Tue, 2 Apr 2024 10:21:42 -0700 Subject: [PATCH] Changed the Api to use get() for ptrs and operator[] for Ref (#5) --- .../containers/host_indexed_map.hpp | 45 ++++++++++--- .../containers/host_local_storage.hpp | 42 +++++++++--- .../containers/per_thread.hpp | 13 ++-- .../containers/pod_local_storage.hpp | 33 +++++++--- .../containers/thread_local_storage.hpp | 51 ++++++++++---- .../graphs/dist_local_csr.hpp | 44 ++++++------- .../import/wmd_graph_importer.hpp | 66 +++++++++---------- .../utility/dist_accumulator.hpp | 4 +- src/wmd_graph_importer.cpp | 2 +- test/containers/test_host_indexed_map.cpp | 10 +-- test/containers/test_host_local_storage.cpp | 10 +-- test/containers/test_per_thread.cpp | 2 +- test/containers/test_thread_local_storage.cpp | 6 +- 13 files changed, 210 insertions(+), 118 deletions(-) diff --git a/include/pando-lib-galois/containers/host_indexed_map.hpp b/include/pando-lib-galois/containers/host_indexed_map.hpp index 22a626f6..7ff7df9c 100644 --- a/include/pando-lib-galois/containers/host_indexed_map.hpp +++ b/include/pando-lib-galois/containers/host_indexed_map.hpp @@ -31,15 +31,15 @@ class HostIndexedMap { using iterator = HostIndexedMapIt; using reverse_iterator = std::reverse_iterator; - [[nodiscard]] constexpr std::uint64_t getNumHosts() const noexcept { + [[nodiscard]] static constexpr std::uint64_t getNumHosts() noexcept { return static_cast(pando::getPlaceDims().node.id); } - [[nodiscard]] constexpr std::uint64_t getCurrentNode() const noexcept { + [[nodiscard]] constexpr std::uint64_t getCurrentHost() const noexcept { return static_cast(pando::getCurrentPlace().node.id); } - std::uint64_t size() { + static constexpr std::uint64_t size() noexcept { return getNumHosts(); } @@ -57,20 +57,49 @@ class HostIndexedMap { deallocateMemory(m_items, getNumHosts()); } - pando::GlobalRef getLocal() noexcept { - return m_items[getCurrentNode()]; + pando::GlobalPtr get(std::uint64_t i) noexcept { + return &m_items[i]; } - pando::GlobalRef get(std::uint64_t i) noexcept { - return m_items[i]; + pando::GlobalPtr get(std::uint64_t i) const noexcept { + return &m_items[i]; + } + + pando::GlobalPtr getLocal() noexcept { + return &m_items[getCurrentHost()]; + } + + pando::GlobalPtr getLocal() const noexcept { + return &m_items[getCurrentHost()]; + } + + pando::GlobalRef getLocalRef() noexcept { + return m_items[getCurrentHost()]; + } + + pando::GlobalRef getLocalRef() const noexcept { + return m_items[getCurrentHost()]; + } + + pando::GlobalRef operator[](std::uint64_t i) noexcept { + return *this->get(i); + } + + pando::GlobalRef operator[](std::uint64_t i) const noexcept { + return *this->get(i); } template - pando::GlobalRef getFromPtr(pando::GlobalPtr ptr) { + pando::GlobalPtr getFromPtr(pando::GlobalPtr ptr) { std::uint64_t i = static_cast(pando::localityOf(ptr).node.id); return this->get(i); } + template + pando::GlobalRef getRefFromPtr(pando::GlobalPtr ptr) { + return *getFromPtr(ptr); + } + iterator begin() noexcept { return iterator(m_items, 0); } diff --git a/include/pando-lib-galois/containers/host_local_storage.hpp b/include/pando-lib-galois/containers/host_local_storage.hpp index 2252f160..41f20ecc 100644 --- a/include/pando-lib-galois/containers/host_local_storage.hpp +++ b/include/pando-lib-galois/containers/host_local_storage.hpp @@ -69,15 +69,15 @@ class HostLocalStorage { using iterator = HostLocalStorageIt; using reverse_iterator = std::reverse_iterator; - [[nodiscard]] constexpr std::uint64_t getNumHosts() const noexcept { + [[nodiscard]] static constexpr std::uint64_t getNumHosts() noexcept { return static_cast(pando::getPlaceDims().node.id); } - [[nodiscard]] constexpr std::uint64_t getCurrentNode() const noexcept { + [[nodiscard]] static constexpr std::uint64_t getCurrentHost() noexcept { return static_cast(pando::getCurrentPlace().node.id); } - std::uint64_t size() { + static constexpr std::uint64_t size() noexcept { return getNumHosts(); } @@ -90,12 +90,36 @@ class HostLocalStorage { HostLocalStorageHeap::deallocate(m_items); } - pando::GlobalRef getLocal() noexcept { + pando::GlobalPtr getLocal() noexcept { + return m_items.getPointer(); + } + + pando::GlobalPtr getLocal() const noexcept { + return m_items.getPointer(); + } + + pando::GlobalRef getLocalRef() noexcept { return *m_items.getPointer(); } - pando::GlobalRef get(std::uint64_t i) noexcept { - return *m_items.getPointerAt(pando::NodeIndex(static_cast(i))); + pando::GlobalRef getLocalRef() const noexcept { + return *m_items.getPointer(); + } + + pando::GlobalPtr get(std::uint64_t i) noexcept { + return m_items.getPointerAt(pando::NodeIndex(static_cast(i))); + } + + pando::GlobalPtr get(std::uint64_t i) const noexcept { + return m_items.getPointerAt(pando::NodeIndex(static_cast(i))); + } + + pando::GlobalRef operator[](std::uint64_t i) noexcept { + return *this->get(i); + } + + pando::GlobalRef operator[](std::uint64_t i) const noexcept { + return *this->get(i); } template @@ -180,15 +204,15 @@ class HostLocalStorageIt { constexpr HostLocalStorageIt& operator=(HostLocalStorageIt&&) noexcept = default; reference operator*() const noexcept { - return m_curr.get(m_loc); + return m_curr[m_loc]; } reference operator*() noexcept { - return m_curr.get(m_loc); + return m_curr[m_loc]; } pointer operator->() { - return &m_curr.get(m_loc); + return m_curr.get(m_loc); } HostLocalStorageIt& operator++() { diff --git a/include/pando-lib-galois/containers/per_thread.hpp b/include/pando-lib-galois/containers/per_thread.hpp index 3a8a49f4..0061a7e4 100644 --- a/include/pando-lib-galois/containers/per_thread.hpp +++ b/include/pando-lib-galois/containers/per_thread.hpp @@ -306,7 +306,7 @@ class PerThreadVector { // Initialize the per host vectors for (std::int16_t i = 0; i < static_cast(lift(flat, getNumHosts)); i++) { auto place = pando::Place{pando::NodeIndex{i}, pando::anyPod, pando::anyCore}; - auto ref = fmap(flat, get, i); + auto ref = fmap(flat, operator[], i); std::uint64_t start = (i == 0) ? 0 : m_indices[static_cast(i) * cores * threads - 1]; std::uint64_t end = m_indices[static_cast(i + 1) * cores * threads - 1]; @@ -322,10 +322,10 @@ class PerThreadVector { std::uint64_t start = (host == 0) ? 0 : assign.data.m_indices[index]; std::uint64_t curr = (i == 0) ? 0 : assign.data.m_indices[i - 1]; - auto ref = assign.to.get(host); + auto ref = assign.to[host]; pando::Vector localVec = assign.data[i]; for (T elt : localVec) { - fmap(ref, get, curr - start) = elt; + fmap(ref, operator[], curr - start) = elt; curr++; } }; @@ -343,7 +343,7 @@ class PerThreadVector { // TODO(AdityaAtulTewari) Make this properly parallel. // Initialize the per host vectors for (std::int16_t i = 0; i < static_cast(flat.getNumHosts()); i++) { - auto ref = flat.get(i); + auto ref = flat[i]; std::uint64_t start = (i == 0) ? 0 : m_indices[static_cast(i) * cores * threads - 1]; std::uint64_t end = m_indices[static_cast(i + 1) * cores * threads - 1]; @@ -364,7 +364,7 @@ class PerThreadVector { std::uint64_t end = assign.data.m_indices[(host + 1) * assign.data.cores * assign.data.threads - 1]; - auto ref = assign.to.get(host); + auto ref = assign.to[host]; pando::Vector localVec = assign.data[i]; std::uint64_t size = lift(ref, size) - (end - start); for (T elt : localVec) { @@ -459,6 +459,7 @@ class PTVectorIterator { using value_type = pando::Vector; using pointer = pando::GlobalPtr>; using reference = pando::GlobalRef>; + using const_reference = pando::GlobalRef>; PTVectorIterator(PerThreadVector arr, std::uint64_t pos) : m_arr(arr), m_pos(pos) {} @@ -520,7 +521,7 @@ class PTVectorIterator { return m_arr.get(m_pos + n); } - reference operator[](std::uint64_t n) const noexcept { + const_reference operator[](std::uint64_t n) const noexcept { return m_arr.get(m_pos + n); } diff --git a/include/pando-lib-galois/containers/pod_local_storage.hpp b/include/pando-lib-galois/containers/pod_local_storage.hpp index 574e20a7..424c3626 100644 --- a/include/pando-lib-galois/containers/pod_local_storage.hpp +++ b/include/pando-lib-galois/containers/pod_local_storage.hpp @@ -72,19 +72,19 @@ class PodLocalStorage { using iterator = PodLocalStorageIt; using reverse_iterator = std::reverse_iterator; - [[nodiscard]] constexpr std::uint64_t getNumPods() const noexcept { + [[nodiscard]] static constexpr std::uint64_t getNumPods() noexcept { const auto p = pando::getPlaceDims(); return static_cast(p.node.id * p.pod.x * p.pod.y); } - [[nodiscard]] constexpr std::uint64_t getCurrentPodIdx() const noexcept { + [[nodiscard]] static constexpr std::uint64_t getCurrentPodIdx() noexcept { const auto dim = pando::getPlaceDims(); const auto cur = pando::getCurrentPlace(); return static_cast(cur.node.id * dim.pod.x * dim.pod.y + cur.pod.x * dim.pod.y + cur.pod.y); } - [[nodiscard]] constexpr pando::Place getPlaceFromPodIdx(std::uint64_t idx) const noexcept { + [[nodiscard]] static constexpr pando::Place getPlaceFromPodIdx(std::uint64_t idx) noexcept { const auto dim = pando::getPlaceDims(); const auto pods = dim.pod.x * dim.pod.y; const pando::NodeIndex node = pando::NodeIndex(idx / pods); @@ -93,7 +93,7 @@ class PodLocalStorage { return pando::Place(node, pod, pando::anyCore); } - std::uint64_t size() { + static constexpr std::uint64_t size() noexcept { return getNumPods(); } @@ -110,7 +110,22 @@ class PodLocalStorage { return *m_items.getPointer(); } - pando::GlobalRef get(std::uint64_t i) noexcept { + pando::GlobalPtr get(std::uint64_t i) noexcept { + auto place = getPlaceFromPodIdx(i); + return *m_items.getPointerAt(place.node, place.pod); + } + + pando::GlobalPtr get(std::uint64_t i) const noexcept { + auto place = getPlaceFromPodIdx(i); + return m_items.getPointerAt(place.node, place.pod); + } + + pando::GlobalRef operator[](std::uint64_t i) noexcept { + auto place = getPlaceFromPodIdx(i); + return *m_items.getPointerAt(place.node, place.pod); + } + + pando::GlobalRef operator[](std::uint64_t i) const noexcept { auto place = getPlaceFromPodIdx(i); return *m_items.getPointerAt(place.node, place.pod); } @@ -199,15 +214,15 @@ class PodLocalStorageIt { constexpr PodLocalStorageIt& operator=(PodLocalStorageIt&&) noexcept = default; reference operator*() const noexcept { - return m_curr.get(m_loc); + return m_curr[m_loc]; } reference operator*() noexcept { - return m_curr.get(m_loc); + return m_curr[m_loc]; } pointer operator->() { - return &m_curr.get(m_loc); + return m_curr.get(m_loc); } PodLocalStorageIt& operator++() { @@ -288,7 +303,7 @@ template const std::uint64_t size = cont.size(); PANDO_CHECK(copy.initialize(size)); for (std::uint64_t i = 0; i < cont.size(); i++) { - copy.get(i) = cont.get(i); + copy[i] = cont[i]; } refcopy = copy; })); diff --git a/include/pando-lib-galois/containers/thread_local_storage.hpp b/include/pando-lib-galois/containers/thread_local_storage.hpp index 8bff6e28..bf0dd1a3 100644 --- a/include/pando-lib-galois/containers/thread_local_storage.hpp +++ b/include/pando-lib-galois/containers/thread_local_storage.hpp @@ -37,7 +37,7 @@ class ThreadLocalStorage { using iterator = ThreadLocalStorageIt; using reverse_iterator = std::reverse_iterator; - [[nodiscard]] constexpr std::uint64_t getNumThreads() const noexcept { + [[nodiscard]] static constexpr std::uint64_t getNumThreads() noexcept { const auto place = pando::getPlaceDims(); std::uint64_t nodes = static_cast(place.node.id); std::uint64_t pods = static_cast(place.pod.x * place.pod.y); @@ -50,8 +50,8 @@ class ThreadLocalStorage { return getThreadIdxFromPlace(pando::getCurrentPlace(), pando::getCurrentThread()); } - [[nodiscard]] constexpr std::uint64_t getThreadIdxFromPlace( - pando::Place place, pando::ThreadIndex thread) const noexcept { + [[nodiscard]] static constexpr std::uint64_t getThreadIdxFromPlace( + pando::Place place, pando::ThreadIndex thread) noexcept { const auto placeDims = pando::getPlaceDims(); const auto threadDims = pando::getThreadDims(); const std::uint64_t threadsPerCore = static_cast(threadDims.id); @@ -68,8 +68,8 @@ class ThreadLocalStorage { return hostIdx * threadsPerHost + podIdx * threadsPerPod + coreIdx * threadsPerCore + threadIdx; } - [[nodiscard]] constexpr galois::Tuple2 getPlaceFromThreadIdx( - std::uint64_t idx) const noexcept { + [[nodiscard]] static constexpr galois::Tuple2 + getPlaceFromThreadIdx(std::uint64_t idx) noexcept { const auto placeDims = pando::getPlaceDims(); const auto threadDims = pando::getThreadDims(); const std::uint64_t threadsPerCore = static_cast(threadDims.id); @@ -91,7 +91,7 @@ class ThreadLocalStorage { return galois::make_tpl(pando::Place{node, pod, core}, thread); } - std::uint64_t size() { + static constexpr std::uint64_t size() noexcept { return getNumThreads(); } @@ -126,7 +126,7 @@ class ThreadLocalStorage { m_items.deinitialize(); } - pando::GlobalRef get(std::uint64_t i) noexcept { + pando::GlobalPtr get(std::uint64_t i) noexcept { const auto placeDims = pando::getPlaceDims(); const auto threadDims = pando::getThreadDims(); const std::uint64_t threadsPerCore = static_cast(threadDims.id); @@ -135,14 +135,39 @@ class ThreadLocalStorage { static_cast(placeDims.core.y); const std::uint64_t podIdx = i / threadsPerPod; const std::uint64_t threadPerPodIdx = i % threadsPerPod; - pando::GlobalPtr arr = m_items.get(podIdx); - return *(arr + threadPerPodIdx); + pando::GlobalPtr arr = m_items[podIdx]; + return (arr + threadPerPodIdx); } - pando::GlobalRef getLocal() noexcept { + pando::GlobalPtr get(std::uint64_t i) const noexcept { + const auto placeDims = pando::getPlaceDims(); + const auto threadDims = pando::getThreadDims(); + const std::uint64_t threadsPerCore = static_cast(threadDims.id); + const std::uint64_t threadsPerPod = threadsPerCore * + static_cast(placeDims.core.x) * + static_cast(placeDims.core.y); + const std::uint64_t podIdx = i / threadsPerPod; + const std::uint64_t threadPerPodIdx = i % threadsPerPod; + pando::GlobalPtr arr = m_items[podIdx]; + return (arr + threadPerPodIdx); + } + + pando::GlobalRef operator[](std::uint64_t i) noexcept { + return *this->get(i); + } + + pando::GlobalRef operator[](std::uint64_t i) const noexcept { + return *this->get(i); + } + + pando::GlobalPtr getLocal() noexcept { return this->get(this->getCurrentThreadIdx()); } + pando::GlobalRef getLocalRef() noexcept { + return *this->get(this->getCurrentThreadIdx()); + } + iterator begin() noexcept { return iterator(*this, 0); } @@ -219,15 +244,15 @@ class ThreadLocalStorageIt { constexpr ThreadLocalStorageIt& operator=(ThreadLocalStorageIt&&) noexcept = default; reference operator*() const noexcept { - return m_curr.get(m_loc); + return m_curr[m_loc]; } reference operator*() noexcept { - return m_curr.get(m_loc); + return m_curr[m_loc]; } pointer operator->() { - return &m_curr.get(m_loc); + return m_curr.get(m_loc); } ThreadLocalStorageIt& operator++() { diff --git a/include/pando-lib-galois/graphs/dist_local_csr.hpp b/include/pando-lib-galois/graphs/dist_local_csr.hpp index 7b0677be..d1528df7 100644 --- a/include/pando-lib-galois/graphs/dist_local_csr.hpp +++ b/include/pando-lib-galois/graphs/dist_local_csr.hpp @@ -95,12 +95,12 @@ class DistLocalCSR { VertexIt& operator++() { auto currNode = static_cast(galois::localityOf(m_pos).node.id); pointer ptr = m_pos + 1; - CSR csrCurr = arrayOfCSRs.get(currNode); + CSR csrCurr = arrayOfCSRs[currNode]; if (csrCurr.vertexEdgeOffsets.end() - 1 > ptr || (int16_t)currNode == pando::getPlaceDims().node.id - 1) { m_pos = ptr; } else { - csrCurr = arrayOfCSRs.get(currNode + 1); + csrCurr = arrayOfCSRs[currNode + 1]; this->m_pos = csrCurr.vertexEdgeOffsets.begin(); } return *this; @@ -322,7 +322,7 @@ class DistLocalCSR { private: template pando::GlobalRef getCSR(pando::GlobalPtr ptr) { - return arrayOfCSRs.getFromPtr(ptr); + return arrayOfCSRs.getRefFromPtr(ptr); } EdgeHandle halfEdgeBegin(VertexTopologyID vertex) { @@ -334,7 +334,7 @@ class DistLocalCSR { } std::uint64_t numVHosts() { - return lift(this->virtualToPhysicalMap.getLocal(), size); + return lift(this->virtualToPhysicalMap.getLocalRef(), size); } struct InitializeEdgeState { @@ -393,15 +393,15 @@ class DistLocalCSR { /** Vertex Manipulation **/ VertexTopologyID getTopologyID(VertexTokenID tid) { std::uint64_t virtualHostID = tid % this->numVHosts(); - std::uint64_t physicalHost = fmap(virtualToPhysicalMap.getLocal(), get, virtualHostID); - return fmap(arrayOfCSRs.get(physicalHost), getTopologyID, tid); + std::uint64_t physicalHost = fmap(virtualToPhysicalMap.getLocalRef(), get, virtualHostID); + return fmap(arrayOfCSRs[physicalHost], getTopologyID, tid); } VertexTopologyID getTopologyIDFromIndex(std::uint64_t index) { std::uint64_t hostNum = 0; std::uint64_t hostSize; for (; index > (hostSize = localSize(hostNum)); hostNum++, index -= hostSize) {} - return fmap(arrayOfCSRs.get(hostNum), getTopologyIDFromIndex, index); + return fmap(arrayOfCSRs[hostNum], getTopologyIDFromIndex, index); } VertexTokenID getTokenID(VertexTopologyID tid) { return fmap(getCSR(tid), getTokenID, tid); @@ -410,7 +410,7 @@ class DistLocalCSR { std::uint64_t vid = fmap(getCSR(vertex), getVertexIndex, vertex); for (std::uint64_t i = 0; i < static_cast(getLocalityVertex(vertex).node.id); i++) { - vid += lift(arrayOfCSRs.get(i), size); + vid += lift(arrayOfCSRs[i], size); } return vid; } @@ -444,8 +444,8 @@ class DistLocalCSR { /** Ranges **/ VertexRange vertices() { - return VertexRange{arrayOfCSRs, lift(arrayOfCSRs.get(0), vertexEdgeOffsets.begin), - lift(arrayOfCSRs.get(arrayOfCSRs.size() - 1), vertexEdgeOffsets.end) - 1, + return VertexRange{arrayOfCSRs, lift(arrayOfCSRs[0], vertexEdgeOffsets.begin), + lift(arrayOfCSRs[arrayOfCSRs.size() - 1], vertexEdgeOffsets.end) - 1, numVertices}; } @@ -455,7 +455,7 @@ class DistLocalCSR { return RefSpan(v.edgeBegin, v1.edgeBegin - v.edgeBegin); } VertexDataRange vertexDataRange() noexcept { - return VertexDataRange{arrayOfCSRs, lift(arrayOfCSRs.get(0), vertexData.begin), + return VertexDataRange{arrayOfCSRs, lift(arrayOfCSRs[0], vertexData.begin), lift(arrayOfCSRs.get(arrayOfCSRs.size() - 1), vertexData.end), numVertices}; } @@ -504,7 +504,7 @@ class DistLocalCSR { galois::HostIndexedMap numVerticesPerHost{}; PANDO_CHECK_RETURN(numVerticesPerHost.initialize()); for (std::uint64_t i = 0; i < numHosts; i++) { - numVerticesPerHost.get(i) = lift(vertexData.get(i), size); + numVerticesPerHost[i] = lift(vertexData[i], size); } auto createCSRFuncs = +[](galois::HostIndexedMap arrayOfCSRs, @@ -513,20 +513,20 @@ class DistLocalCSR { galois::WaitGroup::HandleType wgh) { CSR currentCSR; PANDO_CHECK( - currentCSR.initializeTopologyMemory(lift(vertexData.getLocal(), size), numEdges.get(i))); + currentCSR.initializeTopologyMemory(lift(vertexData.getLocalRef(), size), numEdges[i])); PANDO_CHECK( - currentCSR.initializeDataMemory(lift(vertexData.getLocal(), size), numEdges.get(i))); + currentCSR.initializeDataMemory(lift(vertexData.getLocalRef(), size), numEdges[i])); std::uint64_t j = 0; - pando::Vector vertexDataVec = vertexData.getLocal(); + pando::Vector vertexDataVec = vertexData.getLocalRef(); for (ReadVertexType data : vertexDataVec) { currentCSR.topologyToToken[j] = data.id; currentCSR.vertexData[j] = VertexData(data); PANDO_CHECK(currentCSR.tokenToTopology.put(data.id, ¤tCSR.vertexEdgeOffsets[j])); j++; } - arrayOfCSRs.getLocal() = currentCSR; + arrayOfCSRs.getLocalRef() = currentCSR; wgh.done(); }; @@ -537,7 +537,7 @@ class DistLocalCSR { pando::executeOn(place, createCSRFuncs, this->arrayOfCSRs, vertexData, numEdges, i, wgh)); } for (std::uint64_t i = 0; i < numEdges.size(); i++) { - this->numEdges += numEdges.get(i); + this->numEdges += numEdges[i]; } PANDO_CHECK_RETURN(wg.wait()); wgh.add(numHosts); @@ -548,10 +548,10 @@ class DistLocalCSR { galois::HostIndexedMap> edgeMap, galois::HostIndexedMap numVerticesPerHost, std::uint64_t i, galois::WaitGroup::HandleType wgh) { - CSR currentCSR = dlcsr.arrayOfCSRs.get(i); - pando::Vector> currEdgeData = edgeData.get(i); - std::uint64_t numVertices = numVerticesPerHost.get(i); - galois::HashTable currEdgeMap = edgeMap.get(i); + CSR currentCSR = dlcsr.arrayOfCSRs[i]; + pando::Vector> currEdgeData = edgeData[i]; + std::uint64_t numVertices = numVerticesPerHost[i]; + galois::HashTable currEdgeMap = edgeMap[i]; std::uint64_t edgeCurr = 0; currentCSR.vertexEdgeOffsets[0] = Vertex{currentCSR.edgeDestinations.begin()}; for (std::uint64_t vertexCurr = 0; vertexCurr < numVertices; vertexCurr++) { @@ -575,7 +575,7 @@ class DistLocalCSR { currentCSR.vertexEdgeOffsets[vertexCurr + 1] = Vertex{¤tCSR.edgeDestinations[edgeCurr]}; } - dlcsr.arrayOfCSRs.getLocal() = currentCSR; + dlcsr.arrayOfCSRs.getLocalRef() = currentCSR; wgh.done(); }; for (std::uint64_t i = 0; i < numHosts; i++) { diff --git a/include/pando-lib-galois/import/wmd_graph_importer.hpp b/include/pando-lib-galois/import/wmd_graph_importer.hpp index cf80c908..d6078687 100644 --- a/include/pando-lib-galois/import/wmd_graph_importer.hpp +++ b/include/pando-lib-galois/import/wmd_graph_importer.hpp @@ -184,7 +184,7 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer pando::GlobalRef> hashRef) { uint64_t idx = 0; const std::uint64_t hostID = static_cast(pando::getCurrentPlace().node.id); - pando::Vector partVert = partitionedVertices.get(hostID); + pando::Vector partVert = partitionedVertices[hostID]; pando::Vector v; PANDO_CHECK(fmap(v, initialize, 0)); for (VertexType vrtx : partVert) { @@ -195,7 +195,7 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer i = 0; for (pando::GlobalRef>> vvec : partEdges) { - PANDO_CHECK(fmap(vvec, initialize, lift(renamePerHost.get(i), size))); + PANDO_CHECK(fmap(vvec, initialize, lift(renamePerHost[i], size))); pando::Vector> vec = vvec; for (pando::GlobalRef> v : vec) { PANDO_CHECK(fmap(v, initialize, 0)); @@ -219,8 +219,8 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer PANDO_CHECK(numEdgesPerHostPerThread.initialize()); PANDO_CHECK(prefixArrayPerHostPerThread.initialize()); for (std::uint64_t i = 0; i < numHosts; i++) { - PANDO_CHECK(fmap(prefixArrayPerHostPerThread.get(i), initialize, lift(localEdges, size))); - PANDO_CHECK(fmap(numEdgesPerHostPerThread.get(i), initialize, lift(localEdges, size))); + PANDO_CHECK(fmap(prefixArrayPerHostPerThread[i], initialize, lift(localEdges, size))); + PANDO_CHECK(fmap(numEdgesPerHostPerThread[i], initialize, lift(localEdges, size))); } auto state = galois::make_tpl(perThreadEdges, localEdges, v2PM, numEdgesPerHostPerThread); @@ -234,12 +234,12 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer for (pando::Vector vec : localEdges) { EdgeType e = vec[0]; uint64_t hostID = V2PMap[e.src % V2PMap.size()]; - PANDO_CHECK(fmap(edgeVec.get(hostID), pushBack, vec)); + PANDO_CHECK(fmap(edgeVec[hostID], pushBack, vec)); } std::uint64_t numHosts = static_cast(pando::getPlaceDims().node.id); for (uint64_t i = 0; i < numHosts; i++) { - galois::Array arr = prefixArr.get(i); - *(arr.begin() + tid) = lift(edgeVec.get(i), size); + galois::Array arr = prefixArr[i]; + *(arr.begin() + tid) = lift(edgeVec[i], size); } }); @@ -249,8 +249,8 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer using SRC_Val = uint64_t; using DST_Val = uint64_t; for (uint64_t i = 0; i < numHosts; i++) { - galois::Array arr = numEdgesPerHostPerThread.get(i); - galois::Array prefixArr = prefixArrayPerHostPerThread.get(i); + galois::Array arr = numEdgesPerHostPerThread[i]; + galois::Array prefixArr = prefixArrayPerHostPerThread[i]; galois::PrefixSum, galois::internal::scan_op, galois::internal::combiner, galois::Array> @@ -261,8 +261,8 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer HostIndexedMap>> pHVEdge{}; PANDO_CHECK(pHVEdge.initialize()); for (uint64_t i = 0; i < numHosts; i++) { - galois::Array prefixArr = prefixArrayPerHostPerThread.get(i); - PANDO_CHECK(fmap(pHVEdge.get(i), initialize, prefixArr[lift(localEdges, size) - 1])); + galois::Array prefixArr = prefixArrayPerHostPerThread[i]; + PANDO_CHECK(fmap(pHVEdge[i], initialize, prefixArr[lift(localEdges, size) - 1])); } // Parallel insert auto PHState = galois::make_tpl(pHVEdge, prefixArrayPerHostPerThread, perThreadEdges); @@ -271,9 +271,9 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer auto [phVec, prefixArrPHPT, newEdge] = PHState; std::uint64_t numHosts = static_cast(pando::getPlaceDims().node.id); for (uint64_t i = 0; i < numHosts; i++) { - galois::Array prefixArr = prefixArrPHPT.get(i); + galois::Array prefixArr = prefixArrPHPT[i]; HostIndexedMap>> PTVec = newEdge[threadID]; - pando::Vector> vert = PTVec.get(i); + pando::Vector> vert = PTVec[i]; uint64_t start; if (threadID) start = prefixArr[threadID - 1]; @@ -281,7 +281,7 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer start = 0; uint64_t end = prefixArr[threadID]; uint64_t idx = 0; - pando::Vector> vec = phVec.get(i); + pando::Vector> vec = phVec[i]; for (auto it = vec.begin() + start; it != vec.begin() + end; it++) { *it = vert.get(idx); idx++; @@ -294,8 +294,8 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer PHState1, numHosts, +[](decltype(PHState1) PHState1, uint64_t host_id, uint64_t) { auto [partEdges, renamePH, pHVEdge] = PHState1; pando::Vector> vec; - pando::Vector> exchangedVec = pHVEdge.get(host_id); - galois::HashTable hashMap = renamePH.get(host_id); + pando::Vector> exchangedVec = pHVEdge[host_id]; + galois::HashTable hashMap = renamePH[host_id]; uint64_t result; for (uint64_t j = 0; j < lift(exchangedVec, size); j++) { pando::GlobalRef> v = exchangedVec.get(j); @@ -305,8 +305,7 @@ partitionEdgesParallely(HostIndexedMap> partitionedVer if (!ret) { return pando::Status::Error; } - pando::GlobalRef> edgeVec = - fmap(partEdges.get(host_id), get, result); + pando::GlobalRef> edgeVec = fmap(partEdges[host_id], get, result); PANDO_CHECK(fmap(edgeVec, append, &v)); } return pando::Status::Success; @@ -333,9 +332,8 @@ template for (pando::Vector vec : threadLocalEdges) { for (EdgeType edge : vec) { auto tgtHost = getPhysical(edge.src, virtualToPhysicalMapping); - pando::GlobalRef>> edges = - partitionedEdges.get(tgtHost); - PANDO_CHECK_RETURN(insertLocalEdgesPerThread(renamePerHost.get(tgtHost), edges, edge)); + pando::GlobalRef>> edges = partitionedEdges[tgtHost]; + PANDO_CHECK_RETURN(insertLocalEdgesPerThread(renamePerHost[tgtHost], edges, edge)); } } } @@ -378,7 +376,7 @@ template PANDO_CHECK(lift(perThreadVerticesPartition[i], initialize)); HostIndexedMap> pVec = perThreadVerticesPartition[i]; for (uint64_t j = 0; j < numHosts; j++) { - PANDO_CHECK(fmap(pVec.get(j), initialize, 0)); + PANDO_CHECK(fmap(pVec[j], initialize, 0)); } } @@ -387,8 +385,8 @@ template PANDO_CHECK(numVerticesPerHostPerThread.initialize()); PANDO_CHECK(prefixArrPerHostPerThread.initialize()); for (std::uint64_t i = 0; i < numHosts; i++) { - PANDO_CHECK(fmap(numVerticesPerHostPerThread.get(i), initialize, lift(localVertices, size))); - PANDO_CHECK(fmap(prefixArrPerHostPerThread.get(i), initialize, lift(localVertices, size))); + PANDO_CHECK(fmap(numVerticesPerHostPerThread[i], initialize, lift(localVertices, size))); + PANDO_CHECK(fmap(prefixArrPerHostPerThread[i], initialize, lift(localVertices, size))); } auto newVec = @@ -401,12 +399,12 @@ template HostIndexedMap> vertVec = perThreadVerticesPT[tid]; for (VertexType v : localVertices) { uint64_t hostID = v2PMap[v.id % v2PMap.size()]; - PANDO_CHECK(fmap(vertVec.get(hostID), pushBack, v)); + PANDO_CHECK(fmap(vertVec[hostID], pushBack, v)); } std::uint64_t numHosts = static_cast(pando::getPlaceDims().node.id); for (uint64_t i = 0; i < numHosts; i++) { - galois::Array arr = prefixArr.get(i); - *(arr.begin() + tid) = lift(vertVec.get(i), size); + galois::Array arr = prefixArr[i]; + *(arr.begin() + tid) = lift(vertVec[i], size); } }); @@ -417,8 +415,8 @@ template using DST_Val = uint64_t; for (uint64_t i = 0; i < numHosts; i++) { - galois::Array arr = numVerticesPerHostPerThread.get(i); - galois::Array prefixArr = prefixArrPerHostPerThread.get(i); + galois::Array arr = numVerticesPerHostPerThread[i]; + galois::Array prefixArr = prefixArrPerHostPerThread[i]; galois::PrefixSum, galois::internal::scan_op, galois::internal::combiner, galois::Array> @@ -431,8 +429,8 @@ template PANDO_CHECK(pHV.initialize()); for (uint64_t i = 0; i < numHosts; i++) { - galois::Array prefixArr = prefixArrPerHostPerThread.get(i); - PANDO_CHECK(fmap(pHV.get(i), initialize, prefixArr[lift(localVertices, size) - 1])); + galois::Array prefixArr = prefixArrPerHostPerThread[i]; + PANDO_CHECK(fmap(pHV[i], initialize, prefixArr[lift(localVertices, size) - 1])); } auto phVec = make_tpl(pHV, prefixArrPerHostPerThread, perThreadVerticesPartition); @@ -441,9 +439,9 @@ template auto [pHV, prefixArrPerHost, PHVertex] = phVec; std::uint64_t numHosts = static_cast(pando::getPlaceDims().node.id); for (uint64_t i = 0; i < numHosts; i++) { - galois::Array prefixArr = prefixArrPerHost.get(i); + galois::Array prefixArr = prefixArrPerHost[i]; HostIndexedMap> PHvec = PHVertex[threadID]; - pando::Vector vert = PHvec.get(i); + pando::Vector vert = PHvec[i]; uint64_t start; if (threadID) start = prefixArr[threadID - 1]; @@ -451,7 +449,7 @@ template start = 0; uint64_t end = prefixArr[threadID]; uint64_t idx = 0; - pando::Vector vec = pHV.get(i); + pando::Vector vec = pHV[i]; for (auto it = vec.begin() + start; it != vec.begin() + end; it++) { *it = vert.get(idx); idx++; diff --git a/include/pando-lib-galois/utility/dist_accumulator.hpp b/include/pando-lib-galois/utility/dist_accumulator.hpp index adb84318..49b86897 100644 --- a/include/pando-lib-galois/utility/dist_accumulator.hpp +++ b/include/pando-lib-galois/utility/dist_accumulator.hpp @@ -124,7 +124,7 @@ class DAccumulator { * @brief add adds the given delta to the local accumulator */ void add(T delta) { - pando::atomicFetchAdd(&localCounters.get(pando::getCurrentPlace().node.id), delta, + pando::atomicFetchAdd(&localCounters[pando::getCurrentPlace().node.id], delta, std::memory_order_release); } /** @@ -137,7 +137,7 @@ class DAccumulator { * @brief subtract subtracts the given delta from the local accumulator */ void subtract(T delta) { - pando::atomicFetchSub(&localCounters.get(pando::getCurrentPlace().node.id), delta, + pando::atomicFetchSub(&localCounters[pando::getCurrentPlace().node.id], delta, std::memory_order_release); } /** diff --git a/src/wmd_graph_importer.cpp b/src/wmd_graph_importer.cpp index 160baaec..1072a01f 100644 --- a/src/wmd_graph_importer.cpp +++ b/src/wmd_graph_importer.cpp @@ -41,7 +41,7 @@ galois::internal::buildVirtualToPhysicalMapping( vTPH[virtualPair.second] = physicalPair.second; // Update the count physicalPair.first += virtualPair.first; - numEdges.get(physicalPair.second) = physicalPair.first; + numEdges[physicalPair.second] = physicalPair.first; // Store back intermediateSort[0] = physicalPair; } diff --git a/test/containers/test_host_indexed_map.cpp b/test/containers/test_host_indexed_map.cpp index 8e9ebd89..f69a337a 100644 --- a/test/containers/test_host_indexed_map.cpp +++ b/test/containers/test_host_indexed_map.cpp @@ -20,8 +20,8 @@ TEST(HostIndexedMap, Init) { } auto f = +[](galois::HostIndexedMap ph, std::uint64_t i, pando::NotificationHandle done) { - EXPECT_EQ(&ph.getLocal(), &ph.get(i)); - EXPECT_EQ(ph.getLocal(), ph.getCurrentNode()); + EXPECT_EQ(ph.getLocal(), ph.get(i)); + EXPECT_EQ(ph.getLocalRef(), ph.getCurrentHost()); done.notify(); }; @@ -67,7 +67,7 @@ TEST(HostIndexedMap, DoAll) { EXPECT_FALSE(ph != ph); for (std::uint64_t i = 0; i < ph.getNumHosts(); i++) { - ph.get(i) = 0xDEADBEEF; + ph[i] = 0xDEADBEEF; } auto g = +[](pando::GlobalRef val) { @@ -80,8 +80,8 @@ TEST(HostIndexedMap, DoAll) { auto f = +[](galois::HostIndexedMap ph, std::uint64_t i, pando::NotificationHandle done) { - EXPECT_EQ(&ph.getLocal(), &ph.get(i)); - EXPECT_EQ(ph.getLocal(), ph.getCurrentNode()); + EXPECT_EQ(ph.getLocal(), ph.get(i)); + EXPECT_EQ(*ph.getLocal(), ph.getCurrentHost()); done.notify(); }; pando::NotificationArray dones; diff --git a/test/containers/test_host_local_storage.cpp b/test/containers/test_host_local_storage.cpp index f90ae4d4..0e9b2ba5 100644 --- a/test/containers/test_host_local_storage.cpp +++ b/test/containers/test_host_local_storage.cpp @@ -20,8 +20,8 @@ TEST(HostLocalStorage, Init) { } auto f = +[](galois::HostLocalStorage ph, std::uint64_t i, pando::NotificationHandle done) { - EXPECT_EQ(&ph.getLocal(), &ph.get(i)); - EXPECT_EQ(ph.getLocal(), ph.getCurrentNode()); + EXPECT_EQ(ph.getLocal(), ph.get(i)); + EXPECT_EQ(ph.getLocalRef(), ph.getCurrentHost()); done.notify(); }; @@ -67,7 +67,7 @@ TEST(HostLocalStorage, DoAll) { EXPECT_FALSE(ph != ph); for (std::uint64_t i = 0; i < ph.getNumHosts(); i++) { - ph.get(i) = 0xDEADBEEF; + ph[i] = 0xDEADBEEF; } auto g = +[](pando::GlobalRef val) { @@ -80,8 +80,8 @@ TEST(HostLocalStorage, DoAll) { auto f = +[](galois::HostLocalStorage ph, std::uint64_t i, pando::NotificationHandle done) { - EXPECT_EQ(&ph.getLocal(), &ph.get(i)); - EXPECT_EQ(ph.getLocal(), ph.getCurrentNode()); + EXPECT_EQ(ph.getLocal(), ph.get(i)); + EXPECT_EQ(ph.getLocalRef(), ph.getCurrentHost()); done.notify(); }; pando::NotificationArray dones; diff --git a/test/containers/test_per_thread.cpp b/test/containers/test_per_thread.cpp index 8d02c9ef..bf34bac3 100644 --- a/test/containers/test_per_thread.cpp +++ b/test/containers/test_per_thread.cpp @@ -265,7 +265,7 @@ TEST(PerThreadVector, HostLocalStorageVectorAppend) { for (std::int16_t i = 0; i < static_cast(phv.getNumHosts()); i++) { auto place = pando::Place{pando::NodeIndex{i}, pando::anyPod, pando::anyCore}; - auto ref = phv.get(i); + auto ref = phv[i]; EXPECT_EQ(fmap(ref, initialize, 0, place, pando::MemoryType::Main), pando::Status::Success); } diff --git a/test/containers/test_thread_local_storage.cpp b/test/containers/test_thread_local_storage.cpp index 812fd215..caae41d4 100644 --- a/test/containers/test_thread_local_storage.cpp +++ b/test/containers/test_thread_local_storage.cpp @@ -29,7 +29,7 @@ TEST(ThreadLocalStorage, Init) { } auto f = +[](galois::ThreadLocalStorage tls, std::uint64_t i, pando::NotificationHandle done) { - EXPECT_EQ(pando::localityOf(&tls.getLocal()), pando::localityOf(&tls.get(i))); + EXPECT_EQ(pando::localityOf(tls.getLocal()), pando::localityOf(tls.get(i))); done.notify(); }; @@ -73,7 +73,7 @@ TEST(ThreadLocalStorage, DoAll) { EXPECT_FALSE(tls != tls); for (std::uint64_t i = 0; i < tls.getNumThreads(); i++) { - tls.get(i) = 0xDEADBEEF; + tls[i] = 0xDEADBEEF; } auto g = +[](galois::ThreadLocalStorage tls, pando::GlobalRef val) { @@ -91,7 +91,7 @@ TEST(ThreadLocalStorage, DoAll) { auto place = pando::Place(pando::getCurrentPlace().node, pando::PodIndex{0, 0}, pando::CoreIndex{0, 0}); const std::uint64_t threadIdx = tls.getThreadIdxFromPlace(place, pando::ThreadIndex(0)); - EXPECT_EQ(tls.getLocal(), threadIdx); + EXPECT_EQ(tls.getLocalRef(), threadIdx); done.notify(); }; pando::NotificationArray dones;