-
Notifications
You must be signed in to change notification settings - Fork 453
/
Copy pathGPUReconstructionOCL.h
85 lines (67 loc) · 3.52 KB
/
GPUReconstructionOCL.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GPUReconstructionOCL.h
/// \author David Rohr
#ifndef GPURECONSTRUCTIONOCL_H
#define GPURECONSTRUCTIONOCL_H
#include "GPUReconstructionDeviceBase.h"
#ifdef _WIN32
extern "C" __declspec(dllexport) o2::gpu::GPUReconstruction* GPUReconstruction_Create_OCL(const o2::gpu::GPUSettingsDeviceBackend& cfg);
#else
extern "C" o2::gpu::GPUReconstruction* GPUReconstruction_Create_OCL(const o2::gpu::GPUSettingsDeviceBackend& cfg);
#endif
namespace o2::gpu
{
struct GPUReconstructionOCLInternals;
class GPUReconstructionOCLBackend : public GPUReconstructionDeviceBase
{
public:
~GPUReconstructionOCLBackend() override;
protected:
GPUReconstructionOCLBackend(const GPUSettingsDeviceBackend& cfg);
int32_t InitDevice_Runtime() override;
int32_t ExitDevice_Runtime() override;
void UpdateAutomaticProcessingSettings() override;
virtual int32_t GPUChkErrInternal(const int64_t error, const char* file, int32_t line) const override;
void SynchronizeGPU() override;
int32_t DoStuckProtection(int32_t stream, deviceEvent event) override;
int32_t GPUDebug(const char* state = "UNKNOWN", int32_t stream = -1, bool force = false) override;
void SynchronizeStream(int32_t stream) override;
void SynchronizeEvents(deviceEvent* evList, int32_t nEvents = 1) override;
void StreamWaitForEvents(int32_t stream, deviceEvent* evList, int32_t nEvents = 1) override;
bool IsEventDone(deviceEvent* evList, int32_t nEvents = 1) override;
size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, deviceEvent* ev = nullptr) 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;
void ReleaseEvent(deviceEvent ev) override;
void RecordMarker(deviceEvent* ev, int32_t stream) override;
template <class T, int32_t I = 0>
int32_t AddKernel();
template <class T, int32_t I = 0, typename... Args>
void runKernelBackendInternal(const krnlSetupTime& _xyz, const Args&... args);
GPUReconstructionOCLInternals* mInternals;
float mOclVersion;
template <class T, int32_t I = 0, typename... Args>
void runKernelBackend(const krnlSetupArgs<T, I, Args...>& args);
template <class S, class T, int32_t I>
S& getKernelObject();
int32_t GetOCLPrograms();
private:
static const char* convertErrorToString(int32_t errorCode);
template <typename T, typename... Args>
static inline int64_t OCLsetKernelParameters_helper(cl_kernel& kernel, int32_t i, const T& firstParameter, const Args&... restOfParameters);
template <typename... Args>
static int64_t OCLsetKernelParameters(cl_kernel& kernel, const Args&... args);
static int64_t clExecuteKernelA(cl_command_queue queue, cl_kernel krnl, size_t local_size, size_t global_size, cl_event* pEvent = nullptr, cl_event* wait = nullptr, cl_int nWaitEvents = 1);
int32_t AddKernels();
};
using GPUReconstructionOCL = GPUReconstructionKernels<GPUReconstructionOCLBackend>;
} // namespace o2::gpu
#endif