diff options
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(); } |
