Project
Loading...
Searching...
No Matches
SplineUtil.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
16
17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_SPLINEUTIL_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_SPLINEUTIL_H
19
20namespace o2::gpu
21{
22
27{
28 public:
31 static constexpr int32_t getSpec(int32_t nXdim, int32_t nYdim)
32 {
33 // List of the Spline class specializations:
34 //
35 // 0 - a parent class for other specializations
36 // 1 - nXdim>0, nYdim>0: both nXdim and nYdim are set at the compile time
37 // 2 - at least one of the dimensions must be set during runtime
38 // 3 - specialization where nYdim==1 (a small add-on on top of the other specs)
39
40 return (nYdim == 1) ? 3 : ((nXdim > 0 && nYdim > 0) ? 1 : 2);
41 /*
42 if (nYdim == 1) {
43 return 3;
44 }
45 if (nXdim > 0 && nYdim > 0) {
46 return 1;
47 } else {
48 return 2;
49 }
50 */
51 }
52
55 static constexpr int32_t getSpec(int32_t nYdim)
56 {
57 return getSpec(1, nYdim);
58 }
59
61 static constexpr int32_t abs(int32_t v) { return (v >= 0) ? v : -v; }
62
64 template <bool ConditionT, int32_t ValTrueT>
65 class Switch;
66
73 template <int32_t NdimT>
74 GPUd() static Switch<(NdimT > 0), NdimT> getNdim(int32_t Ndim)
75 {
76 return Switch<(NdimT > 0), NdimT>(Ndim);
77 }
78
84 template <int32_t NdimT>
85 GPUd() static Switch<(NdimT != 0), abs(NdimT)> getMaxNdim(int32_t Ndim)
86 {
88 }
89};
90
91template <int32_t ValTrueT>
92class SplineUtil::Switch<true, ValTrueT>
93{
94 public:
95 GPUd() Switch(int32_t /*valFalse*/) {}
96 GPUd() static constexpr int32_t get() { return ValTrueT; }
97};
98
99template <int32_t ValTrueT>
100class SplineUtil::Switch<false, ValTrueT>
101{
102 public:
103 GPUd() Switch(int32_t valFalse) : mValFalse(valFalse) {}
104 GPUd() int32_t get() const { return mValFalse; }
105
106 private:
107 int32_t mValFalse;
108};
109
110} // namespace o2::gpu
111
112#endif
GPUd() static const expr int32_t get()
Definition SplineUtil.h:96
class lets one to switch between constexpr int32_t ValTrueT and int32_t mValFalse,...
Definition SplineUtil.h:65
GPUd() static Switch<(NdimT > 0)
NdimT getNdim(int32_t Ndim)
Definition SplineUtil.h:74
static constexpr int32_t getSpec(int32_t nXdim, int32_t nYdim)
Definition SplineUtil.h:31
static constexpr int32_t getSpec(int32_t nYdim)
Definition SplineUtil.h:55
static constexpr int32_t abs(int32_t v)
abs() as a constexpr method, to make the GPU compiler happy
Definition SplineUtil.h:61
const GLdouble * v
Definition glcorearb.h:832