summaryrefslogtreecommitdiff
path: root/expt_0528.cu
diff options
context:
space:
mode:
Diffstat (limited to 'expt_0528.cu')
-rw-r--r--expt_0528.cu66
1 files changed, 15 insertions, 51 deletions
diff --git a/expt_0528.cu b/expt_0528.cu
index 27bc29f..bf60070 100644
--- a/expt_0528.cu
+++ b/expt_0528.cu
@@ -94,7 +94,7 @@ constexpr size_t MAX_LEVEL = 32;
// Number of threads per block
// #define NUM_THREADS 512
-constexpr size_t NUM_THREADS = 512;
+constexpr size_t NUM_THREADS = 2;
// constexpr size_t NUM_ITEMS = BUILD_SIZE;
// constexpr size_t KEYS = 1048576;
@@ -211,52 +211,6 @@ public:
}
};
-/*struct MapNode {
- LL key;
- // Node *point[MAX_LEVEL + 1];
- Node *point;
-};
-
-class MemMap {
-public:
- size_t size;
- size_t real_size;
- MapNode *store;
-
- MemMap() : size(0), store(nullptr), real_size(0) {}
-
- __device__ bool insert(MapNode node) {
- bool need_extend = this->size + 1 > this->real_size;
- if (need_extend) {
- bool need_copy = this->real_size == 0;
- if (!need_copy) {
- this->real_size += 1;
- }
- this->real_size *= 2;
- MapNode *old = this->store;
- this->store = new MapNode[this->real_size];
- if (need_copy) {
- memcpy(this->store, old, this->real_size * sizeof(MapNode *));
- }
- delete[] old;
- }
- // need sort after insert
- this->store[size] = node;
- this->size += 1;
- }
-
- __device__ Node *search(LL key) {
- for (int offset = 0; offset < this->size; offset++) {
- if (this->store[offset].key >= key) {
- return this->store[offset].point;
- }
- }
- return nullptr;
- }
-
- __device__ ~MemMap() { delete[] store; }
-};*/
-
// Definition of lock-free skip list
class LockFreeSkipList {
@@ -637,22 +591,32 @@ int *generateRandomLevel(size_t size) {
}
int main(int argc, char **argv) {
- if (argc != 3) {
- printf("Usage %s [sample] [search] [insertion]\n", argv[0]);
+ if (argc < 3) {
+ printf("Usage %s <search> <insertion> [total row]\n", argv[0]);
exit(1);
}
auto search_length = strtol(argv[1], nullptr, 10);
auto insertion_length = strtol(argv[2], nullptr, 10);
+ auto total_row = 0L;
+
+ if (argc > 3) {
+ total_row = strtol(argv[3], nullptr, 10);
+ }
if (insertion_length < search_length) {
printf("Search should smaller than insertion\n");
}
printf("Insertion: %ld, Search: %ld ", insertion_length, search_length);
-
fflush(stdout);
- ReadHelper readHelper("normal_distribution.txt", 0, insertion_length, 0);
+
+ ReadHelper readHelper("normal_distribution.txt", 0, insertion_length,
+ total_row);
+ if (total_row) {
+ printf("Skip: %ld ", readHelper.random_number);
+ fflush(stdout);
+ }
readHelper.readFile();
std::vector<key_type> _search(readHelper.population_vector.begin(),
readHelper.population_vector.begin() +