//***************************************************************************
#include "AliHLTTPCCASliceOutput.h"
-#include "MemoryAssignmentHelpers.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( unsigned int ) + sizeof( int ) + sizeof( unsigned short ) + sizeof( float2 ) + sizeof( float ) + sizeof( UChar_t );
-
- return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
+ return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceOutTrack )*nOfTracks + sizeof(AliHLTTPCCASliceOutCluster)*nOfTrackClusters;
}
-GPUhd() void AliHLTTPCCASliceOutput::SetPointers()
+#ifndef HLTCA_GPUCODE
+
+inline void AssignNoAlignment( int &dst, int &size, int count )
{
- // set all pointers
-
- char *mem = &fMemory[0];
- AssignMemory( fTracks, mem, fNTracks );
- AssignMemory( fClusterUnpackedYZ, mem, fNTrackClusters );
- AssignMemory( fClusterUnpackedX, mem, fNTrackClusters );
- AssignMemory( fClusterIDrc, mem, fNTrackClusters );
- AssignMemory( fClusterHltID, mem, fNTrackClusters );
- AssignMemory( fClusterPackedYZ, mem, fNTrackClusters );
- AssignMemory( fClusterPackedAmp, mem, fNTrackClusters );
+ // assign memory to the pointer dst
+ dst = size;
+ size = dst + count ;
}
+
+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