From be0483ef4b6935324f85f124da8f4c1b93e918f6 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Wed, 24 May 2023 14:12:56 +0800 Subject: fix(exp): Fix expt_0520 malloc failure Signed-off-by: KunoiSayami --- sortlib.cuh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sortlib.cuh') diff --git a/sortlib.cuh b/sortlib.cuh index 5bacc11..ae0ea67 100644 --- a/sortlib.cuh +++ b/sortlib.cuh @@ -3,6 +3,7 @@ #include #include +#include typedef unsigned long long key_type; @@ -176,8 +177,23 @@ public: puts("You can remove this function if passed already"); #endif } + + __host__ __device__ size_t length() const { return this->LENGTH; } }; +template void static rebuild(std::vector original) { + auto sample_length = original.size(); + auto sorter = CustomSort(sample_length); + auto tmp = new T[sample_length]; + + for (size_t i = 0; i < sample_length; i++) { + tmp[i] = original[sorter.calculate_index(i) - 1]; + } + memcpy(original.data(), tmp, sizeof(T) * sample_length); + + delete[] tmp; +} + __global__ void testCustomCalculation(size_t length) { CustomSort(length, sizeof(long) * 8).testCalculation(); } -- cgit v1.3.1