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. *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
10 // Permission to use, copy, modify and distribute this software and its *
11 // documentation strictly for non-commercial purposes is hereby granted *
12 // without fee, provided that the above copyright notice appears in all *
13 // copies and that both the copyright notice and this permission notice *
14 // appear in the supporting documentation. The authors make no claims *
15 // about the suitability of this software for any purpose. It is *
16 // provided "as is" without express or implied warranty. *
18 //***************************************************************************
20 #include "AliHLTTPCCAStartHitsFinder.h"
21 #include "AliHLTTPCCATracker.h"
22 #include "AliHLTTPCCAMath.h"
24 GPUd() void AliHLTTPCCAStartHitsFinder::Thread
25 ( int /*nBlocks*/, int nThreads, int iBlock, int iThread, int iSync,
26 AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
28 // find start hits for tracklets
32 s.fNRows = tracker.Param().NRows();
35 if ( s.fIRow <= s.fNRows - 4 ) {
36 s.fNHits = tracker.Row( s.fIRow ).NHits();
37 if ( s.fNHits >= ALIHLTTPCCASTARTHITSFINDER_MAX_FROWSTARTHITS ) s.fNHits = ALIHLTTPCCASTARTHITSFINDER_MAX_FROWSTARTHITS - 1;
40 } else if ( iSync == 1 ) {
41 const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
42 const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRow + 2 );
43 for ( int ih = iThread; ih < s.fNHits; ih += nThreads ) {
44 if (tracker.HitLinkDownData(row, ih) < 0 && tracker.HitLinkUpData(row, ih) >= 0 && tracker.HitLinkUpData(rowUp, tracker.HitLinkUpData(row, ih)) >= 0) {
45 int oldNRowStartHits = CAMath::AtomicAdd( &s.fNRowStartHits, 1 );
46 s.fRowStartHits[oldNRowStartHits].Set( s.fIRow, ih );
49 } else if ( iSync == 2 ) {
51 int nOffset = CAMath::AtomicAdd( tracker.NTracklets(), s.fNRowStartHits );
53 if (nOffset + s.fNRowStartHits >= HLTCA_GPU_MAX_TRACKLETS)
\r
55 tracker.GPUParameters()->fGPUError = HLTCA_GPU_ERROR_TRACKLET_OVERFLOW;
\r
56 CAMath::AtomicExch( tracker.NTracklets(), 0 );
\r
60 s.fNOldStartHits = nOffset;
61 #ifdef HLTCA_GPU_SORT_STARTHITS
62 tracker.RowStartHitCountOffset()[s.fIRow].x = s.fNRowStartHits;
63 tracker.RowStartHitCountOffset()[s.fIRow].y = nOffset;
66 } else if ( iSync == 3 ) {
67 #ifdef HLTCA_GPU_SORT_STARTHITS
68 AliHLTTPCCAHitId *const startHits = tracker.TrackletTmpStartHits();
70 AliHLTTPCCAHitId *const startHits = tracker.TrackletStartHits();
72 for ( int ish = iThread; ish < s.fNRowStartHits; ish += nThreads ) {
73 startHits[s.fNOldStartHits+ish] = s.fRowStartHits[ish];