Skip to content

Commit 7f9d9f8

Browse files
committed
GPU: Add option to o2 propagator to optionally use GPU PolynomialField instead of normal o2 MagFieldFast
1 parent 1e6f07a commit 7f9d9f8

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

Detectors/Base/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ o2_add_library(DetectorsBase
1616
src/MatLayerCyl.cxx
1717
src/MatLayerCylSet.cxx
1818
src/Ray.cxx
19-
src/DCAFitter.cxx
19+
src/DCAFitter.cxx
2020
src/BaseDPLDigitizer.cxx
2121
src/CTFCoderBase.cxx
2222
PUBLIC_LINK_LIBRARIES FairRoot::Base
@@ -29,8 +29,10 @@ o2_add_library(DetectorsBase
2929
O2::Framework
3030
FairMQ::FairMQ
3131
O2::DataFormatsParameters
32-
O2::SimConfig
33-
ROOT::VMC)
32+
O2::SimConfig
33+
ROOT::VMC
34+
PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/GPU/GPUTracking/Merger # Must not link to avoid cyclic dependency
35+
)
3436

3537
o2_target_root_dictionary(DetectorsBase
3638
HEADERS include/DetectorsBase/Detector.h

Detectors/Base/include/DetectorsBase/Propagator.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ namespace field
4444
class MagFieldFast;
4545
}
4646

47+
namespace gpu
48+
{
49+
class GPUTPCGMPolynomialField;
50+
}
51+
4752
namespace base
4853
{
4954
class Propagator
@@ -104,6 +109,8 @@ class Propagator
104109

105110
GPUd() void setMatLUT(const o2::base::MatLayerCylSet* lut) { mMatLUT = lut; }
106111
GPUd() const o2::base::MatLayerCylSet* getMatLUT() const { return mMatLUT; }
112+
GPUd() void setGPUField(const o2::gpu::GPUTPCGMPolynomialField* field) { mGPUField = field; }
113+
GPUd() const o2::gpu::GPUTPCGMPolynomialField* getGPUField() const { return mGPUField; }
107114

108115
#ifndef GPUCA_GPUCODE
109116
static Propagator* Instance()
@@ -123,11 +130,13 @@ class Propagator
123130
#endif
124131

125132
GPUd() MatBudget getMatBudget(MatCorrType corrType, const o2::math_utils::Point3D<float>& p0, const o2::math_utils::Point3D<float>& p1) const;
133+
GPUd() void getFiedXYZ(const math_utils::Point3D<float> xyz, float* bxyz) const;
126134

127135
const o2::field::MagFieldFast* mField = nullptr; ///< External fast field (barrel only for the moment)
128136
float mBz = 0; // nominal field
129137

130-
const o2::base::MatLayerCylSet* mMatLUT = nullptr; // externally set LUT
138+
const o2::base::MatLayerCylSet* mMatLUT = nullptr; // externally set LUT
139+
const o2::gpu::GPUTPCGMPolynomialField* mGPUField = nullptr; // externally set GPU Field
131140

132141
ClassDef(Propagator, 0);
133142
};

Detectors/Base/src/Propagator.cxx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010

1111
#include "DetectorsBase/Propagator.h"
1212
#include "GPUCommonLogger.h"
13-
#include "Field/MagFieldFast.h"
13+
#include "GPUTPCGMPolynomialField.h"
1414
#include "MathUtils/Utils.h"
1515
#include "ReconstructionDataFormats/Vertex.h"
1616

1717
using namespace o2::base;
1818

19-
#ifndef GPUCA_STANDALONE
19+
#if !defined(GPUCA_GPUCODE)
20+
#include "Field/MagFieldFast.h" // Don't use this on the GPU
21+
#endif
22+
23+
#if !defined(GPUCA_STANDALONE) && !defined(GPUCA_GPUCODE)
2024
#include "Field/MagneticField.h"
2125
#include "DataFormatsParameters/GRPObject.h"
2226
#include "DetectorsBase/GeometryManager.h"
@@ -125,7 +129,7 @@ GPUd() bool Propagator::PropagateToXBxByBz(o2::track::TrackParCov& track, float
125129
}
126130
auto x = track.getX() + step;
127131
auto xyz0 = track.getXYZGlo();
128-
mField->Field(xyz0, &b[0]);
132+
getFiedXYZ(xyz0, &b[0]);
129133

130134
if (!track.propagateTo(x, b)) {
131135
return false;
@@ -184,7 +188,7 @@ GPUd() bool Propagator::PropagateToXBxByBz(o2::track::TrackPar& track, float xTo
184188
}
185189
auto x = track.getX() + step;
186190
auto xyz0 = track.getXYZGlo();
187-
mField->Field(xyz0, &b[0]);
191+
getFiedXYZ(xyz0, &b[0]);
188192

189193
if (!track.propagateParamTo(x, b)) {
190194
return false;
@@ -516,3 +520,19 @@ GPUd() MatBudget Propagator::getMatBudget(Propagator::MatCorrType corrType, cons
516520
#endif
517521
return mMatLUT->getMatBudget(p0.X(), p0.Y(), p0.Z(), p1.X(), p1.Y(), p1.Z());
518522
}
523+
524+
GPUd() void Propagator::getFiedXYZ(const math_utils::Point3D<float> xyz, float* bxyz) const
525+
{
526+
if (mGPUField) {
527+
#if defined(GPUCA_GPUCODE_DEVICE) && defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM)
528+
const auto* f = &GPUCA_CONSMEM.param.polynomialField; // Access directly from constant memory on GPU (copied here to avoid complicated header dependencies)
529+
#else
530+
const auto* f = mGPUField;
531+
#endif
532+
f->GetField(xyz.X(), xyz.Y(), xyz.Z(), bxyz);
533+
} else {
534+
#ifndef GPUCA_GPUCODE
535+
mField->Field(xyz, bxyz); // Must not call the host-only function in GPU compilation
536+
#endif
537+
}
538+
}

GPU/GPUTracking/Merger/GPUTPCGMPolynomialField.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef GPUTPCGMPOLYNOMIALFIELD_H
1515
#define GPUTPCGMPOLYNOMIALFIELD_H
1616

17-
#include "GPUTPCDef.h"
17+
#include "GPUCommonDef.h"
1818

1919
namespace GPUCA_NAMESPACE
2020
{

0 commit comments

Comments
 (0)