]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAGPUTrackerNVCC.h
coding conventions
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAGPUTrackerNVCC.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 // ************************************************************************
5 // This file is property of and copyright by the ALICE HLT Project        *
6 // ALICE Experiment at CERN, All rights reserved.                         *
7 // See cxx source for full Copyright notice                               *
8 //                                                                        *
9 //*************************************************************************
10
11 //  @file   AliHLTTPCCAGPUTrackerNVCC.h
12 //  @author David Rohr, Sergey Gorbunov
13 //  @date   
14 //  @brief  TPC CA Tracker for the NVIDIA GPU
15 //  @note 
16
17 #ifndef ALIHLTTPCCAGPUTRACKERNVCC_H
18 #define ALIHLTTPCCAGPUTRACKERNVCC_H
19
20 #include "AliHLTTPCCAGPUTracker.h"
21 #include "AliHLTTPCCADef.h"
22 #include "AliHLTTPCCATracker.h"
23 #include "AliHLTLogging.h"
24 #include "AliHLTTPCCASliceOutput.h"
25
26 class AliHLTTPCCARow;
27
28 class AliHLTTPCCAGPUTrackerNVCC : public AliHLTTPCCAGPUTracker, public AliHLTLogging
29 {
30 public:
31         AliHLTTPCCAGPUTrackerNVCC();
32         virtual ~AliHLTTPCCAGPUTrackerNVCC();
33
34         virtual int InitGPU(int sliceCount = 12, int forceDeviceID = -1);
35         virtual int Reconstruct(AliHLTTPCCASliceOutput** pOutput, AliHLTTPCCAClusterData* pClusterData, int fFirstSlice, int fSliceCount = -1);
36         virtual int ExitGPU();
37
38         virtual void SetDebugLevel(const int dwLevel, std::ostream* const NewOutFile = NULL);
39         virtual int SetGPUTrackerOption(char* OptionName, int OptionValue);
40
41         virtual unsigned long long int* PerfTimer(int iSlice, unsigned int i);
42
43         virtual int InitializeSliceParam(int iSlice, AliHLTTPCCAParam &param);
44         virtual void SetOutputControl( AliHLTTPCCASliceOutput::outputControlStruct* val);
45
46         virtual const AliHLTTPCCASliceOutput::outputControlStruct* OutputControl() const;
47         virtual int GetSliceCount() const;
48
49 private:
50         static void* RowMemory(void* const BaseMemory, int iSlice) { return( ((char*) BaseMemory) + iSlice * sizeof(AliHLTTPCCARow) * (HLTCA_ROW_COUNT + 1) ); }
51         static void* CommonMemory(void* const BaseMemory, int iSlice) { return( ((char*) BaseMemory) + HLTCA_GPU_ROWS_MEMORY + iSlice * AliHLTTPCCATracker::CommonMemorySize() ); }
52         static void* SliceDataMemory(void* const BaseMemory, int iSlice) { return( ((char*) BaseMemory) + HLTCA_GPU_ROWS_MEMORY + HLTCA_GPU_COMMON_MEMORY + iSlice * HLTCA_GPU_SLICE_DATA_MEMORY ); }
53         void* GlobalMemory(void* const BaseMemory, int iSlice) const { return( ((char*) BaseMemory) + HLTCA_GPU_ROWS_MEMORY + HLTCA_GPU_COMMON_MEMORY + fSliceCount * (HLTCA_GPU_SLICE_DATA_MEMORY) + iSlice * HLTCA_GPU_GLOBAL_MEMORY ); }
54         void* TracksMemory(void* const BaseMemory, int iSlice) const { return( ((char*) BaseMemory) + HLTCA_GPU_ROWS_MEMORY + HLTCA_GPU_COMMON_MEMORY + fSliceCount * (HLTCA_GPU_SLICE_DATA_MEMORY) + iSlice * HLTCA_GPU_TRACKS_MEMORY ); }
55         void* TrackerMemory(void* const BaseMemory, int iSlice) const { return( ((char*) BaseMemory) + HLTCA_GPU_ROWS_MEMORY + HLTCA_GPU_COMMON_MEMORY + fSliceCount * (HLTCA_GPU_SLICE_DATA_MEMORY + HLTCA_GPU_TRACKS_MEMORY) + iSlice * sizeof(AliHLTTPCCATracker) ); }
56
57         void DumpRowBlocks(AliHLTTPCCATracker* tracker, int iSlice, bool check = true);
58         int GetThread();
59         void ReleaseGlobalLock(void* sem);
60         int CheckMemorySizes(int sliceCount);
61
62         AliHLTTPCCATracker *fGpuTracker; //!
63         void* fGPUMemory; //!
64         void* fHostLockedMemory; //!
65
66         int CUDASync(char* state = "UNKNOWN");
67         template <class T> T* alignPointer(T* ptr, int alignment);
68
69         void StandalonePerfTime(int iSlice, int i);
70
71         int fDebugLevel;                        //Debug Level for GPU Tracker
72         std::ostream* fOutFile;         //Debug Output Stream Pointer
73         unsigned long long int fGPUMemSize;     //Memory Size to allocate on GPU
74
75         void* fpCudaStreams; //!
76
77         int fSliceCount; //!
78
79         static const int fgkNSlices = 36; //!
80         AliHLTTPCCATracker fSlaveTrackers[fgkNSlices]; //!
81 #ifdef HLTCA_GPUCODE
82         bool CudaFailedMsg(cudaError_t error);
83 #endif //HLTCA_GPUCODE
84
85         AliHLTTPCCASliceOutput::outputControlStruct* fOutputControl;
86         
87         static bool fgGPUUsed; //!
88         int fThreadId; //!
89         int fCudaInitialized; //!
90
91         // disable copy
92         AliHLTTPCCAGPUTrackerNVCC( const AliHLTTPCCAGPUTrackerNVCC& );
93         AliHLTTPCCAGPUTrackerNVCC &operator=( const AliHLTTPCCAGPUTrackerNVCC& );
94
95         ClassDef( AliHLTTPCCAGPUTrackerNVCC, 0 )
96 };
97
98 #ifdef R__WIN32
99 #define DLL_EXPORT __declspec(dllexport)
100 #else
101 #define DLL_EXPORT
102 #endif
103
104 extern "C" DLL_EXPORT AliHLTTPCCAGPUTracker* AliHLTTPCCAGPUTrackerNVCCCreate();
105 extern "C" DLL_EXPORT void AliHLTTPCCAGPUTrackerNVCCDestroy(AliHLTTPCCAGPUTracker* ptr);
106
107 #endif //ALIHLTTPCCAGPUTRACKER_H