-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.h
124 lines (102 loc) · 3.19 KB
/
test.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
#ifndef TEST_H
#define TEST_H
#include <stdlib.h>
#include <stdint.h>
#include "node.h"
#include "mcslock.h"
/****************************************************************************
*
* Definitions of constants.
*
****************************************************************************/
#define N_EPOCHS 3
#define NS_PER_S 1000000000
#define CACHESIZE 64 /* Should cover most machines. */
#define MAX_THREADS 65
typedef struct item_list_t item_list_t;
typedef struct dw_gc_t dw_gc_t;
typedef struct auto_ebr_t auto_ebr_t;
typedef struct per_thread_t {
__attribute__ ((__aligned__(CACHESIZE)))
pthread_t thread;
unsigned long seed;
size_t ops;
/*
* Private per-thread node pointers for lock-free linked list:
* prev : holds the old address of cur for CAS operations
* cur : the node we want to do something with
* (delete, insert after, etc.)
* next : the successor of cur
*/
node_t **prev;
node_t *next;
node_t *cur;
/* Count of logically deleted nodes awaiting reclamation; used by
* all MR schemes.
*/
size_t retire_count;
/* SMR per-thread data:
* rlist: retired list
* rcount: retired count
*/
node_t *rlist;
node_t **plist;
/* EBR per-thread data:
* limbo_list: three lists of nodes awaiting physical deletion, one
* for each epoch
* in_critical: flag telling us whether we're in a critical section
* with respect to memory reclamation
* entries_since_update: the number of times we have entered a critical
* section in the current epoch since trying to
* update the global epoch
* epoch: the local epoch
*/
node_t *limbo_list [N_EPOCHS];
int in_critical;
int entries_since_update;
int epoch;
item_list_t *item_list;
dw_gc_t *dw_gc;
auto_ebr_t *auto_ebr;
uint32_t thread_id;
} per_thread_t;
typedef enum {
TEST_NOT_STARTED,
TEST_RUNNING,
TEST_OVER,
} test_state_t;
extern uint32_t n_ms;
extern uint32_t n_threads;
extern uint32_t n_elements;
extern uint8_t n_update;
extern uint32_t n_keys;
extern void *global_ds;
extern test_state_t test_state;
extern per_thread_t threads[MAX_THREADS];
extern __thread uint32_t thread_id;
extern node_t *global_freelist;
/****************************************************************************
*
* Utility macros and functions.
*
****************************************************************************/
#ifdef YIELD
#define cond_yield() sched_yield()
#else
#define cond_yield()
#endif
#define this_thread threads[thread_id]
/****************************************************************************
*
* Interface to test functions.
*
****************************************************************************/
/* Sets up the test, in a test-depedent way. Parses the argv. Instantiates
* data_structure to point to the right data structure.
*/
void setup_test(int argc, char **argv);
/* Different data structures -- ie. linked list, queue -- must provide
* implementations of this. It's the workhorse function of the performance test.
*/
void testloop_body();
#endif