Project
Loading...
Searching...
No Matches
GPUReconstructionDeviceBase.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 GPURECONSTRUCTIONDEVICEBASE_H
16#define GPURECONSTRUCTIONDEVICEBASE_H
17
19#include <pthread.h>
20#include "GPUChain.h"
21#include <vector>
22
23namespace o2::gpu
24{
25#if !(defined(__CLING__) || defined(__ROOTCLING__) || defined(G__ROOT))
26extern template class GPUReconstructionKernels<GPUReconstructionCPUBackend>;
27#endif
28
30{
31 public:
33
34 const GPUParam* DeviceParam() const { return &mDeviceConstantMem->param; }
41
42 protected:
43 GPUReconstructionDeviceBase(const GPUSettingsDeviceBackend& cfg, size_t sizeCheck);
44
45 int32_t InitDevice() override;
46 virtual int32_t InitDevice_Runtime() = 0;
47 int32_t ExitDevice() override;
48 virtual int32_t ExitDevice_Runtime() = 0;
49 int32_t registerMemoryForGPU_internal(const void* ptr, size_t size) override;
50 int32_t unregisterMemoryForGPU_internal(const void* ptr) override;
51 void unregisterRemainingRegisteredMemory();
52
53 virtual const GPUTPCTracker* CPUTracker(int32_t iSector) { return &processors()->tpcTrackers[iSector]; }
54
55 int32_t GPUDebug(const char* state = "UNKNOWN", int32_t stream = -1, bool force = false) override = 0;
56 size_t TransferMemoryInternal(GPUMemoryResource* res, int32_t stream, deviceEvent* ev, deviceEvent* evList, int32_t nEvents, bool toGPU, const void* src, void* dst) override;
57 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 = 0;
58 size_t GPUMemCpyAlways(bool onGpu, 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;
59 size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, deviceEvent* ev = nullptr) override = 0;
60
61 int32_t GetGlobalLock(void*& pLock);
62 void ReleaseGlobalLock(void* sem);
63
64 int32_t mDeviceId = -1; // Device ID used by backend
65
66 struct DebugEvents {
67 deviceEvent DebugStart, DebugStop; // Debug timer events
68 };
69 DebugEvents* mDebugEvents = nullptr;
70
71 std::vector<void*> mDeviceConstantMemList;
72 static std::vector<void* (*)()>& getDeviceConstantMemRegistratorsVector()
73 {
74 static std::vector<void* (*)()> deviceConstantMemRegistrators{};
75 return deviceConstantMemRegistrators;
76 }
77 void runConstantRegistrators();
78};
79
80inline size_t GPUReconstructionDeviceBase::GPUMemCpyAlways(bool onGpu, void* dst, const void* src, size_t size, int32_t stream, int32_t toGPU, deviceEvent* ev, deviceEvent* evList, int32_t nEvents)
81{
82 if (onGpu) {
83 return GPUMemCpy(dst, src, size, stream, toGPU, ev, evList, nEvents);
84 } else {
85 return GPUReconstructionCPU::GPUMemCpyAlways(false, dst, src, size, stream, toGPU, ev, evList, nEvents);
86 }
87}
88} // namespace o2::gpu
89
90#endif
benchmark::State & state
uint32_t res
Definition RawData.h:0
TBranch * ptr
virtual size_t GPUMemCpyAlways(bool onGpu, void *dst, const void *src, size_t size, int32_t stream, int32_t toGPU, deviceEvent *ev=nullptr, deviceEvent *evList=nullptr, int32_t nEvents=1)
virtual int32_t InitDevice_Runtime()=0
size_t GPUMemCpyAlways(bool onGpu, 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
virtual const GPUTPCTracker * CPUTracker(int32_t iSector)
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=0
size_t WriteToConstantMemory(size_t offset, const void *src, size_t size, int32_t stream=-1, deviceEvent *ev=nullptr) override=0
virtual int32_t ExitDevice_Runtime()=0
int32_t GPUDebug(const char *state="UNKNOWN", int32_t stream=-1, bool force=false) override=0
static std::vector< void *(*)()> & getDeviceConstantMemRegistratorsVector()
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
const int nEvents
Definition test_Fifo.cxx:27