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{
26{
27 public:
29
30 const GPUParam* DeviceParam() const;
37
38 protected:
39 GPUReconstructionDeviceBase(const GPUSettingsDeviceBackend& cfg, size_t sizeCheck);
40
41 int32_t InitDevice() override;
42 virtual int32_t InitDevice_Runtime() = 0;
43 int32_t ExitDevice() override;
44 virtual int32_t ExitDevice_Runtime() = 0;
45 virtual int32_t GPUChkErrInternal(const int64_t error, const char* file, int32_t line) const override = 0;
46 int32_t registerMemoryForGPU_internal(const void* ptr, size_t size) override;
47 int32_t unregisterMemoryForGPU_internal(const void* ptr) override;
49
50 int32_t GPUDebug(const char* state = "UNKNOWN", int32_t stream = -1, bool force = false) override = 0;
51 size_t TransferMemoryInternal(GPUMemoryResource* res, int32_t stream, deviceEvent* ev, deviceEvent* evList, int32_t nEvents, bool toGPU, const void* src, void* dst) override;
52 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;
53 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;
54 size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, deviceEvent* ev = nullptr) override = 0;
55
56 int32_t GetGlobalLock(void*& pLock);
57 void ReleaseGlobalLock(void* sem);
58
59 int32_t mDeviceId = -1; // Device ID used by backend
60
61 struct DebugEvents {
62 deviceEvent DebugStart, DebugStop; // Debug timer events
63 };
65
66 std::vector<void*> mDeviceConstantMemList;
67 static std::vector<void* (*)()>& getDeviceConstantMemRegistratorsVector()
68 {
69 static std::vector<void* (*)()> deviceConstantMemRegistrators{};
70 return deviceConstantMemRegistrators;
71 }
73};
74
75inline 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)
76{
77 if (onGpu) {
78 return GPUMemCpy(dst, src, size, stream, toGPU, ev, evList, nEvents);
79 } else {
80 return GPUReconstructionCPU::GPUMemCpyAlways(false, dst, src, size, stream, toGPU, ev, evList, nEvents);
81 }
82}
83} // namespace o2::gpu
84
85#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 GPUChkErrInternal(const int64_t error, const char *file, int32_t line) const override=0
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
size_t TransferMemoryInternal(GPUMemoryResource *res, int32_t stream, deviceEvent *ev, deviceEvent *evList, int32_t nEvents, bool toGPU, const void *src, void *dst) 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=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 registerMemoryForGPU_internal(const void *ptr, size_t size) override
int32_t GPUDebug(const char *state="UNKNOWN", int32_t stream=-1, bool force=false) override=0
int32_t unregisterMemoryForGPU_internal(const void *ptr) override
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