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
37 protected:
39
40 void PrintKernelOccupancies() override;
41 virtual int32_t GPUChkErrInternal(const int64_t error, const char* file, int32_t line) const override;
42
43 template <class T, int32_t I = 0, typename... Args>
45 template <class T, int32_t I = 0, typename... Args>
46 void runKernelBackendInternal(const krnlSetupTime& _xyz, const Args&... args);
47
48 void getRTCKernelCalls(std::vector<std::string>& kernels);
49
50 template <class T, class S>
51 friend GPUh() void GPUCommonAlgorithm::sortOnDevice(auto* rec, int32_t stream, T* begin, size_t N, const S& comp);
53};
54
56{
57 public:
60
61 protected:
62 int32_t InitDevice_Runtime() override;
63 int32_t ExitDevice_Runtime() override;
65
66 std::unique_ptr<gpu_reconstruction_kernels::threadContext> GetThreadContext() override;
67 void SynchronizeGPU() override;
68 int32_t GPUDebug(const char* state = "UNKNOWN", int32_t stream = -1, bool force = false) override;
69 void SynchronizeStream(int32_t stream) override;
70 void SynchronizeEvents(deviceEvent* evList, int32_t nEvents = 1) override;
71 void StreamWaitForEvents(int32_t stream, deviceEvent* evList, int32_t nEvents = 1) override;
72 bool IsEventDone(deviceEvent* evList, int32_t nEvents = 1) override;
73 int32_t registerMemoryForGPU_internal(const void* ptr, size_t size) override;
74 int32_t unregisterMemoryForGPU_internal(const void* ptr) override;
75
76 size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, deviceEvent* ev = nullptr) override;
77 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;
78 void ReleaseEvent(deviceEvent ev) override;
79 void RecordMarker(deviceEvent* ev, int32_t stream) override;
80
81 void GetITSTraits(std::unique_ptr<o2::its::TrackerTraits>* trackerTraits, std::unique_ptr<o2::its::VertexerTraits>* vertexerTraits, std::unique_ptr<o2::its::TimeFrame>* timeFrame) override;
82
83#ifndef __HIPCC__ // CUDA
84 bool CanQueryMaxMemory() override { return true; }
85 int32_t PrepareTextures() override;
86 void startGPUProfiling() override;
87 void endGPUProfiling() override;
88#else // HIP
89 void* getGPUPointer(void* ptr) override;
90#endif
91
92 private:
93 int32_t genRTC(std::string& filename, uint32_t& nCompile);
94 void genAndLoadRTC();
95 void loadKernelModules(bool perKernel);
96 const char *mRtcSrcExtension = ".src", *mRtcBinExtension = ".o";
97};
98
99} // namespace o2::gpu
100
101#endif
benchmark::State & state
#define GPUh()
o2::gpu::GPUReconstruction * GPUReconstruction_Create_CUDA(const o2::gpu::GPUSettingsDeviceBackend &cfg)
TBranch * ptr
void runKernelBackendInternal(const krnlSetupTime &_xyz, const Args &... args)
void getRTCKernelCalls(std::vector< std::string > &kernels)
friend GPUh() void GPUCommonAlgorithm GPUReconstructionCUDAInternals * mInternals
GPUReconstructionCUDABackend(const GPUSettingsDeviceBackend &cfg)
virtual int32_t GPUChkErrInternal(const int64_t error, const char *file, int32_t line) const override
void 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
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLuint stream
Definition glcorearb.h:1806
std::string filename()
GPUReconstruction * rec
const int nEvents
Definition test_Fifo.cxx:27