From d71d074df295ae5e4f71592802fe88da514fb84a Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Thu, 27 Apr 2023 15:58:36 +0800 Subject: 2023-04-27 15:58 Signed-off-by: KunoiSayami --- sortlib.cuh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sortlib.cuh') diff --git a/sortlib.cuh b/sortlib.cuh index db6c949..f9bc7d7 100644 --- a/sortlib.cuh +++ b/sortlib.cuh @@ -12,7 +12,10 @@ public: : LENGTH(length), MOVE_OFFSET(move_offset - 1), STEP_LIMIT(fast_log(LENGTH)) {} const size_t LENGTH; - const int MOVE_OFFSET, STEP_LIMIT; + + /// MOVE_OFFSET means bit to select branch + const int MOVE_OFFSET; + const int STEP_LIMIT; __device__ __host__ static size_t fast_log(size_t a) { float t = a; @@ -65,15 +68,15 @@ public: } // son = get_son_from_step(son, (*last_known_point > val)); - auto tmp = ((*last_known_point - val) >> MOVE_OFFSET); + auto branch_selector = ((*last_known_point - val) >> MOVE_OFFSET); // printf("tmp: %llu\n", tmp); // printf("%llu %llu ", val, *last_known_point); - son = son * 2 + tmp; + son = son * 2 + branch_selector; // printf("%d\n", son); // puts(tmp == 0 ? "1:left" : "1:right"); // if (son < 0) son = 0; /*printf("%d %d %d\n", (1 << (i + 1)), son, - -(int)((*last_known_point - val) >> MOVE_OFFSET));*/ + -(int)((*last_known_point - val) >> brenchSelector));*/ last_known_point = next_level_start + son; if (last_known_point > end) { printf("%p %ld\n", end, next_level_start - start); @@ -82,6 +85,7 @@ public: return last_known_point; } + /// Should be correct version __device__ __host__ double sample_cdf_custom_version(key_type *start, const key_type *end, key_type x) { // printf("custom version:\n"); @@ -139,7 +143,7 @@ public: return last_known_point; } - // CDF original version (should only work on default data layout) + /// CDF original version (should only work on default data layout) __device__ __host__ double sample_cdf(key_type *start, key_type *end, key_type x) { auto it = this->original_binary_search(start, end, x); -- cgit v1.3.1