]>
Commit | Line | Data |
---|---|---|
b22af1bf | 1 | // @(#) $Id: AliHLTTPCCAStartHitsFinder.cxx 27042 2008-07-02 12:06:02Z richterm $ |
2 | // ************************************************************************** | |
3 | // This file is property of and copyright by the ALICE HLT Project * | |
4 | // ALICE Experiment at CERN, All rights reserved. * | |
5 | // * | |
6 | // Primary Authors: David Rohr <drohr@kip.uni-heidelberg.de> * | |
7 | // for The ALICE HLT Project. * | |
8 | // * | |
9 | // Permission to use, copy, modify and distribute this software and its * | |
10 | // documentation strictly for non-commercial purposes is hereby granted * | |
11 | // without fee, provided that the above copyright notice appears in all * | |
12 | // copies and that both the copyright notice and this permission notice * | |
13 | // appear in the supporting documentation. The authors make no claims * | |
14 | // about the suitability of this software for any purpose. It is * | |
15 | // provided "as is" without express or implied warranty. * | |
16 | // * | |
17 | //*************************************************************************** | |
18 | ||
19 | #include "AliHLTTPCCAStartHitsSorter.h" | |
20 | #include "AliHLTTPCCATracker.h" | |
21 | ||
22 | GPUd() void AliHLTTPCCAStartHitsSorter::Thread | |
23 | ( int nBlocks, int nThreads, int iBlock, int iThread, int iSync, | |
43422963 | 24 | GPUsharedref() MEM_LOCAL(AliHLTTPCCASharedMemory) &s, GPUconstant() MEM_CONSTANT(AliHLTTPCCATracker) &tracker ) |
b22af1bf | 25 | { |
26 | //Sorts the Start Hits by Row Index and create RowBlock Data | |
2fba026d | 27 | if ( iSync == 0 ) { |
28 | if ( iThread == 0 ) { | |
29 | const int gpuFixedBlockCount = tracker.GPUParametersConst()->fGPUFixedBlockCount; | |
30 | const int tmpNRows = tracker.Param().NRows() - 6; | |
31 | const int nRows = iBlock == (nBlocks - 1) ? (tmpNRows - (tmpNRows / nBlocks) * (nBlocks - 1)) : (tmpNRows / nBlocks); | |
32 | const int nStartRow = (tmpNRows / nBlocks) * iBlock + 1; | |
33 | int startOffset2 = 0; | |
b22af1bf | 34 | |
2fba026d | 35 | #ifndef HLTCA_GPU_ALTERNATIVE_SCHEDULER |
36 | int startOffset = 0; | |
37 | int previousBlockEndTracklet = 0; | |
38 | int nCurrentBlock = 0; | |
39 | #endif | |
b22af1bf | 40 | |
2fba026d | 41 | for (int ir = 1;ir < tracker.Param().NRows() - 5;ir++) |
b22af1bf | 42 | { |
2fba026d | 43 | if (ir < nStartRow) |
44 | startOffset2 += tracker.RowStartHitCountOffset()[ir].x; | |
45 | ||
46 | #ifndef HLTCA_GPU_ALTERNATIVE_SCHEDULER | |
47 | if (iBlock == nBlocks - 1 && nCurrentBlock < gpuFixedBlockCount) | |
b22af1bf | 48 | { |
2fba026d | 49 | startOffset += tracker.RowStartHitCountOffset()[ir].x; |
50 | for (int i = previousBlockEndTracklet + HLTCA_GPU_THREAD_COUNT;i <= startOffset;i += HLTCA_GPU_THREAD_COUNT) | |
51 | { | |
52 | if (previousBlockEndTracklet / HLTCA_GPU_THREAD_COUNT != i / HLTCA_GPU_THREAD_COUNT) | |
53 | { | |
54 | tracker.BlockStartingTracklet()[nCurrentBlock].x = previousBlockEndTracklet; | |
55 | tracker.BlockStartingTracklet()[nCurrentBlock++].y = HLTCA_GPU_THREAD_COUNT; | |
56 | previousBlockEndTracklet += HLTCA_GPU_THREAD_COUNT; | |
57 | if (nCurrentBlock == gpuFixedBlockCount) | |
58 | { | |
59 | break; | |
60 | } | |
61 | } | |
62 | } | |
63 | if ((ir + 1) % HLTCA_GPU_SCHED_ROW_STEP == 0 && nCurrentBlock < gpuFixedBlockCount) | |
64 | { | |
65 | if (previousBlockEndTracklet != startOffset) | |
66 | { | |
67 | tracker.BlockStartingTracklet()[nCurrentBlock].x = previousBlockEndTracklet; | |
68 | tracker.BlockStartingTracklet()[nCurrentBlock++].y = startOffset - previousBlockEndTracklet; | |
69 | previousBlockEndTracklet = startOffset; | |
70 | } | |
71 | } | |
b22af1bf | 72 | if (nCurrentBlock == gpuFixedBlockCount) |
73 | { | |
2fba026d | 74 | tracker.GPUParameters()->fScheduleFirstDynamicTracklet = previousBlockEndTracklet; |
b22af1bf | 75 | } |
76 | } | |
77 | } | |
2fba026d | 78 | if (iBlock == nBlocks - 1) |
b22af1bf | 79 | { |
2fba026d | 80 | if (nCurrentBlock < gpuFixedBlockCount) |
b22af1bf | 81 | { |
82 | tracker.BlockStartingTracklet()[nCurrentBlock].x = previousBlockEndTracklet; | |
83 | tracker.BlockStartingTracklet()[nCurrentBlock++].y = startOffset - previousBlockEndTracklet; | |
2fba026d | 84 | tracker.GPUParameters()->fScheduleFirstDynamicTracklet = startOffset; |
b22af1bf | 85 | } |
2fba026d | 86 | for (int i = nCurrentBlock;i < nBlocks;i++) |
87 | { | |
88 | tracker.BlockStartingTracklet()[i].x = 0; | |
89 | tracker.BlockStartingTracklet()[i].y = 0; | |
90 | } | |
91 | #endif | |
b22af1bf | 92 | } |
2fba026d | 93 | s.fStartOffset = startOffset2; |
94 | s.fNRows = nRows; | |
95 | s.fStartRow = nStartRow; | |
b22af1bf | 96 | } |
2fba026d | 97 | } else if ( iSync == 1 ) { |
98 | int startOffset = s.fStartOffset; | |
99 | for (int ir = 0;ir < s.fNRows;ir++) | |
b22af1bf | 100 | { |
43422963 | 101 | GPUglobalref() AliHLTTPCCAHitId *const startHits = tracker.TrackletStartHits(); |
102 | GPUglobalref() AliHLTTPCCAHitId *const tmpStartHits = tracker.TrackletTmpStartHits(); | |
2fba026d | 103 | const int tmpLen = tracker.RowStartHitCountOffset()[ir + s.fStartRow].x; //Length of hits in row stored by StartHitsFinder |
104 | const int tmpOffset = tracker.RowStartHitCountOffset()[ir + s.fStartRow].y; //Offset of first hit in row of unsorted array by StartHitsFinder | |
105 | if (iThread == 0) | |
106 | tracker.RowStartHitCountOffset()[ir + s.fStartRow].z = startOffset; //Store New Offset Value of sorted array | |
b22af1bf | 107 | |
2fba026d | 108 | for (int j = iThread;j < tmpLen;j += nThreads) |
109 | { | |
110 | startHits[startOffset + j] = tmpStartHits[tmpOffset + j]; | |
111 | } | |
112 | startOffset += tmpLen; | |
b22af1bf | 113 | } |
2fba026d | 114 | } |
b22af1bf | 115 | } |
116 |