Skip to content

Commit 0d77bb7

Browse files
correct result
1 parent c6039f5 commit 0d77bb7

26 files changed

Lines changed: 344 additions & 408 deletions

GPU/Common/GPUCommonAlgorithm.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define GPUCOMMONALGORITHM_H
1717

1818
#include "GPUCommonDef.h"
19+
#include "MemLayout.h"
1920

2021
#if !defined(GPUCA_GPUCODE) // Could also enable custom search on the CPU, but it is not always faster, so we stick to std::sort
2122
#include <algorithm>
@@ -28,19 +29,20 @@ namespace o2::gpu
2829
{
2930
class GPUCommonAlgorithm
3031
{
32+
3133
public:
3234
template <class T>
33-
GPUd() static void sort(T* begin, T* end);
35+
GPUd() static void sort(T begin, T end);
3436
template <class T>
3537
GPUd() static void sortInBlock(T* begin, T* end);
3638
template <class T>
37-
GPUd() static void sortDeviceDynamic(T* begin, T* end);
39+
GPUd() static void sortDeviceDynamic(T begin, T end);
3840
template <class T, class S>
39-
GPUd() static void sort(T* begin, T* end, const S& comp);
41+
GPUd() static void sort(T begin, T end, const S& comp);
4042
template <class T, class S>
4143
GPUd() static void sortInBlock(T* begin, T* end, const S& comp);
4244
template <class T, class S>
43-
GPUd() static void sortDeviceDynamic(T* begin, T* end, const S& comp);
45+
GPUd() static void sortDeviceDynamic(T begin, T end, const S& comp);
4446
#ifndef __OPENCL__
4547
template <class T, class S>
4648
GPUh() static void sortOnDevice(auto* rec, int32_t stream, T* begin, size_t N, const S& comp);
@@ -224,7 +226,7 @@ namespace o2::gpu
224226
{
225227

226228
template <class T>
227-
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T* begin, T* end)
229+
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T begin, T end)
228230
{
229231
#ifndef GPUCA_GPUCODE
230232
GPUCommonAlgorithm::sort(begin, end);
@@ -234,7 +236,7 @@ GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T* begin, T* end)
234236
}
235237

236238
template <class T, class S>
237-
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T* begin, T* end, const S& comp)
239+
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T begin, T end, const S& comp)
238240
{
239241
GPUCommonAlgorithm::sort(begin, end, comp);
240242
}
@@ -248,7 +250,7 @@ namespace o2::gpu
248250
{
249251

250252
template <class T>
251-
GPUdi() void GPUCommonAlgorithm::sort(T* begin, T* end)
253+
GPUdi() void GPUCommonAlgorithm::sort(T begin, T end)
252254
{
253255
#ifdef GPUCA_ALGORITHM_STD
254256
std::sort(begin, end);
@@ -258,7 +260,7 @@ GPUdi() void GPUCommonAlgorithm::sort(T* begin, T* end)
258260
}
259261

260262
template <class T, class S>
261-
GPUdi() void GPUCommonAlgorithm::sort(T* begin, T* end, const S& comp)
263+
GPUdi() void GPUCommonAlgorithm::sort(T begin, T end, const S& comp)
262264
{
263265
#ifdef GPUCA_ALGORITHM_STD
264266
std::sort(begin, end, comp);

GPU/Common/GPUCommonAlgorithmThrust.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
#pragma GCC diagnostic push
2020
#pragma GCC diagnostic ignored "-Wshadow"
2121
#include <thrust/sort.h>
22+
#include <thrust/iterator/iterator_traits.h>
2223
#include <thrust/execution_policy.h>
2324
#include <thrust/device_ptr.h>
2425
#pragma GCC diagnostic pop
2526

2627
#include "GPUCommonDef.h"
2728
#include "GPUCommonHelpers.h"
29+
#include "GPUTPCTrack.h"
2830

2931
#ifndef __HIPCC__ // CUDA
3032
#include <cub/cub.cuh>
@@ -81,19 +83,15 @@ GPUdi() void GPUCommonAlgorithm::sortInBlock(T* begin, T* end, const S& comp)
8183
*/
8284

8385
template <class T>
84-
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T* begin, T* end)
86+
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T begin, T end)
8587
{
86-
thrust::device_ptr<T> thrustBegin(begin);
87-
thrust::device_ptr<T> thrustEnd(end);
88-
thrust::sort(GPUCA_THRUST_NAMESPACE::par, thrustBegin, thrustEnd);
88+
thrust::sort(GPUCA_THRUST_NAMESPACE::par, begin, end);
8989
}
9090

9191
template <class T, class S>
92-
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T* begin, T* end, const S& comp)
92+
GPUdi() void GPUCommonAlgorithm::sortDeviceDynamic(T begin, T end, const S& comp)
9393
{
94-
thrust::device_ptr<T> thrustBegin(begin);
95-
thrust::device_ptr<T> thrustEnd(end);
96-
thrust::sort(GPUCA_THRUST_NAMESPACE::par, thrustBegin, thrustEnd, comp);
94+
thrust::sort(GPUCA_THRUST_NAMESPACE::par, begin, end, comp);
9795
}
9896

9997
#ifndef GPUCA_GPUCODE_COMPILEKERNELS

0 commit comments

Comments
 (0)