Project
Loading...
Searching...
No Matches
GPUReconstructionKernels.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 GPURECONSTRUCTIONKERNELS_H
16#define GPURECONSTRUCTIONKERNELS_H
17
18#include "GPUReconstruction.h"
19
20namespace o2::gpu
21{
22
23namespace gpu_reconstruction_kernels
24{
25
26template <class T, int32_t I = 0>
28 using t = T;
29 static constexpr int32_t i = I;
30};
31
32struct krnlExec {
33 constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d = GPUReconstruction::krnlDeviceType::Auto) : nBlocks(b), nThreads(t), stream(s), device(d), step(GPUCA_RECO_STEP::NoRecoStep) {}
34 constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUCA_RECO_STEP st) : nBlocks(b), nThreads(t), stream(s), device(GPUReconstruction::krnlDeviceType::Auto), step(st) {}
35 constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st) : nBlocks(b), nThreads(t), stream(s), device(d), step(st) {}
36 uint32_t nBlocks;
37 uint32_t nThreads;
38 int32_t stream;
41};
43 constexpr krnlRunRange() = default;
44 constexpr krnlRunRange(uint32_t a) : start(a), num(0) {}
45 constexpr krnlRunRange(uint32_t s, int32_t n) : start(s), num(n) {}
46
47 uint32_t start = 0;
48 int32_t num = 0;
49};
50struct krnlEvent {
51 constexpr krnlEvent(deviceEvent* e = nullptr, deviceEvent* el = nullptr, int32_t n = 1) : ev(e), evList(el), nEvents(n) {}
54 int32_t nEvents;
55};
56
58 krnlProperties(int32_t t = 0, int32_t b = 1, int32_t b2 = 0) : nThreads(t), minBlocks(b), forceBlocks(b2) {}
59 uint32_t nThreads;
60 uint32_t minBlocks;
61 uint32_t forceBlocks;
62 uint32_t total() { return forceBlocks ? forceBlocks : (nThreads * minBlocks); }
63};
64
65struct krnlSetup {
66 krnlSetup(const krnlExec& xx, const krnlRunRange& yy = {0, -1}, const krnlEvent& zz = {nullptr, nullptr, 0}) : x(xx), y(yy), z(zz) {}
70};
71
72struct krnlSetupTime : public krnlSetup {
73 double& t;
74};
75
76template <class T, int32_t I = 0, typename... Args>
78 krnlSetupArgs(const krnlExec& xx, const krnlRunRange& yy, const krnlEvent& zz, double& tt, const Args&... args) : s{{xx, yy, zz}, tt}, v(args...) {}
80 std::tuple<typename std::conditional<(sizeof(Args) > sizeof(void*)), const Args&, const Args>::type...> v;
81};
82
83} // namespace gpu_reconstruction_kernels
84
85template <class T>
87{
88 public:
90
91 protected:
98 template <class S, int32_t I = 0, typename... Args>
100
101#define GPUCA_KRNL(x_class, attributes, x_arguments, x_forward, x_types) \
102 virtual int32_t runKernelImpl(const krnlSetupArgs<GPUCA_M_KRNL_TEMPLATE(x_class) GPUCA_M_STRIP(x_types)>& args) \
103 { \
104 return T::template runKernelBackend<GPUCA_M_KRNL_TEMPLATE(x_class)>(args); \
105 } \
106 virtual gpu_reconstruction_kernels::krnlProperties getKernelPropertiesImpl(gpu_reconstruction_kernels::classArgument<GPUCA_M_KRNL_TEMPLATE(x_class)>) \
107 { \
108 return T::template getKernelPropertiesBackend<GPUCA_M_KRNL_TEMPLATE(x_class)>(); \
109 }
110#include "GPUReconstructionKernelList.h"
111#undef GPUCA_KRNL
112};
113
114} // namespace o2::gpu
115
116#endif
#define GPUCA_RECO_STEP
benchmark::State & st
GPUReconstructionKernels(const GPUSettingsDeviceBackend &cfg)
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLuint start
Definition glcorearb.h:469
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint GLuint stream
Definition glcorearb.h:1806
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr krnlEvent(deviceEvent *e=nullptr, deviceEvent *el=nullptr, int32_t n=1)
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d=GPUReconstruction::krnlDeviceType::Auto)
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUReconstruction::krnlDeviceType d, GPUCA_RECO_STEP st)
constexpr krnlExec(uint32_t b, uint32_t t, int32_t s, GPUCA_RECO_STEP st)
krnlProperties(int32_t t=0, int32_t b=1, int32_t b2=0)
krnlSetupArgs(const krnlExec &xx, const krnlRunRange &yy, const krnlEvent &zz, double &tt, const Args &... args)
krnlSetup(const krnlExec &xx, const krnlRunRange &yy={0, -1}, const krnlEvent &zz={nullptr, nullptr, 0})