Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Serialize.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
27 #ifndef GALOIS_RUNTIME_SERIALIZE_H
28 #define GALOIS_RUNTIME_SERIALIZE_H
29 
30 #include <type_traits>
31 #include <ostream>
32 #include <vector>
33 #include <deque>
34 #include <string>
35 #include <cassert>
36 #include <tuple>
37 
38 #include <boost/mpl/has_xxx.hpp>
40 
41 #include <galois/gdeque.h>
42 #include <galois/DynamicBitset.h>
43 #include <galois/AtomicWrapper.h>
45 #include "galois/CopyableTuple.h"
46 #include "galois/Bag.h"
47 
48 namespace galois {
49 namespace runtime {
50 
51 class DeSerializeBuffer; // forward declaration for friend declaration
52 
58  friend DeSerializeBuffer;
59 
61  // using vTy = std::vector<uint8_t>;
64  vTy bufdata;
65 
66 public:
68  SerializeBuffer() = default;
70  SerializeBuffer(SerializeBuffer&& rhs) = default;
74  SerializeBuffer(const char* d, unsigned len) : bufdata(d, d + len) {}
75 
77  inline void push(const char c) { bufdata.push_back(c); }
78 
80  void insert(const uint8_t* c, size_t bytes) {
81  bufdata.insert(bufdata.end(), c, c + bytes);
82  }
83 
86  void insertAt(const uint8_t* c, size_t bytes, size_t offset) {
87  std::copy_n(c, bytes, bufdata.begin() + offset);
88  }
89 
97  size_t encomber(size_t bytes) {
98  size_t retval = bufdata.size();
99  bufdata.resize(retval + bytes);
100  return retval;
101  }
102 
103  void resize(size_t bytes) { bufdata.resize(bytes); }
104 
110  void reserve(size_t s) { bufdata.reserve(bufdata.size() + s); }
111 
113  const uint8_t* linearData() const { return bufdata.data(); }
115  vTy& getVec() { return bufdata; }
116 
118  vTy::const_iterator begin() const { return bufdata.cbegin(); }
120  vTy::const_iterator end() const { return bufdata.cend(); }
121 
123 
125  size_type size() const { return bufdata.size(); }
126 
129  void print(std::ostream& o) const {
130  o << "<{" << std::hex;
131  for (auto& i : bufdata)
132  o << (unsigned int)i << " ";
133  o << std::dec << "}>";
134  }
135 
137  friend std::ostream& operator<<(std::ostream& os, const SerializeBuffer& b) {
138  b.print(os);
139  return os;
140  }
141 };
142 
149  friend SerializeBuffer;
151  // using vTy = std::vector<uint8_t>;
154  vTy bufdata;
155  int offset;
156 
157 public:
159  DeSerializeBuffer() : offset(0) {}
165  DeSerializeBuffer(vTy&& v, uint32_t start = 0)
166  : bufdata(std::move(v)), offset(start) {}
167 
170  explicit DeSerializeBuffer(vTy& data) {
171  bufdata.swap(data);
172  offset = 0;
173  }
174 
179  explicit DeSerializeBuffer(int count) : bufdata(count), offset(0) {}
180 
185  template <typename Iter>
186  DeSerializeBuffer(Iter b, Iter e) : bufdata(b, e), offset{0} {}
187 
191  explicit DeSerializeBuffer(SerializeBuffer&& buf) : offset(0) {
192  bufdata.swap(buf.bufdata);
193  }
194 
199 
204  void reset(int count) {
205  offset = 0;
206  bufdata.resize(count);
207  }
208 
210  unsigned getOffset() const { return offset; }
212  void setOffset(unsigned off) {
213  assert(off <= size());
214  offset = off;
215  }
216 
218  unsigned size() const { return bufdata.size(); }
219 
222  bool empty() const { return bufdata.empty(); }
223 
225  unsigned char pop() { return bufdata.at(offset++); }
226 
229  void pop_back(unsigned x) { bufdata.resize(bufdata.size() - x); }
230 
237  void extract(uint8_t* dst, size_t num) {
238  memcpy(dst, &bufdata[offset], num);
239  offset += num;
240  }
241 
244  vTy& getVec() { return bufdata; }
245 
247  void* linearData() { return &bufdata[0]; }
248 
251  const uint8_t* r_linearData() const { return &bufdata[offset]; }
254  size_t r_size() const { return bufdata.size() - offset; }
255 
258  bool atAlignment(size_t a) { return (uintptr_t)r_linearData() % a == 0; }
259 
262  void print(std::ostream& o) const {
263  o << "<{(" << offset << ") " << std::hex;
264  for (auto ii = bufdata.begin(), ee = bufdata.end(); ii != ee; ++ii)
265  o << (unsigned int)*ii << " ";
266  o << std::dec << "}>";
267  }
268 
270  friend std::ostream& operator<<(std::ostream& os,
271  const DeSerializeBuffer& buf) {
272  buf.print(os);
273  return os;
274  }
275 };
276 
277 namespace internal {
278 
285 template <typename T>
286 __attribute__((always_inline)) constexpr size_t
287 gSizedObj(const T&,
288  typename std::enable_if<is_memory_copyable<T>::value>::type* = 0) {
289  return sizeof(T);
290 }
291 
300 template <typename T>
301 __attribute__((always_inline)) constexpr size_t
302 gSizedObj(const T&,
303  typename std::enable_if<!is_memory_copyable<T>::value>::type* = 0,
304  typename std::enable_if<has_serialize<T>::value>::type* = 0) {
305  return sizeof(uintptr_t);
306 }
307 
314 template <typename T1, typename T2>
315 inline size_t gSizedObj(const std::pair<T1, T2>& data) {
316  return gSizedObj(data.first) + gSizedObj(data.second);
317 }
318 
323 template <typename Seq>
324 size_t gSizedSeq(const Seq& seq) {
325  typename Seq::size_type size = seq.size();
326  typedef typename Seq::value_type T;
327  size_t tsize = std::conditional<
328  is_memory_copyable<T>::value, std::integral_constant<size_t, sizeof(T)>,
329  std::integral_constant<size_t, sizeof(uintptr_t)>>::type::value;
330  return sizeof(size) + tsize * size;
331 }
332 
339 template <typename T, typename Alloc>
340 inline size_t gSizedObj(const std::vector<T, Alloc>& data) {
341  return gSizedSeq(data);
342 }
343 
350 template <typename T>
351 inline size_t gSizedObj(const galois::PODResizeableArray<T>& data) {
352  return gSizedSeq(data);
353 }
354 
361 template <typename T, typename Alloc>
362 inline size_t gSerializeObj(const std::deque<T, Alloc>& data) {
363  return gSizedSeq(data);
364 }
365 
372 template <typename T, unsigned CS>
373 inline size_t gSizedObj(const galois::gdeque<T, CS>& data) {
374  return gSizedSeq(data);
375 }
376 
383 template <typename A>
384 inline size_t
385 gSizedObj(const std::basic_string<char, std::char_traits<char>, A>& data) {
386  return data.length() + 1;
387 }
388 
394 inline size_t gSizedObj(const SerializeBuffer& data) { return data.size(); }
395 
401 inline size_t gSizedObj(const DeSerializeBuffer& rbuf) { return rbuf.r_size(); }
402 
408 template <typename T>
409 inline size_t gSizedObj(const galois::InsertBag<T>& bag) {
410  return bag.size();
411 }
412 
417 inline size_t adder() { return 0; }
423 inline size_t adder(size_t a) { return a; }
428 template <typename... Args>
429 inline size_t adder(size_t a, size_t b, Args&&... args) {
430  return a + b + adder(args...);
431 }
432 
433 } // namespace internal
434 
441 template <typename... Args>
442 static inline size_t gSized(Args&&... args) {
443  return internal::adder(internal::gSizedObj(args)...);
444 }
445 
447 // Serialize support
449 
450 namespace internal {
451 
458 template <typename T>
459 inline void gSerializeObj(
460  SerializeBuffer& buf, const T& data,
461  typename std::enable_if<is_memory_copyable<T>::value>::type* = 0) {
462  uint8_t* pdata = (uint8_t*)&data;
463  buf.insert(pdata, sizeof(T));
464 }
465 
473 template <typename T>
474 inline void
475 gSerializeObj(SerializeBuffer& buf, const T& data,
476  typename std::enable_if<!is_memory_copyable<T>::value>::type* = 0,
477  typename std::enable_if<has_serialize<T>::value>::type* = 0) {
478  data.serialize(buf);
479 }
480 
487 template <typename T1, typename T2>
488 inline void gSerializeObj(SerializeBuffer& buf, const std::pair<T1, T2>& data) {
489  gSerialize(buf, data.first, data.second);
490 }
491 
499 template <typename T1, typename T2>
500 inline void gSerializeObj(SerializeBuffer& buf,
501  const galois::Pair<T1, T2>& data) {
502  if (is_memory_copyable<T1>::value && is_memory_copyable<T2>::value) {
503  // do memcpy
504  buf.insert((uint8_t*)&data, sizeof(data));
505  } else {
506  // serialize each individually
507  gSerialize(buf, data.first, data.second);
508  }
509 }
510 
519 template <typename T1, typename T2, typename T3>
520 inline void gSerializeObj(SerializeBuffer& buf,
521  const galois::TupleOfThree<T1, T2, T3>& data) {
522  if (is_memory_copyable<T1>::value && is_memory_copyable<T2>::value &&
523  is_memory_copyable<T3>::value) {
524  // do memcpy
525  buf.insert((uint8_t*)&data, sizeof(data));
526  } else {
527  // serialize each individually
528  gSerialize(buf, data.first, data.second, data.third);
529  }
530 }
531 
539 template <typename T>
540 inline void gSerializeObj(SerializeBuffer& buf,
541  const galois::CopyableAtomic<T>& data) {
542  T temp = data.load();
543  buf.insert((uint8_t*)(&temp), sizeof(T));
544 }
545 
552 template <typename A>
553 inline void
554 gSerializeObj(SerializeBuffer& buf,
555  const std::basic_string<char, std::char_traits<char>, A>& data) {
556  buf.insert((uint8_t*)data.data(), data.length() + 1);
557 }
558 
559 // Forward declaration of vector serialize
560 template <typename T, typename Alloc>
561 inline void gSerializeObj(SerializeBuffer& buf,
562  const std::vector<T, Alloc>& data);
563 
571 template <typename Seq>
572 void gSerializeSeq(SerializeBuffer& buf, const Seq& seq) {
573  typename Seq::size_type size = seq.size();
574  gSerializeObj(buf, size);
575  for (auto& o : seq)
576  gSerializeObj(buf, o);
577 }
578 
585 template <typename Seq>
586 void gSerializeLinearSeq(SerializeBuffer& buf, const Seq& seq) {
587  typename Seq::size_type size = seq.size();
588  typedef typename Seq::value_type T;
589  size_t tsize = sizeof(T);
590  // buf.reserve(size * tsize + sizeof(size));
591  gSerializeObj(buf, size);
592  buf.insert((uint8_t*)seq.data(), size * tsize);
593 }
594 
602 template <typename T, typename Alloc>
603 inline void gSerializeObj(SerializeBuffer& buf,
604  const std::vector<T, Alloc>& data) {
605  if (is_memory_copyable<T>::value)
606  gSerializeLinearSeq(buf, data);
607  else
608  gSerializeSeq(buf, data);
609 }
610 
618 template <typename T>
619 inline void gSerializeObj(SerializeBuffer& buf,
620  const galois::PODResizeableArray<T>& data) {
621  gSerializeLinearSeq(buf, data);
622 }
623 
630 template <typename T, typename Alloc>
631 inline void gSerializeObj(SerializeBuffer& buf,
632  const std::deque<T, Alloc>& data) {
633  gSerializeSeq(buf, data);
634 }
635 
642 template <typename T, unsigned CS>
643 inline void gSerializeObj(SerializeBuffer& buf,
644  const galois::gdeque<T, CS>& data) {
645  gSerializeSeq(buf, data);
646 }
647 
654 inline void gSerializeObj(SerializeBuffer& buf, const SerializeBuffer& data) {
655  buf.insert(data.linearData(), data.size());
656 }
657 
664 inline void gSerializeObj(SerializeBuffer& buf, const DeSerializeBuffer& rbuf) {
665  // buf.reserve(rbuf.r_size());
666  buf.insert(rbuf.r_linearData(), rbuf.r_size());
667 }
668 
675 inline void gSerializeObj(SerializeBuffer& buf,
676  const galois::DynamicBitSet& data) {
677  gSerializeObj(buf, data.size());
678  gSerializeObj(buf, data.get_vec());
679 }
680 
681 // we removed the functions in Bag.h that this function requires, so this
682 // won't work
683 #if 0
684 
692 template<typename T>
693 inline void gSerializeObj(SerializeBuffer& buf, galois::InsertBag<T>& bag){
694  gSerializeObj(buf, bag.size());
695  auto headerVec = bag.getHeads();
696  size_t totalSize = 0;
697  for(auto h : headerVec){
698  size_t localSize = (h->dend - h->dbegin);
699  buf.insert((uint8_t*)h->dbegin, localSize*sizeof(T));
700  totalSize += (h->dend - h->dbegin);
701  }
702 
703  assert(totalSize == bag.size());
704  bag.clear();
705 }
706 #endif
707 } // namespace internal
708 
713 template <typename T>
714 struct LazyRef {
715  size_t off;
716 };
717 
723 template <typename Seq>
725 gSerializeLazySeq(SerializeBuffer& buf, unsigned num, Seq*) {
727  "Not POD Sequence");
728  typename Seq::size_type size = num;
729  internal::gSerializeObj(buf, size);
730  size_t tsize = sizeof(typename Seq::value_type);
731  return LazyRef<typename Seq::value_type>{buf.encomber(tsize * num)};
732 }
733 
744 template <typename Ty>
745 static inline void gSerializeLazy(SerializeBuffer& buf, LazyRef<Ty> r,
746  unsigned item, Ty&& data) {
747  size_t off = r.off + sizeof(Ty) * item;
748  uint8_t* pdata = (uint8_t*)&data;
749  buf.insertAt(pdata, sizeof(Ty), off);
750 }
751 
755 template <typename T1, typename... Args>
756 static inline void gSerialize(SerializeBuffer& buf, T1&& t1, Args&&... args) {
757  buf.reserve(gSized(t1, args...));
758  internal::gSerializeObj(buf, std::forward<T1>(t1));
759  gSerialize(buf, std::forward<Args>(args)...);
760 }
761 
765 static inline void gSerialize(SerializeBuffer&) {}
766 
768 // Deserialize support
770 
771 namespace internal {
772 
779 template <typename T>
780 void gDeserializeObj(
781  DeSerializeBuffer& buf, T& data,
782  typename std::enable_if<is_memory_copyable<T>::value>::type* = 0) {
783  uint8_t* pdata = (uint8_t*)&data;
784  buf.extract(pdata, sizeof(T));
785 }
786 
793 template <typename T>
794 void gDeserializeObj(
795  DeSerializeBuffer& buf, T& data,
796  typename std::enable_if<!is_memory_copyable<T>::value>::type* = 0,
797  typename std::enable_if<has_serialize<T>::value>::type* = 0) {
798  data.deserialize(buf);
799 }
800 
807 template <typename T1, typename T2>
808 void gDeserializeObj(DeSerializeBuffer& buf, std::pair<T1, T2>& data) {
809  gDeserialize(buf, data.first, data.second);
810 }
811 
819 template <typename T1, typename T2>
820 inline void gDeserializeObj(DeSerializeBuffer& buf,
821  galois::Pair<T1, T2>& data) {
822  if (is_memory_copyable<T1>::value && is_memory_copyable<T2>::value) {
823  // do memcpy
824  buf.extract((uint8_t*)&data, sizeof(data));
825  } else {
826  // deserialize each individually
827  gDeserialize(buf, data.first, data.second);
828  }
829 }
830 
839 template <typename T1, typename T2, typename T3>
840 inline void gDeserializeObj(DeSerializeBuffer& buf,
842  if (is_memory_copyable<T1>::value && is_memory_copyable<T2>::value &&
843  is_memory_copyable<T3>::value) {
844  // do memcpy straight to data
845  buf.extract((uint8_t*)&data, sizeof(data));
846  } else {
847  // deserialize each individually
848  gDeserialize(buf, data.first, data.second, data.third);
849  }
850 }
851 
859 template <typename T>
860 void gDeserializeObj(DeSerializeBuffer& buf, galois::CopyableAtomic<T>& data) {
861  T tempData;
862  uint8_t* pointerToTemp = (uint8_t*)&tempData;
863  buf.extract(pointerToTemp, sizeof(T));
864  data.store(tempData);
865 }
866 
867 namespace {
868 template <int...>
869 struct seq {};
870 template <int N, int... S>
871 struct gens : gens<N - 1, N - 1, S...> {};
872 template <int... S>
873 struct gens<0, S...> {
874  typedef seq<S...> type;
875 };
876 } // namespace
877 
884 template <typename... T, int... S>
885 void gDeserializeTuple(DeSerializeBuffer& buf, std::tuple<T...>& data,
886  seq<S...>) {
887  gDeserialize(buf, std::get<S>(data)...);
888 }
889 
896 template <typename... T>
897 void gDeserializeObj(DeSerializeBuffer& buf, std::tuple<T...>& data) {
898  return gDeserializeTuple(buf, data, typename gens<sizeof...(T)>::type());
899 }
900 
907 template <typename A>
908 inline void
909 gDeserializeObj(DeSerializeBuffer& buf,
910  std::basic_string<char, std::char_traits<char>, A>& data) {
911  char c = buf.pop();
912  while (c != '\0') {
913  data.push_back(c);
914  c = buf.pop();
915  };
916 }
917 
918 // Forward declaration of vector deserialize
919 template <typename T, typename Alloc>
920 void gDeserializeObj(DeSerializeBuffer& buf, std::vector<T, Alloc>& data);
921 
928 template <typename Seq>
929 void gDeserializeSeq(DeSerializeBuffer& buf, Seq& seq) {
930  seq.clear();
931  typename Seq::size_type size;
932  gDeserializeObj(buf, size);
933  while (size--) {
934  typename Seq::value_type v;
935  gDeserializeObj(buf, v);
936  seq.push_back(v);
937  }
938 }
939 
946 template <typename Seq>
947 void gDeserializeLinearSeq(DeSerializeBuffer& buf, Seq& seq) {
948  typedef typename Seq::value_type T;
949  // seq.clear();
950  typename Seq::size_type size;
951  gDeserializeObj(buf, size);
952  // If the alignment is right, cast to a T array and insert
953  if (buf.atAlignment(alignof(T))) {
954  T* src = (T*)buf.r_linearData();
955  seq.assign(src, &src[size]);
956  buf.setOffset(buf.getOffset() + size * sizeof(T));
957  } else {
958  seq.resize(size);
959  buf.extract((uint8_t*)seq.data(), size * sizeof(T));
960  }
961 }
962 
969 template <typename T, typename Alloc>
970 void gDeserializeObj(DeSerializeBuffer& buf, std::deque<T, Alloc>& data) {
971  gDeserializeSeq(buf, data);
972 }
973 
981 template <typename T, typename Alloc>
982 void gDeserializeObj(DeSerializeBuffer& buf, std::vector<T, Alloc>& data) {
983  if (is_memory_copyable<T>::value)
984  gDeserializeLinearSeq(buf, data);
985  else
986  gDeserializeSeq(buf, data);
987 }
988 
995 template <typename T>
996 void gDeserializeObj(DeSerializeBuffer& buf,
998  gDeserializeLinearSeq(buf, data);
999 }
1000 
1007 template <typename T, unsigned CS>
1008 void gDeserializeObj(DeSerializeBuffer& buf, galois::gdeque<T, CS>& data) {
1009  gDeserializeSeq(buf, data);
1010 }
1011 
1018 inline void gDeserializeObj(DeSerializeBuffer& buf,
1019  galois::DynamicBitSet& data) {
1020  size_t size = 0;
1021  gDeserializeObj(buf, size);
1022  data.resize(size);
1023  gDeserializeObj(buf, data.get_vec());
1024 }
1025 
1026 } // namespace internal
1027 
1031 template <typename T1, typename... Args>
1032 void gDeserialize(DeSerializeBuffer& buf, T1&& t1, Args&&... args) {
1033  internal::gDeserializeObj(buf, std::forward<T1>(t1));
1034  gDeserialize(buf, std::forward<Args>(args)...);
1035 }
1036 
1041 
1051 template <typename Iter, typename T>
1052 auto gDeserializeRaw(Iter iter, T& data) -> decltype(
1053  std::declval<typename std::enable_if<is_memory_copyable<T>::value>::type>(),
1054  Iter()) {
1055  unsigned char* pdata = (unsigned char*)&data;
1056  for (size_t i = 0; i < sizeof(T); ++i)
1057  pdata[i] = *iter++;
1058  return iter;
1059 }
1060 
1061 } // namespace runtime
1062 } // namespace galois
1063 
1064 #endif // SERIALIZE DEF end
iterator end()
Definition: PODResizeableArray.h:107
reference at(size_type __n)
Definition: PODResizeableArray.h:152
friend std::ostream & operator<<(std::ostream &os, const DeSerializeBuffer &buf)
Operator for printing deserialize buffer.
Definition: Serialize.h:270
void * linearData()
Get a pointer to the underlying data of the deserialize buffer.
Definition: Serialize.h:247
void push_back(const _Tp &value)
Definition: PODResizeableArray.h:177
size_t size_type
Definition: PODResizeableArray.h:47
void push(const char c)
Push a character onto the serialize buffer.
Definition: Serialize.h:77
DeSerializeBuffer(vTy &data)
Constructor that takes an existing vector to use as the deserialize buffer.
Definition: Serialize.h:170
const_iterator cbegin() const
Definition: PODResizeableArray.h:119
Defines particular traits used by the distributed runtime.
void resize(size_t n)
Definition: PODResizeableArray.h:142
Concurrent dynamically allocated bitset.
Definition: libgalois/include/galois/DynamicBitset.h:47
bool empty() const
Definition: PODResizeableArray.h:127
Buffer for serialization of data.
Definition: Serialize.h:56
void reserve(size_t s)
Reserve more space in the serialize buffer.
Definition: Serialize.h:110
size_t r_size() const
Get the remaining size of the deserialize buffer (as determined by offset)
Definition: Serialize.h:254
void insert(iterator GALOIS_USED_ONLY_IN_DEBUG(position), InputIterator first, InputIterator last)
Definition: PODResizeableArray.h:183
T1 first
first element
Definition: CopyableTuple.h:66
const_pointer const_iterator
Definition: PODResizeableArray.h:54
SerializeBuffer()=default
default constructor
Contains the DynamicBitSet class and most of its implementation.
friend std::ostream & operator<<(std::ostream &os, const SerializeBuffer &b)
Operator that calls the print function of the serialize buffer.
Definition: Serialize.h:137
DeSerializeBuffer & operator=(DeSerializeBuffer &&buf)=default
Disable copy constructor.
void gDeserialize(DeSerializeBuffer &buf, T1 &&t1, Args &&...args)
Deserialize data in a buffer into a series of objects.
Definition: Serialize.h:1032
void setOffset(unsigned off)
Sets the offset into the deserialize buffer.
Definition: Serialize.h:212
void print(std::ostream &o) const
Utility print function for the serialize buffer.
Definition: Serialize.h:129
vTy & getVec()
Returns vector of data stored in this serialize buffer.
Definition: Serialize.h:115
Class that inherits from std::atomic to make it copyable by defining a copy constructor.
Definition: AtomicWrapper.h:40
void reserve(size_t n)
Definition: PODResizeableArray.h:129
void insertAt(const uint8_t *c, size_t bytes, size_t offset)
Insert characters from a buffer into the serialize buffer at a particular offset. ...
Definition: Serialize.h:86
vTy::const_iterator begin() const
Returns an iterator to the beginning of the data in this serialize buffer.
Definition: Serialize.h:118
size_t off
Definition: Serialize.h:715
vTy::const_iterator end() const
Returns an iterator to the end of the data in this serialize buffer.
Definition: Serialize.h:120
void pop_back(unsigned x)
Clears the last x bytes of the deserialize buffer, resizing it as well.
Definition: Serialize.h:229
T1 first
first element
Definition: CopyableTuple.h:41
void swap(PODResizeableArray &v)
Definition: PODResizeableArray.h:192
void insert(const uint8_t *c, size_t bytes)
Insert characters from a buffer into the serialize buffer.
Definition: Serialize.h:80
void resize(uint64_t n)
Resizes the bitset.
Definition: libgalois/include/galois/DynamicBitset.h:78
DeSerializeBuffer(Iter b, Iter e)
Initializes the deserialize buffer using vector initialization from 2 iterators.
Definition: Serialize.h:186
DeSerializeBuffer(SerializeBuffer &&buf)
Initialize a deserialize buffer from a serialize buffer.
Definition: Serialize.h:191
Unordered collection of elements.
Definition: Bag.h:42
const_iterator cend() const
Definition: PODResizeableArray.h:120
size_type size() const
Returns the size of the serialize buffer.
Definition: Serialize.h:125
void reset(int count)
Reset deserialize buffer.
Definition: Serialize.h:204
Struct that contains 3 elements.
Definition: CopyableTuple.h:64
size_t size() const
Gets the size of the bitset.
Definition: libgalois/include/galois/DynamicBitset.h:99
T2 second
second element
Definition: CopyableTuple.h:68
void print(std::ostream &o) const
Utility print of deserialize buffer.
Definition: Serialize.h:262
bool empty() const
Returns true if the deserialize buffer is empty.
Definition: Serialize.h:222
unsigned char pop()
Get the next character in the deserialize buffer.
Definition: Serialize.h:225
size_type size() const
Definition: PODResizeableArray.h:125
DeSerializeBuffer(int count)
Initializes the deserialize buffer with a certain size.
Definition: Serialize.h:179
SerializeBuffer(const char *d, unsigned len)
Creates a buffer from another buffer.
Definition: Serialize.h:74
vTy::size_type size_type
Definition: Serialize.h:122
size_t encomber(size_t bytes)
Reserve space at the end for inserting new data into the serialize buffer.
Definition: Serialize.h:97
bool atAlignment(size_t a)
Checks if the current location in the deserialize buffer is aligned to some size a.
Definition: Serialize.h:258
DeSerializeBuffer(vTy &&v, uint32_t start=0)
Move constructor.
Definition: Serialize.h:165
iterator begin()
Definition: PODResizeableArray.h:105
unsigned getOffset() const
Gets the current offset into the deserialize buffer.
Definition: Serialize.h:210
const uint8_t * r_linearData() const
Get a pointer to the remaining data of the deserialize buffer (as determined by offset) ...
Definition: Serialize.h:251
void resize(size_t bytes)
Definition: Serialize.h:103
auto gDeserializeRaw(Iter iter, T &data) -> decltype(std::declval< typename std::enable_if< is_memory_copyable< T >::value >::type >(), Iter())
&quot;Deserialize&quot; data in an iterator type into a data object.
Definition: Serialize.h:1052
T2 second
second element
Definition: CopyableTuple.h:43
Contains a copyable atomics class.
Struct that contains 2 elements.
Definition: CopyableTuple.h:39
void clear()
Definition: Bag.h:220
void extract(uint8_t *dst, size_t num)
Extracts a certain amount of data from the deserialize buffer.
Definition: Serialize.h:237
Buffer for deserialization of data.
Definition: Serialize.h:147
DeSerializeBuffer()
Constructor initializes offset into buffer to 0.
Definition: Serialize.h:159
pointer data()
Definition: PODResizeableArray.h:174
LazyRef structure; used to store both a type and an offset to begin saving data into.
Definition: Serialize.h:714
unsigned size() const
Gets the size of the deserialize buffer.
Definition: Serialize.h:218
T3 third
third element
Definition: CopyableTuple.h:70
Like std::deque but use Galois memory management functionality.
Definition: gdeque.h:43
T value_type
Definition: Executor_ParaMeter.h:111
const auto & get_vec() const
Returns the underlying bitset representation to the user.
Definition: libgalois/include/galois/DynamicBitset.h:63
const uint8_t * linearData() const
Returns a pointer to the data stored in this serialize buffer.
Definition: Serialize.h:113
Indicates if T is memory copyable.
Definition: ExtraTraits.h:64
vTy & getVec()
Get the underlying vector storing the data of the deserialize buffer.
Definition: Serialize.h:244
Contains copyable tuple classes whose elements are contiguous in memory.