20 #ifndef GALOIS_LARGEARRAY_H
21 #define GALOIS_LARGEARRAY_H
26 #include <boost/archive/binary_iarchive.hpp>
27 #include <boost/archive/binary_oarchive.hpp>
28 #include <boost/serialization/binary_object.hpp>
29 #include <boost/serialization/array.hpp>
30 #include <boost/serialization/serialization.hpp>
31 #include <boost/serialization/split_member.hpp>
33 #include "galois/config.h"
73 const static size_t value =
sizeof(T);
101 m_data =
reinterpret_cast<T*
>(m_realdata.get());
108 friend class boost::serialization::access;
109 template <
typename Archive>
110 void save(Archive& ar,
const unsigned int)
const {
119 ar << boost::serialization::make_binary_object(m_data, m_size *
sizeof(T));
128 template <
typename Archive>
129 void load(Archive& ar,
const unsigned int) {
144 ar >> boost::serialization::make_binary_object(m_data, m_size *
sizeof(T));
156 BOOST_SERIALIZATION_SPLIT_MEMBER()
162 LargeArray(
void* d,
size_t s) : m_data(reinterpret_cast<T*>(d)), m_size(s) {}
167 std::swap(this->m_realdata, o.m_realdata);
168 std::swap(this->m_data, o.m_data);
169 std::swap(this->m_size, o.m_size);
173 std::swap(this->m_realdata, o.m_realdata);
174 std::swap(this->m_data, o.m_data);
175 std::swap(this->m_size, o.m_size);
188 std::swap(lhs.m_realdata, rhs.m_realdata);
189 std::swap(lhs.m_data, rhs.m_data);
190 std::swap(lhs.m_size, rhs.m_size);
239 template <
typename RangeArrayTy>
241 RangeArrayTy& threadRanges) {
246 threadRanges,
sizeof(T));
248 m_size = numberOfElements;
249 m_data =
reinterpret_cast<T*
>(m_realdata.get());
253 template <
typename... Args>
255 for (T *ii = m_data, *ei = m_data + m_size; ii != ei; ++ii)
256 new (ii) T(std::forward<Args>(args)...);
259 template <
typename... Args>
261 new (&m_data[n]) T(std::forward<Args>(args)...);
265 template <
typename... Args>
283 template <
typename U = T>
288 template <
typename U = T>
306 friend class boost::serialization::access;
307 template <
typename Archive>
308 void serialize(Archive&,
const unsigned int)
const {}
336 template <
typename AnyTy>
348 template <
typename RangeArrayTy>
351 template <
typename... Args>
353 template <
typename... Args>
355 template <
typename... Args>
void destroy()
Definition: LargeArray.h:359
size_type size() const
Definition: LargeArray.h:338
void set(difference_type x, const_reference v)
Definition: LargeArray.h:197
friend void swap(LargeArray &lhs, LargeArray &rhs)
Definition: LargeArray.h:187
LAptr largeMallocBlocked(size_t bytes, unsigned numThreads)
Definition: NumaMem.cpp:188
void destroyAt(size_type)
Definition: LargeArray.h:360
void raw_value_type
Definition: LargeArray.h:318
void destroy()
Definition: LargeArray.h:277
void set(difference_type, AnyTy)
Definition: LargeArray.h:337
LAptr largeMallocFloating(size_t bytes)
Definition: NumaMem.cpp:180
pointer iterator
Definition: LargeArray.h:326
const_pointer const_iterator
Definition: LargeArray.h:68
std::enable_if_t< std::is_scalar< U >::value > destroyAt(size_type)
Definition: LargeArray.h:289
iterator end()
Definition: LargeArray.h:341
pointer data()
Definition: LargeArray.h:293
T value_type
Definition: LargeArray.h:60
value_type * pointer
Definition: LargeArray.h:65
iterator begin()
Definition: LargeArray.h:339
const_reference operator[](size_type) const
Definition: LargeArray.h:335
T raw_value_type
Definition: LargeArray.h:59
const_iterator end() const
Definition: LargeArray.h:342
void create(size_type n, Args &&...args)
Allocate and construct.
Definition: LargeArray.h:266
void gDebug(Args &&...GALOIS_USED_ONLY_IN_DEBUG(args))
Prints a debug string from a sequence of things; prints nothing if NDEBUG is defined.
Definition: gIO.h:72
ptrdiff_t difference_type
Definition: LargeArray.h:62
void allocateInterleaved(size_type)
Definition: LargeArray.h:344
static const size_t value
Definition: LargeArray.h:73
Definition: LargeArray.h:72
value_type reference
Definition: LargeArray.h:322
void allocateLocal(size_type n)
Allocates using Thread Local memory policy.
Definition: LargeArray.h:220
const_reference at(difference_type x) const
Definition: LargeArray.h:193
~LargeArray()
Definition: LargeArray.h:182
void deallocate()
Definition: LargeArray.h:358
void construct(Args &&...)
Definition: LargeArray.h:352
LargeArray(LargeArray &&o)
Definition: LargeArray.h:166
AllocType
Definition: LargeArray.h:77
const_iterator begin() const
Definition: LargeArray.h:340
Definition: LargeArray.h:77
const_reference at(difference_type) const
Definition: LargeArray.h:333
void allocateSpecified(size_type, RangeArrayTy)
Definition: LargeArray.h:349
const_iterator end() const
Definition: LargeArray.h:202
void allocateInterleaved(size_type n)
[allocatefunctions] Allocates interleaved across NUMA (memory) nodes.
Definition: LargeArray.h:206
reference at(difference_type)
Definition: LargeArray.h:334
LargeArray & operator=(LargeArray &&o)
Definition: LargeArray.h:172
value_type & reference
Definition: LargeArray.h:63
value_type * const_pointer
Definition: LargeArray.h:325
pointer iterator
Definition: LargeArray.h:67
LAptr largeMallocLocal(size_t bytes)
Definition: NumaMem.cpp:172
unsigned int activeThreads
Definition: Threads.cpp:26
void allocateFloating(size_type)
Definition: LargeArray.h:347
Definition: LargeArray.h:77
value_type const_reference
Definition: LargeArray.h:323
void create(size_type, Args &&...)
Definition: LargeArray.h:356
LAptr largeMallocSpecified(size_t bytes, uint32_t numThreads, RangeArrayTy &threadRanges, size_t elementSize)
Allocates pages for some specified number of bytes, then does NUMA page faulting based on a specified...
Definition: NumaMem.cpp:213
Large array of objects with proper specialization for void type and supporting various allocation and...
Definition: LargeArray.h:53
friend void swap(LargeArray &, LargeArray &)
Definition: LargeArray.h:316
LargeArray()
Definition: LargeArray.h:164
reference at(difference_type x)
Definition: LargeArray.h:194
reference operator[](size_type x)
Definition: LargeArray.h:196
LAptr largeMallocInterleaved(size_t bytes, unsigned numThreads)
Definition: NumaMem.cpp:150
pointer data()
Definition: LargeArray.h:363
LargeArray(void *, size_t)
Definition: LargeArray.h:311
std::enable_if_t<!std::is_scalar< U >::value > destroyAt(size_type n)
Definition: LargeArray.h:284
std::enable_if_t<!std::is_scalar< internal::Val_ty< I > >::value > destroy(I first, I last)
Definition: ParallelSTL.h:300
const value_type & const_reference
Definition: LargeArray.h:64
void allocateLocal(size_type, bool=true)
Definition: LargeArray.h:346
void constructAt(size_type n, Args &&...args)
Definition: LargeArray.h:260
size_type size() const
Definition: LargeArray.h:198
std::unique_ptr< void, internal::largeFreer > LAptr
Definition: NumaMem.h:39
const_pointer data() const
Definition: LargeArray.h:292
void allocateBlocked(size_type n)
Allocates using blocked memory policy.
Definition: LargeArray.h:213
iterator end()
Definition: LargeArray.h:201
size_t size_type
Definition: LargeArray.h:61
static const bool has_value
Definition: LargeArray.h:69
const_iterator begin() const
Definition: LargeArray.h:200
const_reference operator[](size_type x) const
Definition: LargeArray.h:195
ptrdiff_t difference_type
Definition: LargeArray.h:321
const_pointer data() const
Definition: LargeArray.h:362
void allocate(size_type n, AllocType t)
Definition: LargeArray.h:78
const_pointer const_iterator
Definition: LargeArray.h:327
void * value_type
Definition: LargeArray.h:319
void allocateFloating(size_type n)
Allocates using no memory policy (no pre alloc)
Definition: LargeArray.h:227
void deallocate()
Definition: LargeArray.h:271
void construct(Args &&...args)
[allocatefunctions]
Definition: LargeArray.h:254
Definition: LargeArray.h:77
Definition: LargeArray.h:77
const value_type * const_pointer
Definition: LargeArray.h:66
void allocateSpecified(size_type numberOfElements, RangeArrayTy &threadRanges)
Allocate memory to threads based on a provided array specifying which threads receive which elements ...
Definition: LargeArray.h:240
value_type * pointer
Definition: LargeArray.h:324
iterator begin()
Definition: LargeArray.h:199
void allocateBlocked(size_type)
Definition: LargeArray.h:345
size_t size_type
Definition: LargeArray.h:320
void constructAt(size_type, Args &&...)
Definition: LargeArray.h:354