-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashtable.h
More file actions
53 lines (37 loc) · 1.18 KB
/
Copy pathhashtable.h
File metadata and controls
53 lines (37 loc) · 1.18 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
53
// hashtable.h
#ifndef HASHTABLE_H
#define HASHTABLE_H
#define _POSIX_C_SOURCE 199309L // For clock_gettime and CLOCK_MONOTONIC
#define _GNU_SOURCE // For CPU_ZERO and CPU_SET
#include <pthread.h>
#define NUMA_NODES 4
#define BUCKETS_PER_NODE 16 // Number of buckets per NUMA node
typedef struct Entry {
int key;
int value;
struct Entry* next;
} Entry;
typedef struct Timer{
struct timespec start;
struct timespec finish;
}Timer;
typedef struct Hashtable {
Entry* buckets[BUCKETS_PER_NODE];
Timer timer;
} Hashtable;
// Declare hashtables array as extern
extern Hashtable hashtables[NUMA_NODES];
// Hash function 1: Determines NUMA node
unsigned int hash_to_numa_node(int key);
// Hash function 2: Determines bucket within NUMA node
unsigned int hash_to_bucket(int key);
void init_hash_coefficients();
// Initialize hashtables
void init_hashtables(void);
// Insert a key-value pair into the hashtable for a specific NUMA node
void insert(int key, int value);
// Lookup a value by key in the hashtable for a specific NUMA node
int lookup(int key);
// Delete a key-value pair from the hashtable for a specific NUMA node
void delete(int key);
#endif // HASHTABLE_H