-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark_list.h
53 lines (38 loc) · 1.1 KB
/
benchmark_list.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
#ifndef BENCHMARK_LIST_H
#define BENCHMARK_LIST_H
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <limits.h>
typedef struct barrier {
pthread_cond_t complete;
pthread_mutex_t mutex;
int count;
int crossing;
} barrier_t;
#define CACHE_ALIGN (192)
#define CACHE_ALIGN_SIZE(size) ((((size - 1) / CACHE_ALIGN) + 1) * CACHE_ALIGN)
#define PTHREAD_PADDING (16)
typedef struct pthread_data {
long pthread_padding[PTHREAD_PADDING];
long id;
unsigned long nr_ins;
unsigned long nr_del;
unsigned long nr_find;
unsigned long nr_txn;
int range;
int update_ratio;
unsigned int seed;
barrier_t *barrier;
void *list;
void *ds_data; // data structure specific data
} pthread_data_t;
pthread_data_t *alloc_pthread_data(void);
void free_pthread_data(pthread_data_t *d);
void *list_global_init(int init_size, int value_range);
int list_thread_init(pthread_data_t *data, pthread_data_t **sync_data, int nr_threads);
void list_global_exit(void *list);
int list_ins(int key, pthread_data_t *data);
int list_del(int key, pthread_data_t *data);
int list_find(int key, pthread_data_t *data);
#endif