MaCh3  2.8.0
Reference Guide
gpuSplineUtils.cuh
Go to the documentation of this file.
1 
12 //MaCh3 included
13 #include "Manager/gpuUtils.cuh"
14 #include "Splines/SplineCommon.h"
15 
17 __host__ void SynchroniseSplines();
18 
29 __global__ void EvalOnGPU_Splines(
30  const unsigned int gpu_n_splines,
31  const short int gpu_spline_size,
32  const short int* __restrict__ gpu_paramNo_arr,
33  const unsigned int* __restrict__ gpu_nKnots_arr,
34  const float* __restrict__ gpu_coeff_many,
35  const float* __restrict__ gpu_par_val,
36  const short int* __restrict__ gpu_spline_segment,
37  float* __restrict__ gpu_weights,
38  const cudaTextureObject_t __restrict__ text_coeff_x);
39 
47 __global__ void EvalOnGPU_TF1(
48  const unsigned int gpu_n_TF1,
49  const float* __restrict__ gpu_coeffs_tf1,
50  const short int* __restrict__ gpu_paramNo_arr_tf1,
51  const float* __restrict__ gpu_par_val,
52  float* __restrict__ gpu_weights_tf1);
53 
61 __global__ void EvalOnGPU_TotWeight(
62  const int gpu_n_events,
63  const float* __restrict__ gpu_weights,
64  const float* __restrict__ gpu_weights_tf1,
65  M3::float_t* __restrict__ gpu_total_weights,
66  const cudaTextureObject_t __restrict__ text_nParamPerEvent,
67  const cudaTextureObject_t __restrict__ text_nParamPerEvent_TF1);
68 
75 {
76  public:
81  virtual ~SplineMonolithGPU();
82 
89  __host__ void InitGPU_SplineMonolith(
90  unsigned int total_nknots,
91  unsigned int n_splines,
92  unsigned int n_tf1,
93  int Eve_size);
94 
98  __host__ void InitGPU_Unbinned_SplineMonolith(
99  M3::float_t **cpu_total_weights,
100  int n_events);
101 
119  __host__ void CopyToGPU_SplineMonolith_Unbinned(
120  const SplineMonoStruct* cpu_spline_handler,
121 
122  // TFI related now
123  const std::vector<float>& cpu_many_array_TF1,
124  const std::vector<short int>& cpu_paramNo_arr_TF1,
125  const int n_events,
126  const std::vector<unsigned int>& cpu_nParamPerEvent,
127  // TFI related now
128  const std::vector<unsigned int>& cpu_nParamPerEvent_TF1,
129  const int n_params,
130  const unsigned int n_splines,
131  const short int spline_size,
132  const unsigned int total_nknots,
133  const unsigned int n_tf1);
134 
136  __host__ void CopyToGPU_SplineMonolith_Binned(
137  M3::float_t *manycoeff_arr,
138  M3::float_t *xcoeff_arr,
139  const std::vector<short int>& uniquesplinevec_Monolith,
140  const std::vector<unsigned int>& coeffindexvec,
141 
142  const int n_params,
143  const unsigned int n_splines,
144  const short int spline_size,
145  const unsigned int total_nknots);
146 
149  __host__ void InitGPU_Segments(short int **segment);
150 
153  __host__ void InitGPU_Vals(float **vals);
154 
158 
174  __host__ void RunGPU_SplineMonolith_Unbinned(
175  M3::float_t* cpu_total_weights,
176  // Holds the changes in parameters
177  float *vals,
178  // Holds the segments for parameters
179  short int *segment);
180 
181  __host__ void RunGPU_SplineMonolith_Binned(
182  M3::float_t* cpu_spline_weights,
183  // Holds the changes in parameters
184  float *vals,
185  // Holds the segments for parameters
186  short int *segment);
187 
194  __host__ void CleanupPinnedMemory(M3::float_t *cpu_total_weights,
195  short int *segment, float *vals);
196 
197  private:
199  unsigned int *gpu_nParamPerEvent;
201  unsigned int *gpu_nParamPerEvent_TF1;
202 
204  float *gpu_coeff_x;
205 
208 
210  unsigned int *gpu_nKnots_arr;
211 
213  short int *gpu_paramNo_arr;
214 
218  short int *gpu_nPoints_arr;
221 
223  float* gpu_par_val;
225  short int* gpu_spline_segment;
226 
230  float *gpu_weights;
233 
235  short int cpu_spline_size;
237  unsigned int cpu_n_splines;
239  unsigned int cpu_n_TF1;
244  #ifndef _LOW_MEMORY_STRUCTS_
246  std::vector<float> cpu_tmp_weights;
247  #endif
248 
249  // ******************************************
250  // TEXTURES
251  // ******************************************
253  cudaTextureObject_t text_coeff_x = 0;
255  cudaTextureObject_t text_nParamPerEvent = 0;
257  cudaTextureObject_t text_nParamPerEvent_TF1 = 0;
258 };
Contains definitions for spline coefficients and structure used in both CPU and GPU code.
Class responsible for calculating spline weight on GPU.
float * gpu_weights
GPU arrays to hold weight for each spline.
unsigned int * gpu_nParamPerEvent
KS: GPU map keeping track how many parameters applies to each event, we keep two numbers here {number...
__host__ void InitGPU_SplineMonolith(unsigned int total_nknots, unsigned int n_splines, unsigned int n_tf1, int Eve_size)
Allocate memory on gpu for spline monolith.
unsigned int cpu_n_TF1
Number of tf1 living on CPU.
virtual ~SplineMonolithGPU()
This function deallocates the resources allocated for the separate {x} and {ybcd} arrays in the and T...
unsigned int * gpu_nParamPerEvent_TF1
KS: GPU map keeping track how many parameters applies to each event, we keep two numbers here {number...
float * gpu_weights_tf1
GPU arrays to hold weight for each TF1.
unsigned int * gpu_nKnots_arr
KS: GPU Number of knots per spline.
float * gpu_par_val
CW: parameter value on GPU.
float * gpu_coeff_TF1_many
GPU arrays to hold TF1 coefficients.
__host__ void InitGPU_Vals(float **vals)
Allocate memory for spline segments.
cudaTextureObject_t text_nParamPerEvent_TF1
KS: Map keeping track how many parameters applies to each event, we keep two numbers here {number of ...
__host__ void RunGPU_SplineMonolith_Unbinned(M3::float_t *cpu_total_weights, float *vals, short int *segment)
Run the GPU code for the separate many arrays. As in separate {x}, {y,b,c,d} arrays Pass the segment ...
float * gpu_coeff_many
GPU arrays to hold other coefficients.
__host__ void CleanupPinnedMemory(M3::float_t *cpu_total_weights, short int *segment, float *vals)
Clean up pinned variables at CPU.
__host__ void CopyToGPU_SplineMonolith_Unbinned(const SplineMonoStruct *cpu_spline_handler, const std::vector< float > &cpu_many_array_TF1, const std::vector< short int > &cpu_paramNo_arr_TF1, const int n_events, const std::vector< unsigned int > &cpu_nParamPerEvent, const std::vector< unsigned int > &cpu_nParamPerEvent_TF1, const int n_params, const unsigned int n_splines, const short int spline_size, const unsigned int total_nknots, const unsigned int n_tf1)
Copies data from CPU to GPU for the spline monolith.
short int * gpu_paramNo_TF1_arr
CW: GPU array with the number of points per TF1 object.
cudaTextureObject_t text_coeff_x
KS: Textures are L1 cache variables which are well optimised for fetching. Make texture only for vari...
int cpu_n_params
Number of params living on CPU.
__host__ void InitGPU_Segments(short int **segment)
Allocate memory for spline segments.
__host__ void InitGPU_Unbinned_SplineMonolith(M3::float_t **cpu_total_weights, int n_events)
Allocate memory on gpu for spline monolith.
int cpu_n_events
Number of events living on CPU.
short int * gpu_nPoints_arr
GPU arrays to hold number of points.
unsigned int cpu_n_splines
Number of splines living on CPU.
SplineMonolithGPU()
constructor
short int * gpu_paramNo_arr
CW: GPU array with the number of points per spline (not per spline point!)
float * gpu_coeff_x
KS: GPU arrays to hold X coefficient.
__host__ void RunGPU_SplineMonolith_Binned(M3::float_t *cpu_spline_weights, float *vals, short int *segment)
cudaTextureObject_t text_nParamPerEvent
KS: Map keeping track how many parameters applies to each event, we keep two numbers here {number of ...
std::vector< float > cpu_tmp_weights
Temporary weight needed for conversion from float to double.
short int cpu_spline_size
Size of splines living on CPU.
__host__ void CopyToGPU_SplineMonolith_Binned(M3::float_t *manycoeff_arr, M3::float_t *xcoeff_arr, const std::vector< short int > &uniquesplinevec_Monolith, const std::vector< unsigned int > &coeffindexvec, const int n_params, const unsigned int n_splines, const short int spline_size, const unsigned int total_nknots)
Copies data from CPU to GPU for the spline monolith.
M3::float_t * gpu_total_weights
GPU arrays to hold weight for event.
short int * gpu_spline_segment
CW: Spline segment on GPU.
__global__ void EvalOnGPU_TF1(const unsigned int gpu_n_TF1, const float *__restrict__ gpu_coeffs_tf1, const short int *__restrict__ gpu_paramNo_arr_tf1, const float *__restrict__ gpu_par_val, float *__restrict__ gpu_weights_tf1)
Evaluate the TF1 on the GPU Using first order polynomial Polynomial form: w(x) = a0 + a1·x.
__host__ void SynchroniseSplines()
Make sure all Cuda threads finished execution.
__global__ void EvalOnGPU_TotWeight(const int gpu_n_events, const float *__restrict__ gpu_weights, const float *__restrict__ gpu_weights_tf1, M3::float_t *__restrict__ gpu_total_weights, const cudaTextureObject_t __restrict__ text_nParamPerEvent, const cudaTextureObject_t __restrict__ text_nParamPerEvent_TF1)
KS: Evaluate the total spline event weight on the GPU, as in most cases GPU is faster,...
__global__ void EvalOnGPU_Splines(const unsigned int gpu_n_splines, const short int gpu_spline_size, const short int *__restrict__ gpu_paramNo_arr, const unsigned int *__restrict__ gpu_nKnots_arr, const float *__restrict__ gpu_coeff_many, const float *__restrict__ gpu_par_val, const short int *__restrict__ gpu_spline_segment, float *__restrict__ gpu_weights, const cudaTextureObject_t __restrict__ text_coeff_x)
Evaluate the spline on the GPU Using one {y,b,c,d} array and one {x} array Should be most efficient a...
Common CUDA utilities and definitions for shared GPU functionality.
double float_t
Definition: Core.h:37
KS: Struct storing information for spline monolith.
Definition: SplineCommon.h:61