Project
Loading...
Searching...
No Matches
GPUTPCSectorDebugSortKernels.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "GPUParam.h"
16#include "GPUTPCClusterData.h"
17#include "GPUTPCHit.h"
18#include "GPUTPCTrackingData.h"
19#include "GPUProcessor.h"
20#include "GPUO2DataTypes.h"
21#include "GPUCommonMath.h"
22#include "GPUCommonAlgorithm.h"
24
25using namespace o2::gpu;
26
27template <>
28GPUdii() void GPUTPCSectorDebugSortKernels::Thread<GPUTPCSectorDebugSortKernels::hitData>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& GPUrestrict() tracker)
29{
30 const uint32_t iRow = iBlock;
31 const GPUTPCRow& GPUrestrict() row = tracker.Data().Row(iRow);
32 const GPUTPCGrid& GPUrestrict() grid = row.Grid();
33 for (uint32_t i = iThread; i < grid.N(); i += nThreads) {
34 uint32_t jMin = tracker.Data().FirstHitInBin(row, i);
35 uint32_t jMax = tracker.Data().FirstHitInBin(row, i + 1);
36 const uint32_t n = jMax - jMin;
37 calink* GPUrestrict() tmp1 = tracker.Data().HitLinkUpData(row) + jMin;
38 auto* GPUrestrict() tmp2 = tracker.Data().HitWeights() + row.HitNumberOffset() + jMin;
39 cahit2* GPUrestrict() hitData = tracker.Data().HitData(row) + jMin;
40 int32_t* GPUrestrict() clusterId = tracker.Data().ClusterDataIndex() + row.HitNumberOffset() + jMin;
41 for (uint32_t j = 0; j < n; j++) {
42 tmp1[j] = j;
43 }
44 GPUCommonAlgorithm::sort(tmp1, tmp1 + n, [&hitData, &clusterId](const calink& a, const calink& b) {
45 if (hitData[a].x != hitData[b].x) {
46 return hitData[a].x < hitData[b].x;
47 }
48 if (hitData[a].y != hitData[b].y) {
49 return hitData[a].y < hitData[b].y;
50 }
51 return clusterId[a] < clusterId[b];
52 });
53 for (uint32_t j = 0; j < n; j++) {
54 tmp2[j] = hitData[j].x;
55 }
56 for (uint32_t j = 0; j < n; j++) {
57 hitData[j].x = tmp2[tmp1[j]];
58 }
59 for (uint32_t j = 0; j < n; j++) {
60 tmp2[j] = hitData[j].y;
61 }
62 for (uint32_t j = 0; j < n; j++) {
63 hitData[j].y = tmp2[tmp1[j]];
64 }
65 for (uint32_t j = 0; j < n; j++) {
66 tmp2[j] = clusterId[j];
67 }
68 for (uint32_t j = 0; j < n; j++) {
69 clusterId[j] = tmp2[tmp1[j]];
70 }
71 }
72}
73
74template <>
75GPUdii() void GPUTPCSectorDebugSortKernels::Thread<GPUTPCSectorDebugSortKernels::startHits>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& GPUrestrict() tracker)
76{
77 if (iThread || iBlock) {
78 return;
79 }
80 GPUCommonAlgorithm::sortDeviceDynamic(tracker.TrackletStartHits(), tracker.TrackletStartHits() + *tracker.NStartHits(), [](const GPUTPCHitId& a, const GPUTPCHitId& b) {
81 if (a.RowIndex() != b.RowIndex()) {
82 return (a.RowIndex() < b.RowIndex());
83 }
84 return (a.HitIndex() < b.HitIndex());
85 });
86}
87
88template <>
89GPUdii() void GPUTPCSectorDebugSortKernels::Thread<GPUTPCSectorDebugSortKernels::sectorTracks>(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread, GPUsharedref() GPUSharedMemory& smem, processorType& GPUrestrict() tracker)
90{
91 if (iThread || iBlock) {
92 return;
93 }
94 auto sorter = [&tracker](const GPUTPCTrack& trk1, const GPUTPCTrack& trk2) {
95 if (trk1.NHits() != trk2.NHits()) {
96 return trk1.NHits() > trk2.NHits();
97 }
98 if (trk1.Param().Y() != trk2.Param().Y()) {
99 return trk1.Param().Y() > trk2.Param().Y();
100 }
101 if (trk1.Param().Z() != trk2.Param().Z()) {
102 return trk1.Param().Z() > trk2.Param().Z();
103 }
104 if (tracker.TrackHits()[trk1.FirstHitID()].RowIndex() != tracker.TrackHits()[trk2.FirstHitID()].RowIndex()) {
105 return tracker.TrackHits()[trk1.FirstHitID()].RowIndex() > tracker.TrackHits()[trk2.FirstHitID()].RowIndex();
106 }
107 return tracker.TrackHits()[trk1.FirstHitID()].HitIndex() > tracker.TrackHits()[trk2.FirstHitID()].HitIndex();
108 };
109 GPUCommonAlgorithm::sortDeviceDynamic(tracker.Tracks(), tracker.Tracks() + tracker.CommonMemory()->nLocalTracks, sorter);
110 GPUCommonAlgorithm::sortDeviceDynamic(tracker.Tracks() + tracker.CommonMemory()->nLocalTracks, tracker.Tracks() + *tracker.NTracks(), sorter);
111}
int32_t i
#define GPUsharedref()
#define GPUrestrict()
GPUdii() void GPUTPCSectorDebugSortKernels
uint32_t j
Definition RawData.h:0
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
uint32_t calink
Definition GPUTPCDef.h:30
std::vector< int > row