aboutsummaryrefslogtreecommitdiff
path: root/db/skiplist_test.cu
diff options
context:
space:
mode:
Diffstat (limited to 'db/skiplist_test.cu')
-rw-r--r--db/skiplist_test.cu27
1 files changed, 8 insertions, 19 deletions
diff --git a/db/skiplist_test.cu b/db/skiplist_test.cu
index 53f60f8..9b7ec7e 100644
--- a/db/skiplist_test.cu
+++ b/db/skiplist_test.cu
@@ -22,7 +22,7 @@ namespace leveldb {
typedef uint64_t Key;
struct Comparator {
- int operator()(const Key& a, const Key& b) const {
+ __device__ int operator()(const Key& a, const Key& b) const {
if (a < b) {
return -1;
} else if (a > b) {
@@ -287,31 +287,22 @@ __device__ void update_list(SkipList<Key, Comparator> * l, Key key) {
l->Insert(key);
}
-__global__ void insert_skiplist(SkipList<Key, Comparator> * l, Random * rnd) {
+__global__ void insert_skiplist(int random_seed) {
+ Arena arena;
+ Comparator cmp;
+ auto * skipList = new SkipList<Key, Comparator>(cmp, &arena);
+ auto * device_rnd = new Random(random_seed);
unsigned row = threadIdx.x + blockIdx.x * blockDim.x;
for (int i = 0; i < 1000; i++ ) {
- update_list(l, rnd->Next());
+ update_list(skipList, device_rnd->Next());
}
}
__host__ void host_insert_test() {
- constexpr size_t sz_size = 1024;
- Arena arena;
- Comparator cmp;
Key * keys;
//SkipList<Key, Comparator> list(cmp, &arena);
-
- SkipList<Key, Comparator> * ptr_list;
- Random * device_rnd;
-
- //cudaMallocManaged((void**)&keys, sizeof(Key) * sz_size);
- cudaMallocManaged((void**)&device_rnd, sizeof(Random));
- cudaMallocManaged((void**)&ptr_list, sizeof(SkipList<Key, Comparator>));
-
- ptr_list = new SkipList<Key, Comparator>(cmp, &arena);
- device_rnd = new Random(test::RandomSeed());
/*
for (int i = 0; i < 1000; i++) {
keys[i] = .Next();
@@ -321,12 +312,10 @@ __host__ void host_insert_test() {
dim3 gridSize(32, 1);
- insert_skiplist<<<gridSize, blockSize>>>(ptr_list, device_rnd);
+ insert_skiplist<<<gridSize, blockSize>>>(test::RandomSeed());
cudaDeviceSynchronize();
- cudaFree(&device_rnd);
- cudaFree(ptr_list);
}