Project
Loading...
Searching...
No Matches
GPUReconstructionCUDA.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef GPURECONSTRUCTIONCUDA_H
16#define GPURECONSTRUCTIONCUDA_H
17
19#include <vector>
20#include <string>
21
22#ifdef _WIN32
24#else
26#endif
27
28namespace o2::gpu
29{
30struct GPUReconstructionCUDAInternals;
31
33{
34 public:
36 static int32_t GPUFailedMsgAI(const int64_t error, const char* file, int32_t line);
37 void GPUFailedMsgA(const int64_t error, const char* file, int32_t line);
38
39 protected:
41
42 void PrintKernelOccupancies() override;
43
44 template <class T, int32_t I = 0, typename... Args>
46 template <class T, int32_t I = 0, typename... Args>
47 void runKernelBackendInternal(const krnlSetupTime& _xyz, const Args&... args);
48 template <class T, int32_t I = 0>
50 template <class T, int32_t I>
52
53 template <bool multi, class T, int32_t I = 0>
54 static int32_t getRTCkernelNum(int32_t k = -1);
55
56 void getRTCKernelCalls(std::vector<std::string>& kernels);
57
59};
60
61class GPUReconstructionCUDA : public GPUReconstructionKernels<GPUReconstructionCUDABackend>
62{
63 public:
66
67 protected:
68 int32_t InitDevice_Runtime() override;
69 int32_t ExitDevice_Runtime() override;
71
72 std::unique_ptr<gpu_reconstruction_kernels::threadContext> GetThreadContext() override;
73 void SynchronizeGPU() override;
74 int32_t GPUDebug(const char* state = "UNKNOWN", int32_t stream = -1, bool force = false) override;
75 void SynchronizeStream(int32_t stream) override;
76 void SynchronizeEvents(deviceEvent* evList, int32_t nEvents = 1) override;
77 void StreamWaitForEvents(int32_t stream, deviceEvent* evList, int32_t nEvents = 1) override;
78 bool IsEventDone(deviceEvent* evList, int32_t nEvents = 1) override;
79 int32_t registerMemoryForGPU_internal(const void* ptr, size_t size) override;
80 int32_t unregisterMemoryForGPU_internal(const void* ptr) override;
81
82 size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, deviceEvent* ev = nullptr) override;
83 size_t GPUMemCpy(void* dst, const void* src, size_t size, int32_t stream, int32_t toGPU, deviceEvent* ev = nullptr, deviceEvent* evList = nullptr, int32_t nEvents = 1) override;
84 void ReleaseEvent(deviceEvent ev) override;
85 void RecordMarker(deviceEvent* ev, int32_t stream) override;
86
87 void GetITSTraits(std::unique_ptr<o2::its::TrackerTraits>* trackerTraits, std::unique_ptr<o2::its::VertexerTraits>* vertexerTraits, std::unique_ptr<o2::its::TimeFrame>* timeFrame) override;
88
89#ifndef __HIPCC__ // CUDA
90 bool CanQueryMaxMemory() override { return true; }
91 int32_t PrepareTextures() override;
92 void startGPUProfiling() override;
93 void endGPUProfiling() override;
94#else // HIP
95 void* getGPUPointer(void* ptr) override;
96#endif
97
98 private:
99 int32_t genRTC(std::string& filename, uint32_t& nCompile);
100 void genAndLoadRTC();
101 void loadKernelModules(bool perKernel, bool perSingleMulti = true);
102 const char *mRtcSrcExtension = ".src", *mRtcBinExtension = ".o";
103};
104
105} // namespace o2::gpu
106
107#endif
benchmark::State & state
o2::gpu::GPUReconstruction * GPUReconstruction_Create_CUDA(const o2::gpu::GPUSettingsDeviceBackend &cfg)
TBranch * ptr
void GPUFailedMsgA(const int64_t error, const char *file, int32_t line)
static int32_t GPUFailedMsgAI(const int64_t error, const char *file, int32_t line)
void runKernelBackendInternal(const krnlSetupTime &_xyz, const Args &... args)
void getRTCKernelCalls(std::vector< std::string > &kernels)
static int32_t getRTCkernelNum(int32_t k=-1)
GPUReconstructionCUDAInternals * mInternals
GPUReconstructionCUDABackend(const GPUSettingsDeviceBackend &cfg)
gpu_reconstruction_kernels::krnlProperties getKernelPropertiesBackend()
int32_t runKernelBackend(const krnlSetupArgs< T, I, Args... > &args)
int32_t ExitDevice_Runtime() override
int32_t unregisterMemoryForGPU_internal(const void *ptr) override
bool IsEventDone(deviceEvent *evList, int32_t nEvents=1) override
GPUReconstructionCUDA(const GPUSettingsDeviceBackend &cfg)
size_t WriteToConstantMemory(size_t offset, const void *src, size_t size, int32_t stream=-1, deviceEvent *ev=nullptr) override
void UpdateAutomaticProcessingSettings() override
void startGPUProfiling() override
int32_t InitDevice_Runtime() override
void StreamWaitForEvents(int32_t stream, deviceEvent *evList, int32_t nEvents=1) override
int32_t PrepareTextures() override
void RecordMarker(deviceEvent *ev, int32_t stream) override
void SynchronizeEvents(deviceEvent *evList, int32_t nEvents=1) override
size_t GPUMemCpy(void *dst, const void *src, size_t size, int32_t stream, int32_t toGPU, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1) override
int32_t registerMemoryForGPU_internal(const void *ptr, size_t size) override
int32_t GPUDebug(const char *state="UNKNOWN", int32_t stream=-1, bool force=false) override
void SynchronizeStream(int32_t stream) override
void GetITSTraits(std::unique_ptr< o2::its::TrackerTraits > *trackerTraits, std::unique_ptr< o2::its::VertexerTraits > *vertexerTraits, std::unique_ptr< o2::its::TimeFrame > *timeFrame) override
std::unique_ptr< gpu_reconstruction_kernels::threadContext > GetThreadContext() override
void ReleaseEvent(deviceEvent ev) override
virtual void * getGPUPointer(void *ptr)
GLenum src
Definition glcorearb.h:1767
GLsizeiptr size
Definition glcorearb.h:659
GLenum GLenum dst
Definition glcorearb.h:1767
GLintptr offset
Definition glcorearb.h:660
GLuint GLuint stream
Definition glcorearb.h:1806
std::string filename()
const int nEvents
Definition test_Fifo.cxx:27