]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutput.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCASliceOutput.cxx
index 220beb0326eb3a55076b6adfed49605482ae4734..3ecdcd44ed61dd8ffaf3614fa4cb40e3e6c88ba9 100644 (file)
 
 #include "AliHLTTPCCASliceOutput.h"
 
-GPUhd() int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
+int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
 {
   // calculate the amount of memory [bytes] needed for the event
 
-  const int kClusterDataSize = sizeof(  int ) + sizeof( unsigned short ) + sizeof( float2 ) + sizeof( float ) + sizeof( UChar_t ) + sizeof( UChar_t );
-
-  return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
+  return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceOutTrack )*nOfTracks + sizeof(AliHLTTPCCASliceOutCluster)*nOfTrackClusters;
 }
 
-template<typename T> inline void AssignNoAlignment( T *&dst, char *&mem, int count )
+#ifndef HLTCA_GPUCODE
+
+inline void AssignNoAlignment( int &dst, int &size, int count )
 {
   // assign memory to the pointer dst
-  dst = (T*) mem;
-  mem = (char *)(dst + count);
+  dst = size;
+  size = dst + count ;
 }
 
-GPUhd() void AliHLTTPCCASliceOutput::SetPointers()
-{
-  // set all pointers
-
-  char *mem = &fMemory[0];
-  AssignNoAlignment( fTracks,            mem, fNTracks );
-  AssignNoAlignment( fClusterUnpackedYZ, mem, fNTrackClusters );
-  AssignNoAlignment( fClusterUnpackedX,  mem, fNTrackClusters );
-  AssignNoAlignment( fClusterId,         mem, fNTrackClusters );
-  AssignNoAlignment( fClusterPackedYZ,   mem, fNTrackClusters );
-  AssignNoAlignment( fClusterRow,        mem, fNTrackClusters );
-  AssignNoAlignment( fClusterPackedAmp,  mem, fNTrackClusters );
 
+void AliHLTTPCCASliceOutput::Allocate(AliHLTTPCCASliceOutput* &ptrOutput, int nTracks, int nTrackHits, outputControlStruct* outputControl)
+{
+       //Allocate All memory needed for slice output
+       const int memsize =  EstimateSize(nTracks, nTrackHits);
+
+       if (outputControl->fOutputPtr)
+       {
+               if (outputControl->fOutputMaxSize < memsize)
+               {
+                       outputControl->fEndOfSpace = 1;
+                       ptrOutput = NULL;
+                       return;
+               }
+               ptrOutput = (AliHLTTPCCASliceOutput*) outputControl->fOutputPtr;
+               outputControl->fOutputPtr += memsize;
+               outputControl->fOutputMaxSize -= memsize;
+       }
+       else
+       {
+               if (ptrOutput) free(ptrOutput);
+               ptrOutput = (AliHLTTPCCASliceOutput*) malloc(memsize);
+       }
+       ptrOutput->SetMemorySize(memsize);
 }
-
+#endif