-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_item.hpp
More file actions
52 lines (40 loc) · 1.22 KB
/
data_item.hpp
File metadata and controls
52 lines (40 loc) · 1.22 KB
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
#pragma once
// You can rely on the fields local_item.
// Do not rely on the implementation of shared_item!
// It's important that the constant below (now 64) is the size in bits of shared_item.shared_item_data.
#define ITER_SHIFT (64 - NUM_CPUS_SHIFT)
#define ITER_MASK ((1l << ITER_SHIFT) - 1l)
//A shared_item is the data written in the CAS object.
typedef uint64_t shared_item;
#define EMPTY_SHARED_ITEM 0
#define DUMMY_SHARED_ITEM ((uint64_t) (-1l))
//A local_item is an element of some thread's record.
struct local_item {
shared_item val;
op_type op;
uint64_t loc;
#ifdef TIME
timespec start;
timespec end;
#endif
};
#define EMPTY_LOCAL_ITEM {EMPTY_SHARED_ITEM}
#define DUMMY_LOCAL_ITEM {DUMMY_SHARED_ITEM}
shared_item make_shared_item(uint64_t worker, uint64_t iter) {
return (worker << ITER_SHIFT) | iter;
}
void increment_shared_item(shared_item &item) {
item++;
}
uint64_t shared_item_worker(shared_item item) {
return item >> ITER_SHIFT;
}
uint64_t shared_item_iter(shared_item item) {
return item & ITER_MASK;
}
bool is_shared_item_empty(shared_item item) {
return item == EMPTY_SHARED_ITEM;
}
bool is_local_item_dummy(local_item item) {
return item.val == DUMMY_SHARED_ITEM;
}