forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGPUReconstructionCUDA.h
More file actions
98 lines (79 loc) · 3.91 KB
/
GPUReconstructionCUDA.h
File metadata and controls
98 lines (79 loc) · 3.91 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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 GPUReconstructionCUDA.h
/// \author David Rohr
#ifndef GPURECONSTRUCTIONCUDA_H
#define GPURECONSTRUCTIONCUDA_H
#include "GPUReconstructionDeviceBase.h"
#include <vector>
#include <string>
#ifdef _WIN32
extern "C" __declspec(dllexport) o2::gpu::GPUReconstruction* GPUReconstruction_Create_CUDA(const o2::gpu::GPUSettingsDeviceBackend& cfg);
#else
extern "C" o2::gpu::GPUReconstruction* GPUReconstruction_Create_CUDA(const o2::gpu::GPUSettingsDeviceBackend& cfg);
#endif
namespace o2::gpu
{
struct GPUReconstructionCUDAInternals;
class GPUReconstructionCUDABackend : public GPUReconstructionDeviceBase
{
public:
~GPUReconstructionCUDABackend() override;
protected:
GPUReconstructionCUDABackend(const GPUSettingsDeviceBackend& cfg);
void PrintKernelOccupancies() override;
virtual int32_t GPUChkErrInternal(const int64_t error, const char* file, int32_t line) const override;
template <class T, int32_t I = 0, typename... Args>
void runKernelBackend(const krnlSetupArgs<T, I, Args...>& args);
template <class T, int32_t I = 0, typename... Args>
void runKernelBackendInternal(const krnlSetupTime& _xyz, const Args&... args);
template <class T, class S>
friend GPUh() void GPUCommonAlgorithm::sortOnDevice(auto* rec, int32_t stream, T* begin, size_t N, const S& comp);
GPUReconstructionCUDAInternals* mInternals;
};
class GPUReconstructionCUDA : public GPUReconstructionKernels<GPUReconstructionCUDABackend>
{
public:
~GPUReconstructionCUDA() override;
GPUReconstructionCUDA(const GPUSettingsDeviceBackend& cfg);
protected:
int32_t InitDevice_Runtime() override;
int32_t ExitDevice_Runtime() override;
std::unique_ptr<gpu_reconstruction_kernels::threadContext> GetThreadContext() override;
void SynchronizeGPU() 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;
int32_t registerMemoryForGPU_internal(const void* ptr, size_t size) override;
int32_t unregisterMemoryForGPU_internal(const void* ptr) 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;
void GetITSTraits(std::unique_ptr<o2::its::TrackerTraits>* trackerTraits, std::unique_ptr<o2::its::VertexerTraits>* vertexerTraits, std::unique_ptr<o2::its::TimeFrame>* timeFrame) override;
#ifndef __HIPCC__ // CUDA
bool CanQueryMaxMemory() override { return true; }
void startGPUProfiling() override;
void endGPUProfiling() override;
#else // HIP
void* getGPUPointer(void* ptr) override;
#endif
private:
int32_t genRTC(std::string& filename, uint32_t& nCompile);
void getRTCKernelCalls(std::vector<std::string>& kernels);
void genAndLoadRTC();
void loadKernelModules(bool perKernel);
const char *mRtcSrcExtension = ".src", *mRtcBinExtension = ".o";
};
} // namespace o2::gpu
#endif