Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CacheLineStorage.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 
20 #ifndef GALOIS_SUBSTRATE_CACHELINESTORAGE_H
21 #define GALOIS_SUBSTRATE_CACHELINESTORAGE_H
22 
23 #include <utility>
24 
25 #include "galois/config.h"
27 
28 namespace galois::substrate {
29 
30 // Store an item with padding
31 template <typename T>
34 
36  // static_assert(sizeof(T) < GALOIS_CACHE_LINE_SIZE, "Too large a type");
37 
39  CacheLineStorage(const T& v) : data(v) {}
40 
41  template <typename A>
42  explicit CacheLineStorage(A&& v) : data(std::forward<A>(v)) {}
43 
44  explicit operator T() { return data; }
45 
46  T& get() { return data; }
47  template <typename V>
48  CacheLineStorage& operator=(const V& v) {
49  data = v;
50  return *this;
51  }
52 };
53 
54 } // namespace galois::substrate
55 
56 #endif
Definition: CacheLineStorage.h:32
CacheLineStorage(const T &v)
Definition: CacheLineStorage.h:39
constexpr int GALOIS_CACHE_LINE_SIZE
Definition: CompilerSpecific.h:37
char buffer[GALOIS_CACHE_LINE_SIZE-(sizeof(T)%GALOIS_CACHE_LINE_SIZE)]
Definition: CacheLineStorage.h:35
CacheLineStorage & operator=(const V &v)
Definition: CacheLineStorage.h:48
CacheLineStorage(A &&v)
Definition: CacheLineStorage.h:42
CacheLineStorage()
Definition: CacheLineStorage.h:38
T data
Definition: CacheLineStorage.h:33