diff options
| author | KunoiSayami <[email protected]> | 2023-05-24 14:12:56 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2023-05-24 14:12:56 +0800 |
| commit | be0483ef4b6935324f85f124da8f4c1b93e918f6 (patch) | |
| tree | 6a16d9082f975447f2f2bb7a12116cdbf80e52a2 /sortlib.cuh | |
| parent | f0d3437f2e1fc9612e5a926d048a1ae3cd1e7a75 (diff) | |
fix(exp): Fix expt_0520 malloc failure
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'sortlib.cuh')
| -rw-r--r-- | sortlib.cuh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sortlib.cuh b/sortlib.cuh index 5bacc11..ae0ea67 100644 --- a/sortlib.cuh +++ b/sortlib.cuh @@ -3,6 +3,7 @@ #include <cassert> #include <cstdio> +#include <vector> 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 <typename T> void static rebuild(std::vector<T> 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(); } |
