Skip to content

Commit 90f3763

Browse files
committed
GPU: Rewrite virtual kernel call to a single virtual function, should enable further simplifications in the future
1 parent a5caa27 commit 90f3763

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

GPU/GPUTracking/Base/GPUReconstructionCPU.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ class GPUReconstructionCPU : public GPUReconstructionKernels<GPUReconstructionCP
7575
#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, ...) \
7676
inline void runKernelImplWrapper(gpu_reconstruction_kernels::classArgument<GPUCA_M_KRNL_TEMPLATE(x_class)>, bool cpuFallback, double& timer, krnlSetup&& setup GPUCA_M_STRIP(x_arguments)) \
7777
{ \
78+
krnlSetupArgs<GPUCA_M_KRNL_TEMPLATE(x_class) GPUCA_M_STRIP(x_types)> args(setup.x, setup.y, setup.z, timer GPUCA_M_STRIP(x_forward)); \
79+
const uint32_t num = GetKernelNum<GPUCA_M_KRNL_TEMPLATE(x_class)>(); \
7880
if (cpuFallback) { \
79-
GPUReconstructionCPU::runKernelImpl(krnlSetupArgs<GPUCA_M_KRNL_TEMPLATE(x_class) GPUCA_M_STRIP(x_types)>(setup.x, setup.y, setup.z, timer GPUCA_M_STRIP(x_forward))); \
81+
GPUReconstructionCPU::runKernelImpl(num, &args); \
8082
} else { \
81-
runKernelImpl(krnlSetupArgs<GPUCA_M_KRNL_TEMPLATE(x_class) GPUCA_M_STRIP(x_types)>(setup.x, setup.y, setup.z, timer GPUCA_M_STRIP(x_forward))); \
83+
runKernelImpl(num, &args); \
8284
} \
8385
}
8486
#include "GPUReconstructionKernelList.h"

GPU/GPUTracking/Base/GPUReconstructionKernels.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,19 @@ class GPUReconstructionKernels : public T
9595
template <class S, int32_t I = 0, typename... Args>
9696
using krnlSetupArgs = gpu_reconstruction_kernels::krnlSetupArgs<S, I, Args...>;
9797

98-
#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types) \
99-
virtual void runKernelImpl(const krnlSetupArgs<GPUCA_M_KRNL_TEMPLATE(x_class) GPUCA_M_STRIP(x_types)>& args) \
100-
{ \
101-
T::template runKernelBackend<GPUCA_M_KRNL_TEMPLATE(x_class)>(args); \
102-
}
98+
virtual void runKernelImpl(const int num, const void* args)
99+
{
100+
switch (num) { // clang-format off
101+
#define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward, x_types, x_num) \
102+
case x_num: { \
103+
const auto& args2 = *(const krnlSetupArgs<GPUCA_M_KRNL_TEMPLATE(x_class) GPUCA_M_STRIP(x_types)>*)args; \
104+
T::template runKernelBackend<GPUCA_M_KRNL_TEMPLATE(x_class)>(args2); \
105+
break; \
106+
}
103107
#include "GPUReconstructionKernelList.h"
104108
#undef GPUCA_KRNL
109+
} // clang-format on
110+
}
105111
};
106112

107113
} // namespace o2::gpu

0 commit comments

Comments
 (0)