diff options
Diffstat (limited to 'main.cu')
| -rw-r--r-- | main.cu | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -99,13 +99,15 @@ constexpr size_t FACTOR = 1; // should change this to dynamic next time constexpr size_t KEY_INDEX_SIZE = 32; -constexpr int block_size = STEP_SIZE; +volatile int block_size = STEP_SIZE; // Supported operations constexpr int ADD = 0; constexpr int DELETE = 1; constexpr int SEARCH = 2; +typedef LL key_type; + #ifdef RANDOM_TARGET constexpr const char *TARGET_STRING = "RANDOM"; #else @@ -540,21 +542,21 @@ __global__ void kernel(LL *items, LL *op, LL *result) { }*/ // Generate the level of a newly created node -LL Randomlevel(std::mt19937 &randomEngine) { - std::geometric_distribution<> distribution(0.5); - return std::min(MAX_LEVEL, (size_t)distribution(randomEngine) + 1); +LL Randomlevel(std::mt19937 &randomEngine, double p) { + std::geometric_distribution<> distribution(p); + return std::min(MAX_LEVEL, (size_t)distribution(randomEngine)); } std::vector<LL> storage; -unsigned trailing_zeroes(LL n) { +unsigned trailing_zeroes(size_t index) { unsigned bits = 0; - LL x = n; + LL x = index / block_size; if (x) { - while ((x & 1) == 0) { + while (x % block_size == 0) { ++bits; - x >>= 1; + x /= block_size; } } return bits; @@ -572,7 +574,7 @@ LL CustomLevel(LL value) { auto index = left - storage.begin(); if (index % block_size == 0) { - auto level = trailing_zeroes(index / block_size + 1) + 1; + auto level = trailing_zeroes(index) + 1; // printf("%ld,%u\n", index, level); return level; } @@ -641,7 +643,7 @@ int main(int argc, char **argv) { // srand(0); for (i = 0; i < NUM_ITEMS; i++) { #ifdef RANDOM_HEIGHT - // levels[i] = Randomlevel(randomEngine) - 1; // 36/14 + levels[i] = Randomlevel(1 / randomEngine) - 1; // 36/14 #else levels[i] = CustomLevel(items[i]) - 1; // 31/18 #endif @@ -737,11 +739,7 @@ int main(int argc, char **argv) { // Print kernel execution time in milliseconds - printf("%s ", TARGET_STRING); - -#ifndef RANDOM_TARGET - printf("%d ", block_size); -#endif + printf("%s %d ", TARGET_STRING, block_size); printf("%lu: %lf", NUM_ITEMS, time); |
