summaryrefslogtreecommitdiff
path: root/main.cu
diff options
context:
space:
mode:
Diffstat (limited to 'main.cu')
-rw-r--r--main.cu41
1 files changed, 32 insertions, 9 deletions
diff --git a/main.cu b/main.cu
index 411dd9d..a463280 100644
--- a/main.cu
+++ b/main.cu
@@ -76,6 +76,14 @@ typedef unsigned long long LL;
typedef unsigned int LL;
#endif
+#ifndef BUILD_SIZE
+#define BUILD_SIZE 1048576
+#endif
+
+#ifndef STEP_SIZE
+#define STEP_SIZE 2
+#endif
+
// Maximum level of a node in the skip list
//#define MAX_LEVEL 32
constexpr size_t MAX_LEVEL = 32;
@@ -84,18 +92,26 @@ constexpr size_t MAX_LEVEL = 32;
//#define NUM_THREADS 512
constexpr size_t NUM_THREADS = 512;
-constexpr size_t NUM_ITEMS = 1048576;
+constexpr size_t NUM_ITEMS = BUILD_SIZE;
// constexpr size_t KEYS = 1048576;
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;
+
// Supported operations
constexpr int ADD = 0;
constexpr int DELETE = 1;
constexpr int SEARCH = 2;
+#ifdef RANDOM_TARGET
+constexpr const char *TARGET_STRING = "RANDOM";
+#else
+constexpr const char *TARGET_STRING = "PERFECT";
+#endif
+
#define CUDA_ERROR_CHECK
#define CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__)
@@ -544,8 +560,6 @@ unsigned trailing_zeroes(LL n) {
return bits;
}
-constexpr int block_size = 8;
-
LL CustomLevel(LL value) {
auto left = std::lower_bound(storage.begin(), storage.end(), value);
auto right = std::upper_bound(storage.begin(), storage.end(), value);
@@ -559,7 +573,7 @@ LL CustomLevel(LL value) {
if (index % block_size == 0) {
auto level = trailing_zeroes(index / block_size + 1) + 1;
- // printf("%ld %u\n", index, level);
+ // printf("%ld,%u\n", index, level);
return level;
}
@@ -626,8 +640,11 @@ int main(int argc, char **argv) {
// Pre-generated levels of skip list nodes (relevant only if op[i] is add)
// srand(0);
for (i = 0; i < NUM_ITEMS; i++) {
- // levels[i] = Randomlevel(randomEngine) - 1; //36/14
+#ifdef RANDOM_HEIGHT
+ // levels[i] = Randomlevel(randomEngine) - 1; // 36/14
+#else
levels[i] = CustomLevel(items[i]) - 1; // 31/18
+#endif
}
// Populate the sequence of operations
@@ -720,7 +737,13 @@ int main(int argc, char **argv) {
// Print kernel execution time in milliseconds
- printf("%lf\n", time);
+ printf("%s ", TARGET_STRING);
+
+#ifndef RANDOM_TARGET
+ printf("%d ", block_size);
+#endif
+
+ printf("%lu: %lf", NUM_ITEMS, time);
// Launch main kernel for query
@@ -753,7 +776,7 @@ int main(int argc, char **argv) {
// Print kernel execution time in milliseconds
- printf("%lf\n", time);
+ printf(" %lf\n", time);
// Check for errors
@@ -769,9 +792,9 @@ int main(int argc, char **argv) {
// Uncomment the following for debugging
// print<<<1,32>>>();
- cudaDeviceSynchronize();
+ // cudaDeviceSynchronize();
- print_function<<<1, 1>>>();
+ // print_function<<<1, 1>>>();
cudaDeviceSynchronize();
/*cudaFree(Clist);