fix of segm. violation in the GPU tracker (by D.Rohr)
authorsgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 May 2012 10:34:31 +0000 (10:34 +0000)
committersgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 May 2012 10:34:31 +0000 (10:34 +0000)
HLT/TPCLib/tracking-ca/AliHLTTPCCACompressedInputData.h
HLT/TPCLib/tracking-ca/AliHLTTPCCASliceData.cxx
HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutTrack.h
HLT/TPCLib/tracking-ca/AliHLTTPCCATrackerComponent.cxx
HLT/TPCLib/tracking-ca/AliHLTTPCCATrackerFramework.cxx

index 785f163..6823427 100644 (file)
@@ -2,7 +2,11 @@
 #ifndef ALIHLTTPCCACOMPRESSEDINPUTDATA_H
 #define ALIHLTTPCCACOMPRESSEDINPUTDATA_H
 
+#ifdef HLTCA_STANDALONE
+#include "AliHLTTPCRootTypes.h"
+#else
 #include "Rtypes.h"
+#endif
 
 /**
  * @struct AliHLTTPCCACompressedCluster
index 91d1e60..ed878da 100644 (file)
@@ -167,15 +167,26 @@ size_t AliHLTTPCCASliceData::SetPointers(const AliHLTTPCCAClusterData *data, boo
     // HitWeights, ClusterDataIndex
     fNumberOfHitsPlusAlign * 2 * sizeof( int );
 
-  if ( 1 ){// fMemorySize < memorySize ) { // release the memory on CPU
-       fMemorySize = memorySize;
-       if (allocate && !fIsGpuSliceData)
+  if ( 1 )// fMemorySize < memorySize ) { // release the memory on CPU
+  {
+       fMemorySize = memorySize + 4;
+       if (allocate)
        {
-               if (fMemory)
+               if (!fIsGpuSliceData)
+               {
+                       if (fMemory)
+                       {
+                               delete[] fMemory;
+                       }
+                       fMemory = new char[fMemorySize];// kVectorAlignment];
+               }
+               else
                {
-                       delete[] fMemory;
+                       if (fMemorySize > HLTCA_GPU_SLICE_DATA_MEMORY)
+                       {
+                               return(0);
+                       }
                }
-         fMemory = new char[fMemorySize + 4];// kVectorAlignment];
        }
   }
 
@@ -209,7 +220,7 @@ void AliHLTTPCCASliceData::InitFromClusterData( const AliHLTTPCCAClusterData &da
   }
   const int memorySize = fNumberOfHits * sizeof( short_v::Type )
   */
-  SetPointers(&data, true);
+  if (SetPointers(&data, true) == 0) return;
 
   ////////////////////////////////////
   // 2. fill HitData and FirstHitInBin
index 7b164ca..6617a20 100644 (file)
@@ -59,8 +59,11 @@ class AliHLTTPCCASliceOutTrack
     AliHLTTPCCABaseTrackParam fParam; //* fitted track parameters at its innermost cluster
     int fNClusters;             //* number of track clusters
        int fLocalTrackId;                      //See AliHLTPCCATrack.h
+#ifdef HLTCA_STANDALONE
+    AliHLTTPCCASliceOutCluster fClusters[1]; //* track clusters
+#else
     AliHLTTPCCASliceOutCluster fClusters[0]; //* track clusters
-
+#endif
        static const int fgkMaxTrackIdInSlice = 4096;
 };
 
index f928900..bd3e6e6 100644 (file)
@@ -631,8 +631,15 @@ int AliHLTTPCCATrackerComponent::DoEvent
          Logging( kHLTLogDebug, "HLT::TPCCATracker::DoEvent", "Reading hits",
                           "Total %d hits to read for slice %d", nClustersTotal, slice );
 
+         if (nClustersTotal > 500000)
+         {
+                 HLTWarning( "Too many clusters in tracker input: Slice %d, Number of Clusters %d, some clusters are droped", slice, nClustersTotal );
+                 nClustersTotal = 500000;
+         }
+
 
          clusterData[islice].StartReading( slice, nClustersTotal );
+         int nSliceClust = 0;
 
          for ( std::vector<unsigned long>::iterator pIter = patchIndices.begin(); pIter != patchIndices.end(); pIter++ ) {
                ndx = *pIter;
@@ -650,7 +657,11 @@ int AliHLTTPCCATrackerComponent::DoEvent
                      HLTError( "Wrong TPC cluster with row number %d received", c->fPadRow );
                      continue;
                    }
-                   clusterData[islice].ReadCluster( c->fID, c->fPadRow, c->fX, c->fY, c->fZ, c->fCharge );
+                       if (nSliceClust < nClustersTotal)
+                       {
+                     clusterData[islice].ReadCluster( c->fID, c->fPadRow, c->fX, c->fY, c->fZ, c->fCharge );
+                         nSliceClust++;
+                       }
                  }           
                } else         
                if ( iter->fDataType == AliHLTTPCCADefinitions::fgkCompressedInputDataType){
@@ -683,8 +694,9 @@ int AliHLTTPCCATrackerComponent::DoEvent
                      
                      UInt_t cluId = AliHLTTPCSpacePointData::GetID( jslice, jpatch, nPatchClust );
                      //cout<<"clu "<<i<<": "<<x<<" "<<y<<" "<<z<<" "<<cluId<<endl;
-                     if ( CAMath::Abs( z ) <= fClusterZCut ){
+                     if ( CAMath::Abs( z ) <= fClusterZCut && nSliceClust < nClustersTotal){
                        clusterData[islice].ReadCluster( cluId, jrow, x, y, z, 0 );
+                       nSliceClust++;
                      }
                      nPatchClust++;              
                    }
@@ -726,7 +738,7 @@ int AliHLTTPCCATrackerComponent::DoEvent
   for (int islice = 0;islice < slicecount;islice++)
   {
     if( outputControl.fEndOfSpace ){
-      HLTWarning( "Output buffer size exceed, tracks are not stored" );
+      HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), tracks are not stored", maxBufferSize, mySize );
       ret = -ENOSPC;
       error = 1;
       break;     
@@ -744,7 +756,7 @@ int AliHLTTPCCATrackerComponent::DoEvent
       }
     else
       {
-       HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), tracks are not stored", maxBufferSize, mySize );
+       HLTWarning( "Error during Tracking, no tracks stored" );
        mySize = 0;
        ret = -ENOSPC;
        ntracks = 0;
index 56d409a..804803a 100644 (file)
@@ -283,6 +283,7 @@ AliHLTTPCCATrackerFramework::~AliHLTTPCCATrackerFramework()
        {
                if (fGPUTracker)
                {
+                       ExitGPU();
 #ifdef R__WIN32
                        FARPROC destroyFunc = GetProcAddress(hGPULib, "AliHLTTPCCAGPUTrackerNVCCDestroy");
 #else