summaryrefslogtreecommitdiff
path: root/sortlib.cuh
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2023-04-27 15:58:36 +0800
committerKunoiSayami <[email protected]>2023-04-27 15:58:36 +0800
commitd71d074df295ae5e4f71592802fe88da514fb84a (patch)
treedb04c6133c07c63eb45fe97b6e74eba4b16e54fe /sortlib.cuh
parent32d06031ceb10e99a85297ce43b17099741ce3bc (diff)
2023-04-27 15:58
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'sortlib.cuh')
-rw-r--r--sortlib.cuh14
1 files changed, 9 insertions, 5 deletions
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);