summaryrefslogtreecommitdiff
path: root/sortlib.cuh
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2023-05-29 22:45:41 +0800
committerKunoiSayami <[email protected]>2023-05-29 22:45:41 +0800
commitd01ba96eb4ae147159f15d5f3cdb076fc60483e4 (patch)
tree52108e4a46d268d45f6d58e3e70dcd32738c4304 /sortlib.cuh
parent00543577ea9d59d1bf73837f26d16f41ef67724d (diff)
feat(exp): Add expt_0529
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'sortlib.cuh')
-rw-r--r--sortlib.cuh10
1 files changed, 8 insertions, 2 deletions
diff --git a/sortlib.cuh b/sortlib.cuh
index a7d3e2d..64f355b 100644
--- a/sortlib.cuh
+++ b/sortlib.cuh
@@ -37,7 +37,7 @@ public:
size_t low_bit = index & (-index);
return ((LENGTH + index) / low_bit) >> 1;
}
-
+#ifdef ENABLE_SORT_TEST
__device__ __host__ __attribute__((unused)) void testCalculation() const {
for (size_t i = 0; i < LENGTH; i++) {
auto left = calculate_index(i);
@@ -50,6 +50,7 @@ public:
assert(i + 1 == right);
}
}
+#endif
__device__ __host__ const key_type *binary_search(key_type *const start,
// const key_type *end,
@@ -127,7 +128,7 @@ public:
(double)(this->LENGTH - 1);
// printf("tmp: %llu %lf %lu\n", *it - *it_prev, tmp, prev_real_location);
}
-
+#ifdef SORT_FIRST_VERSION
/// First version
__device__ __host__ key_type *original_binary_search(key_type *start,
const key_type *end,
@@ -172,13 +173,16 @@ public:
(double)(x - *it_prev) / (double)(*it - *it_prev)) /
(double)((end - start) - 1);
}
+#endif
+#ifdef ENABLE_SORT_TEST
static void testSelf(size_t length) {
CustomSort(length, sizeof(long) * 8).testCalculation();
#ifndef DISABLE_TEST_WARNING
puts("You can remove this function if passed already");
#endif
}
+#endif
__host__ __device__ size_t length() const { return this->LENGTH; }
};
@@ -201,6 +205,7 @@ template <typename T> void rebuildSort(std::vector<T> &original) {
rebuild(original);
}
+#ifdef ENABLE_SORT_TEST
__global__ void testCustomCalculation(size_t length) {
CustomSort(length, sizeof(long) * 8).testCalculation();
}
@@ -209,6 +214,7 @@ __global__ void testCustomCalculationWithPrint(size_t length) {
CustomSort(length, sizeof(long) * 8).testCalculation();
printf("%lu pass\n", length);
}
+#endif
class FactorySort {