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#include <iostream>
21
22using namespace o2::gpu;
23
25{
27}
28
30{
32 mGridU.destroy();
33 mGridV.destroy();
35}
36
37void IrregularSpline2D3D::cloneFromObject(const IrregularSpline2D3D& obj, char* newFlatBufferPtr)
38{
40
41 const char* oldFlatBufferPtr = obj.mFlatBufferPtr;
42
43 FlatObject::cloneFromObject(obj, newFlatBufferPtr);
44
45 char* bufferU = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mGridU.getFlatBufferPtr());
46 mGridU.cloneFromObject(obj.mGridU, bufferU);
47
48 char* bufferV = FlatObject::relocatePointer(oldFlatBufferPtr, mFlatBufferPtr, obj.mGridV.getFlatBufferPtr());
49 mGridV.cloneFromObject(obj.mGridV, bufferV);
50}
51
52void IrregularSpline2D3D::moveBufferTo(char* newFlatBufferPtr)
53{
55 FlatObject::moveBufferTo(newFlatBufferPtr);
57}
58
59void IrregularSpline2D3D::setActualBufferAddress(char* actualFlatBufferPtr)
60{
62 FlatObject::setActualBufferAddress(actualFlatBufferPtr);
63 size_t vOffset = alignSize(mGridU.getFlatBufferSize(), mGridV.getBufferAlignmentBytes());
65 mGridV.setActualBufferAddress(mFlatBufferPtr + vOffset);
66}
67
68void IrregularSpline2D3D::setFutureBufferAddress(char* futureFlatBufferPtr)
69{
71 const char* oldFlatBufferPtr = mFlatBufferPtr;
72
73 char* bufferU = relocatePointer(oldFlatBufferPtr, futureFlatBufferPtr, mGridU.getFlatBufferPtr());
74 mGridU.setFutureBufferAddress(bufferU);
75
76 char* bufferV = relocatePointer(oldFlatBufferPtr, futureFlatBufferPtr, mGridV.getFlatBufferPtr());
77 mGridV.setFutureBufferAddress(bufferV);
78
79 FlatObject::setFutureBufferAddress(futureFlatBufferPtr);
80}
81
82void IrregularSpline2D3D::construct(int32_t numberOfKnotsU, const float knotsU[], int32_t numberOfAxisBinsU, int32_t numberOfKnotsV, const float knotsV[], int32_t numberOfAxisBinsV)
83{
104
106
107 mGridU.construct(numberOfKnotsU, knotsU, numberOfAxisBinsU);
108 mGridV.construct(numberOfKnotsV, knotsV, numberOfAxisBinsV);
109
110 size_t vOffset = alignSize(mGridU.getFlatBufferSize(), mGridV.getBufferAlignmentBytes());
111
112 FlatObject::finishConstruction(vOffset + mGridV.getFlatBufferSize());
113
115 mGridV.moveBufferTo(mFlatBufferPtr + vOffset);
116}
117
118void IrregularSpline2D3D::constructRegular(int32_t numberOfKnotsU, int32_t numberOfKnotsV)
119{
124
126
127 mGridU.constructRegular(numberOfKnotsU);
128 mGridV.constructRegular(numberOfKnotsV);
129
130 size_t vOffset = alignSize(mGridU.getFlatBufferSize(), mGridV.getBufferAlignmentBytes());
131
132 FlatObject::finishConstruction(vOffset + mGridV.getFlatBufferSize());
133
135 mGridV.moveBufferTo(mFlatBufferPtr + vOffset);
136}
137
139{
140 LOG(info) << " Irregular Spline 2D3D: ";
141 LOG(info) << " grid U: ";
142 mGridU.print();
143 LOG(info) << " grid V: ";
144 mGridV.print();
145}
Definition of IrregularSpline2D3D class.
void setFutureBufferAddress(char *futureFlatBufferPtr)
Definition FlatObject.h:569
void destroy()
_______________ Utilities _______________________________________________
Definition FlatObject.h:361
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:283
void setActualBufferAddress(char *actualFlatBufferPtr)
_____________ Methods for moving the class with its external buffer to another location _____________...
Definition FlatObject.h:559
void startConstruction()
_____________ Construction _________
Definition FlatObject.h:354
void moveBufferTo(char *newBufferPtr)
Definition FlatObject.h:408
void finishConstruction(int32_t flatBufferSize)
Definition FlatObject.h:370
static constexpr size_t alignSize(size_t sizeBytes, size_t alignmentBytes)
_______________ Generic utilities _______________________________________________
Definition FlatObject.h:275
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
Definition FlatObject.h:385
void setFutureBufferAddress(char *futureFlatBufferPtr)
Definition FlatObject.h:569
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
Definition FlatObject.h:559
void print() const
Print method.
void moveBufferTo(char *newBufferPtr)
Definition FlatObject.h:408
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"