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.cu29
1 files changed, 16 insertions, 13 deletions
diff --git a/db/skiplist_test.cu b/db/skiplist_test.cu
index b8fcb5e..c926575 100644
--- a/db/skiplist_test.cu
+++ b/db/skiplist_test.cu
@@ -393,16 +393,17 @@ class TestClass {
cuda::atomic<size_t> atomic;
};
-__global__ void init(Arena * pArena, SkipList<Key, Comparator> * pSkipList) {
+__global__ void init(Arena ** pArena, SkipList<Key, Comparator> ** pSkipList) {
Comparator cmp;
printf("init\n");
- pArena = new Arena();
+ *pArena = new Arena();
//new TestClass();
printf("init arena\n");
- pSkipList = new SkipList<Key, Comparator>(cmp, pArena);
+ // new = SkipList *
+ *pSkipList = new SkipList<Key, Comparator>(cmp, *pArena);
printf("init2\n");
- pSkipList->Insert(16807);
- printf("skiplist: %p\n", pSkipList);
+ //pSkipList->Insert(16807);
+ printf("skiplist: %p\n", *pSkipList);
printf("init3\n");
}
@@ -410,8 +411,8 @@ __global__ void testParallel(SkipList<Key, Comparator> * skipList, Key * keys) {
unsigned int start = threadIdx.x;
printf("skiplist: %p\n", skipList);
printf("start: %u\n", start);
- for (unsigned i = start; i < start + 100 ; i++) {
- printf("key: %lu\n", keys[i]);
+ for (unsigned i = start * 100; i < (start + 1) * 100 ; i++) {
+ //printf("key: %lu\n", keys[i]);
skipList->Insert(keys[i]);
}
printf("done: %u\n", start);
@@ -426,12 +427,12 @@ void host_insert_test() {
keys[i] = .Next();
}*/
Key * keys = new Key[1000];
- Arena * pArena;
- SkipList<Key, Comparator> * skipList;
+ Arena ** pArena;
+ SkipList<Key, Comparator> ** skipList;
std::set<Key> k;
- cudaMallocManaged((void**)&pArena, sizeof(Arena));
- cudaMallocManaged((void**)&skipList, sizeof(SkipList<Key, Comparator>));
+ cudaMallocManaged((void**)&pArena, sizeof(void*));
+ cudaMallocManaged((void**)&skipList, sizeof(void*));
auto * device_rnd = new Random(test::RandomSeed());
Key * device_keys = nullptr;
cudaMallocManaged((void**)&device_keys, sizeof(Key) * 1000 );
@@ -457,12 +458,14 @@ void host_insert_test() {
cudaDeviceSynchronize();
//insert_skiplist<<<gridSize, blockSize>>>(skipList, device_rnd);
- testParallel<<<gridSize, 1>>>(skipList, device_keys);
+ testParallel<<<gridSize, blockSize>>>(*skipList, device_keys);
//cudaDeviceSynchronize();
//insert_and_lookup<<<gridSize, blockSize>>>(skipList);
cudaDeviceSynchronize();
- std::cout << "test\n";
+ cudaFree(device_keys);
+ cudaFree(skipList);
+ cudaFree(pArena);
}