summaryrefslogtreecommitdiff
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
parent32d06031ceb10e99a85297ce43b17099741ce3bc (diff)
2023-04-27 15:58
Signed-off-by: KunoiSayami <[email protected]>
-rw-r--r--CMakeLists.txt11
-rw-r--r--sortlib.cuh14
-rw-r--r--valid_sort.cpp2
3 files changed, 20 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e9a8af..a037c5e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,4 +150,13 @@ target_link_libraries(expt_0406 m stdc++)
set_target_properties(expt_0406 PROPERTIES
CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(expt_0406 PROPERTIES CUDA_ARCHITECTURES "75")
-set_target_properties(expt_0406 PROPERTIES LINKER_LANGUAGE CUDA) \ No newline at end of file
+set_target_properties(expt_0406 PROPERTIES LINKER_LANGUAGE CUDA)
+
+
+add_executable(expt_0425 expt_0425.cu)
+target_link_libraries(expt_0425 m stdc++)
+
+set_target_properties(expt_0425 PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON)
+set_target_properties(expt_0425 PROPERTIES CUDA_ARCHITECTURES "75")
+set_target_properties(expt_0425 PROPERTIES LINKER_LANGUAGE CUDA) \ No newline at end of file
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);
diff --git a/valid_sort.cpp b/valid_sort.cpp
index 399ac08..dbe989b 100644
--- a/valid_sort.cpp
+++ b/valid_sort.cpp
@@ -180,5 +180,5 @@ int main() {
// printf("%zu %zu\n", location, location2);
}
});
- valid_sort(tmp);
+ // valid_sort(tmp);
} \ No newline at end of file