diff options
| author | KunoiSayami <[email protected]> | 2023-05-28 23:20:31 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2023-05-28 23:20:31 +0800 |
| commit | 9c0ce2f5570dedd5ad68c7e8fc222928046c5908 (patch) | |
| tree | 6ee48dfbd2bfb7607f87dcc3d96c332043327402 /sortlib.cuh | |
| parent | 44a035ec3ebb094adb162ba0c0d374a3fe153094 (diff) | |
fix(exp): Fix search action
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'sortlib.cuh')
| -rw-r--r-- | sortlib.cuh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sortlib.cuh b/sortlib.cuh index 6b19d3e..a7d3e2d 100644 --- a/sortlib.cuh +++ b/sortlib.cuh @@ -1,6 +1,7 @@ #ifndef LOCKFREE_SORTLIB_CUH #define LOCKFREE_SORTLIB_CUH +#include <algorithm> #include <cassert> #include <cstdio> #include <vector> @@ -182,7 +183,7 @@ public: __host__ __device__ size_t length() const { return this->LENGTH; } }; -template <typename T> void rebuild(std::vector<T> original) { +template <typename T> void rebuild(std::vector<T> &original) { auto sample_length = original.size(); auto sorter = CustomSort(sample_length, sizeof(T) * 8); auto tmp = new T[sample_length]; @@ -195,6 +196,11 @@ template <typename T> void rebuild(std::vector<T> original) { delete[] tmp; } +template <typename T> void rebuildSort(std::vector<T> &original) { + std::sort(original.begin(), original.end()); + rebuild(original); +} + __global__ void testCustomCalculation(size_t length) { CustomSort(length, sizeof(long) * 8).testCalculation(); } |
