forked from efficient/cicada-exp-sigmod2017-silo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.h
132 lines (107 loc) · 3.39 KB
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef _MACROS_H_
#define _MACROS_H_
#include <assert.h>
#include <stdexcept>
/** options */
//#define TUPLE_PREFETCH
#define BTREE_NODE_PREFETCH
//#define DIE_ON_ABORT
//#define TRAP_LARGE_ALLOOCATIONS
#define USE_BUILTIN_MEMFUNCS
//#define CHECK_INVARIANTS
//#define TUPLE_CHECK_KEY
#define USE_SMALL_CONTAINER_OPT
#define BTREE_NODE_ALLOC_CACHE_ALIGNED
#define TXN_BTREE_DUMP_PURGE_STATS
//#define ENABLE_EVENT_COUNTERS
//#define ENABLE_BENCH_TXN_COUNTERS
#define USE_VARINT_ENCODING
//#define DISABLE_FIELD_SELECTION
//#define PARANOID_CHECKING
//#define BTREE_LOCK_OWNERSHIP_CHECKING
//#define TUPLE_LOCK_OWNERSHIP_CHECKING
//#define MEMCHECK_MAGIC 0xFF
//#define TUPLE_MAGIC
//#define PROTO2_CAN_DISABLE_GC
//#define PROTO2_CAN_DISABLE_SNAPSHOTS
//#define USE_PERF_CTRS
#ifndef CONFIG_H
#error "no CONFIG_H set"
#endif
#include CONFIG_H
/**
* some non-sensical options, which only make sense for performance debugging
* experiments. these should ALL be DISABLED when doing actual benchmarking
**/
//#define LOGGER_UNSAFE_FAKE_COMPRESSION
//#define LOGGER_UNSAFE_REDUCE_BUFFER_SIZE
//#define LOGGER_STRIDE_OVER_BUFFER
#define CACHELINE_SIZE 64 // XXX: don't assume x86
#define LG_CACHELINE_SIZE __builtin_ctz(CACHELINE_SIZE)
// global maximum on the number of unique threads allowed
// in the system
#define NMAXCOREBITS 9
#define NMAXCORES (1 << NMAXCOREBITS)
// some helpers for cacheline alignment
#define CACHE_ALIGNED __attribute__((aligned(CACHELINE_SIZE)))
#define __XCONCAT2(a, b) a ## b
#define __XCONCAT(a, b) __XCONCAT2(a, b)
#define CACHE_PADOUT \
char __XCONCAT(__padout, __COUNTER__)[0] __attribute__((aligned(CACHELINE_SIZE)))
#define PACKED __attribute__((packed))
#define NEVER_INLINE __attribute__((noinline))
#define ALWAYS_INLINE __attribute__((always_inline))
#define UNUSED __attribute__((unused))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define COMPILER_MEMORY_FENCE asm volatile("" ::: "memory")
#ifdef NDEBUG
#define ALWAYS_ASSERT(expr) (likely((expr)) ? (void)0 : abort())
#else
#define ALWAYS_ASSERT(expr) assert((expr))
#endif /* NDEBUG */
#define ARRAY_NELEMS(a) (sizeof(a)/sizeof((a)[0]))
#define VERBOSE(expr) ((void)0)
//#define VERBOSE(expr) (expr)
#ifdef CHECK_INVARIANTS
#define INVARIANT(expr) ALWAYS_ASSERT(expr)
#else
#define INVARIANT(expr) ((void)0)
#endif /* CHECK_INVARIANTS */
// XXX: would be nice if we checked these during single threaded execution
#define SINGLE_THREADED_INVARIANT(expr) ((void)0)
// tune away
#define SMALL_SIZE_VEC 128
#define SMALL_SIZE_MAP 64
#define EXTRA_SMALL_SIZE_MAP 8
//#define BACKOFF_SPINS_FACTOR 1000
//#define BACKOFF_SPINS_FACTOR 100
#define BACKOFF_SPINS_FACTOR 10
// throw exception after the assert(), so that GCC knows
// we'll never return
#define NDB_UNIMPLEMENTED(what) \
do { \
ALWAYS_ASSERT(false); \
throw ::std::runtime_error(what); \
} while (0)
#ifdef USE_BUILTIN_MEMFUNCS
#define NDB_MEMCPY __builtin_memcpy
#define NDB_MEMSET __builtin_memset
#else
#define NDB_MEMCPY memcpy
#define NDB_MEMSET memset
#endif
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#define GCC_AT_LEAST_47 1
#else
#define GCC_AT_LEAST_47 0
#endif
// g++-4.6 does not support override
#if GCC_AT_LEAST_47
#define OVERRIDE override
#else
#define OVERRIDE
#endif
// number of nanoseconds in 1 second (1e9)
#define ONE_SECOND_NS 1000000000
#endif /* _MACROS_H_ */