Project
Loading...
Searching...
No Matches
IrregularSpline2D3D.cxx
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#include "IrregularSpline2D3D.h"
18#include "GPUCommonLogger.h"
19
20#if !defined(GPUCA_GPUCODE)
21#include <iostream>
22#endif
23
24using namespace o2::gpu;
25
27{
29}
30
32{
34 mGridU.destroy();
35 mGridV.destroy();
37}
38
39void IrregularSpline2D3D::cloneFromObject(const IrregularSpline2D3D& obj, char* newFlatBufferPtr)
40{
42
43 const char* oldFlatBufferPtr = obj.mFlatBufferPtr;
44
45 FlatObject::cloneFromObject(obj, newFlatBufferPtr);
46
47 char* bufferU = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mGridU.getFlatBufferPtr());
48 mGridU.cloneFromObject(obj.mGridU, bufferU);
49
50 char* bufferV = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mGridV.getFlatBufferPtr());
51 mGridV.cloneFromObject(obj.mGridV, bufferV);
52}
53
54void IrregularSpline2D3D::moveBufferTo(char* newFlatBufferPtr)
55{
57 FlatObject::moveBufferTo(newFlatBufferPtr);
59}
60
61void IrregularSpline2D3D::setActualBufferAddress(char* actualFlatBufferPtr)
62{
64 FlatObject::setActualBufferAddress(actualFlatBufferPtr);
65 size_t vOffset = alignSize(mGridU.getFlatBufferSize(), mGridV.getBufferAlignmentBytes());
67 mGridV.setActualBufferAddress(mFlatBufferPtr + vOffset);
68}
69
70void IrregularSpline2D3D::setFutureBufferAddress(char* futureFlatBufferPtr)
71{
73 const char* oldFlatBufferPtr = mFlatBufferPtr;
74
75 char* bufferU = relocatePointer(oldFlatBufferPtr, futureFlatBufferPtr, mGridU.getFlatBufferPtr());
76 mGridU.setFutureBufferAddress(bufferU);
77
78 char* bufferV = relocatePointer(oldFlatBufferPtr, futureFlatBufferPtr, mGridV.getFlatBufferPtr());
79 mGridV.setFutureBufferAddress(bufferV);
80
81 FlatObject::setFutureBufferAddress(futureFlatBufferPtr);
82}
83
84void IrregularSpline2D3D::construct(int32_t numberOfKnotsU, const float knotsU[], int32_t numberOfAxisBinsU, int32_t numberOfKnotsV, const float knotsV[], int32_t numberOfAxisBinsV)
85{
106
108
109 mGridU.construct(numberOfKnotsU, knotsU, numberOfAxisBinsU);
110 mGridV.construct(numberOfKnotsV, knotsV, numberOfAxisBinsV);
111
112 size_t vOffset = alignSize(mGridU.getFlatBufferSize(), mGridV.getBufferAlignmentBytes());
113
115
117 mGridV.moveBufferTo(mFlatBufferPtr + vOffset);
118}
119
120void IrregularSpline2D3D::constructRegular(int32_t numberOfKnotsU, int32_t numberOfKnotsV)
121{
126
128
129 mGridU.constructRegular(numberOfKnotsU);
130 mGridV.constructRegular(numberOfKnotsV);
131
132 size_t vOffset = alignSize(mGridU.getFlatBufferSize(), mGridV.getBufferAlignmentBytes());
133
135
137 mGridV.moveBufferTo(mFlatBufferPtr + vOffset);
138}
139
141{
142#if !defined(GPUCA_GPUCODE)
143 LOG(info) << " Irregular Spline 2D3D: ";
144 LOG(info) << " grid U: ";
145 mGridU.print();
146 LOG(info) << " grid V: ";
147 mGridV.print();
148#endif
149}
Definition of IrregularSpline2D3D class.
GPUCA_GPUCODE.
Definition FlatObject.h:176
void setFutureBufferAddress(char *futureFlatBufferPtr)
Definition FlatObject.h:557
void destroy()
_______________ Utilities _______________________________________________
Definition FlatObject.h:349
static size_t alignSize(size_t sizeBytes, size_t alignmentBytes)
_______________ Generic utilities _______________________________________________
Definition FlatObject.h:277
static T * relocatePointer(const char *oldBase, char *newBase, const T *ptr)
Relocates a pointer inside a buffer to the new buffer address.
Definition FlatObject.h:285
void setActualBufferAddress(char *actualFlatBufferPtr)
_____________ Methods for moving the class with its external buffer to another location _____________...
Definition FlatObject.h:547
void startConstruction()
_____________ Construction _________
Definition FlatObject.h:342
void moveBufferTo(char *newBufferPtr)
Definition FlatObject.h:396
void finishConstruction(int32_t flatBufferSize)
Definition FlatObject.h:358
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
Definition FlatObject.h:373
size_t getFlatBufferSize() const
Gives size of the flat buffer.
Definition FlatObject.h:256
const char * getFlatBufferPtr() const
Gives pointer to the flat buffer.
Definition FlatObject.h:259
void setFutureBufferAddress(char *futureFlatBufferPtr)
Definition FlatObject.h:557
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
Definition FlatObject.h:547
void print() const
Print method.
void moveBufferTo(char *newBufferPtr)
Definition FlatObject.h:396
void construct(int32_t numberOfKnots, const float knots[], int32_t numberOfAxisBins)
_______________ Construction interface ________________________
void cloneFromObject(const IrregularSpline1D &obj, char *newFlatBufferPtr)
Construction interface.
static constexpr size_t getBufferAlignmentBytes()
Get minimal required alignment for the flat buffer.
void constructRegular(int32_t numberOfKnotsU)
Constructor for a regular spline.
void construct(int32_t numberOfKnotsU, const float knotsU[], int32_t numberOfAxisBinsU, int32_t numberOfKnotsV, const float knotsV[], int32_t numberOfAxisBinsV)
_______________ Construction interface ________________________
IrregularSpline2D3D()
_____________ Constructors / destructors __________________________
void cloneFromObject(const IrregularSpline2D3D &obj, char *newFlatBufferPtr)
Construction interface.
void setFutureBufferAddress(char *futureFlatBufferPtr)
void moveBufferTo(char *newBufferPtr)
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
void print() const
Print method.
void constructRegular(int32_t numberOfKnotsU, int32_t numberOfKnotsV)
Constructor for a regular spline.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"