This repository has been archived by the owner on Apr 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hashtable.cuh
82 lines (63 loc) · 1.42 KB
/
hashtable.cuh
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
#ifndef HASHTABLE_H
#define HASHTABLE_H
#include "lock.cuh"
#include <iostream>
enum State {EMPTY, DELETED, FULL};
struct Data {
volatile State state;
volatile ULL key;
Lock lock;
};
struct Instruction {
enum Type {
Insert,
Delete,
Find
};
Type type;
ULL key;
};
class ThreadLog {
public:
int * iterations, * h_iterations, final_index, size;
bool returned;
Instruction instruction;
ThreadLog(int size, Instruction);
~ThreadLog();
void to_string(std::ostream &);
void fillhostarray();
};
class HashTable {
public:
Data * table;
int size;
HashTable(int size);
~HashTable();
__device__ void insert(ULL key, ThreadLog *);
__device__ void deleteKey(ULL key, ThreadLog *);
__device__ void findKey(ULL key, ThreadLog *);
static void performInstructs(HashTable *table, Instruction *instructions,
int numInstruction, ThreadLog *);
static void print(HashTable *table, ThreadLog *, int, std::ostream &);
};
namespace init_table {
__global__
void init_empty_table(Data *, int);
}
// Contains all the CUDA kernels
namespace cu {
// Insert array of keys into table given. Stores insert statuses in ret
__global__ void performInstructs(
HashTable * table,
Instruction *instructions,
int numInstructions,
ThreadLog *);
}
// Temporary hash functions
namespace HashFunction {
__device__
int h1(ULL key, int size);
__device__
int h2(ULL key, int size);
}
#endif /* HASHTABLE_H */