-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.h
119 lines (103 loc) · 2.83 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
/*
* Copyright (c) 2014 Mohamed L. Karaoui.
* Copyright (c) 2014 Sorbonne Universités, UPMC Univ Paris 06.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef TOTEST_H
#define TOTEST_H
#define _LGPL_SOURCE
#include <pthread.h>
#include "lock.h"
#ifdef RCU_QSBR
#include <urcu-qsbr.h>
#endif
#if (defined(RCU_MB) || defined(RCU_SIGNAL))
#ifdef RCU_QSBR
#error ! cannot mix rcu flavors !
#endif
//#define RCU_MB
#include <urcu.h>
#endif
#define MAX_CPU
#define NB_TEST 2000000
#define ITERATION 5
#define NBNODE_DEFAULT 4
#define MAX_THREAD 256
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
//(*(__volatile__ __typeof__(x) *)&(x))
#define clean_pointer(p) ((node_t *)(((unsigned long)(p)) & (-2)))
#define mark_pointer(p) ((node_t *)(((unsigned long)(p)) + 1 ))
#define CACHESIZE 64 /* Should cover most machines. */
typedef unsigned long gc_t;
typedef struct node {
int key;
struct node *next;
struct node *mr_next;
unsigned long rc;
gc_t gc;
#ifdef RCU
struct rcu_head head;
#endif
//} node_t;
} __attribute__ ((__aligned__ (CACHESIZE))) node_t;
struct hash {
lock_t *locks;
node_t **heads;
};
//};__attribute__ ((__aligned__ (CACHESIZE)));
extern __thread long thread;
extern __thread long nbretry;
extern __thread long nbrelink;
extern __thread long nbreprev;
extern __thread int backoff_amount;
extern __thread double nbmallocs;
extern __thread int nbfl;
extern //__thread
__thread double nbblockeds;
extern __thread unsigned int thd_seed;
extern __thread unsigned int thd_nbupdaters;
extern unsigned long nbnodes, nbbuckets, nbkeys;
extern unsigned long nbthreads, nbreaders, nbupdaters;
//extern struct list hash[];
node_t *new_node();
static void *run(void*);
static void read_compute();
int insert(int key, node_t** head, lock_t* lock);
int search(int key, node_t** head, lock_t* lock);
int delete(int key, node_t** head, lock_t* lock);
//#define DEBUG
//#define CHECK_CCRT
//
#if 0
#define COMPUTE_AMOUNT 8
static void read_compute()
{
volatile int x=COMPUTE_AMOUNT;
while(x)
{
x--;
compiler_barrier();
}
}
static void write_compute()
{
read_compute();
}
#else
static void read_compute(){}
static void write_compute(){}
#endif
#endif