Skip to content

Commit

Permalink
switch to non-atomic variable
Browse files Browse the repository at this point in the history
  • Loading branch information
meyerzinn committed Apr 16, 2024
1 parent 8985cc5 commit d5119f7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions libgalois/include/galois/graphs/LS_LC_CSR_Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ class LS_LC_CSR_Graph : private boost::noncopyable {
CacheLinePaddedArr>
m_pfx{&m_vertices[0], &m_pfx_sum_cache[0]};

alignas(hardware_destructive_interference_size)
std::atomic<bool> m_prefix_valid = ATOMIC_VAR_INIT(false);
bool m_prefix_valid = false;

void resetPrefixSum() {
m_pfx_sum_cache.resize(m_vertices.size());
Expand All @@ -122,7 +121,7 @@ class LS_LC_CSR_Graph : private boost::noncopyable {
// Compute the prefix sum using the two level method
void computePrefixSum() {
m_pfx.computePrefixSum(m_vertices.size());
m_prefix_valid.store(true, std::memory_order_release);
m_prefix_valid = true;
}

// returns a reference to the metadata for the pointed-to edge
Expand Down Expand Up @@ -341,7 +340,7 @@ class LS_LC_CSR_Graph : private boost::noncopyable {
vertex_meta.begin = new_begin;
vertex_meta.end = new_end;

m_prefix_valid.store(false, std::memory_order_release);
m_prefix_valid = false;
}

// Performs the compaction algorithm by copying any vertices left in buffer 0
Expand Down Expand Up @@ -423,13 +422,13 @@ class LS_LC_CSR_Graph : private boost::noncopyable {
* array
*/
uint64_t operator[](uint64_t n) {
if (!m_prefix_valid.load(std::memory_order_acquire))
if (!m_prefix_valid)
computePrefixSum();
return m_pfx_sum_cache[n];
}

std::vector<uint64_t> const& getEdgePrefixSum() {
if (!m_prefix_valid.load(std::memory_order_acquire))
if (!m_prefix_valid)
computePrefixSum();
return m_pfx_sum_cache;
}
Expand Down

0 comments on commit d5119f7

Please sign in to comment.