Skip to content

Commit

Permalink
align atomics to cache line
Browse files Browse the repository at this point in the history
  • Loading branch information
meyerzinn committed Mar 21, 2024
1 parent 68ef517 commit dbbaa02
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libgalois/include/galois/graphs/LS_LC_CSR_Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <iterator>
#include <cstddef>
#include <atomic>
#include <new>

#include <boost/range/iterator_range_core.hpp>
#include <boost/range/counting_range.hpp>
Expand All @@ -32,6 +33,12 @@
#include "galois/config.h"
#include "galois/LargeVector.h"

#ifdef __cpp_lib_hardware_interference_size
using std::hardware_destructive_interference_size;
#else
constexpr std::size_t hardware_destructive_interference_size = 64;
#endif

namespace galois::graphs {

/**
Expand Down Expand Up @@ -74,8 +81,11 @@ class LS_LC_CSR_Graph : private boost::noncopyable {
std::vector<VertexMetadata> m_vertices;
LargeVector<EdgeMetadata> m_edges[2];
SpinLock m_edges_lock; // guards resizing of edges vectors
std::atomic_uint64_t m_edges_tail = ATOMIC_VAR_INIT(0);
std::atomic_uint64_t m_holes = ATOMIC_VAR_INIT(0);

alignas(hardware_destructive_interference_size) std::atomic_uint64_t
m_edges_tail = ATOMIC_VAR_INIT(0);
alignas(hardware_destructive_interference_size) std::atomic_uint64_t m_holes =
ATOMIC_VAR_INIT(0);

// returns a reference to the metadata for the pointed-to edge
inline EdgeMetadata& getEdgeMetadata(EdgeHandle const& handle) {
Expand Down

0 comments on commit dbbaa02

Please sign in to comment.