Skip to content

Commit

Permalink
Avoid linking to GPUTracking where possible, use GPUDataTypes / GPUCo…
Browse files Browse the repository at this point in the history
…mmon / GPUO2Interface
  • Loading branch information
davidrohr committed Mar 1, 2024
1 parent 60229bc commit b6c1a14
Show file tree
Hide file tree
Showing 27 changed files with 242 additions and 154 deletions.
2 changes: 1 addition & 1 deletion Detectors/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ o2_add_library(DetectorsBase
O2::SimulationDataFormat
O2::SimConfig
O2::CCDB
O2::GPUDataTypeHeaders
MC::VMC
TBB::tbb
PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/GPU/GPUTracking/Merger # Must not link to avoid cyclic dependency
)

o2_target_root_dictionary(DetectorsBase
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TPC/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ o2_add_library(TPCCalibration
Microsoft.GSL::GSL
O2::DetectorsCalibration
O2::GPUO2Interface
O2::GPUTracking
O2::GPUDataTypes
O2::TPCFastTransformation
O2::DataFormatsCTP
O2::CCDB
Expand Down
5 changes: 1 addition & 4 deletions Detectors/TPC/calibration/src/TrackDump.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
#include <vector>
#include <filesystem>
#include <fmt/format.h>
#include "GPUO2Interface.h"
#include "GPUDefOpenCL12Templates.h"
#include "GPUDefConstantsAndSettings.h"
#include "SliceTracker/GPUTPCGeometry.h"
#include "GPUTPCGeometry.h"

#include "DataFormatsTPC/Defs.h"
#include "DataFormatsTPC/ClusterNative.h"
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TPC/reconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ o2_add_test(AdcClockMonitor
o2_add_test(GPUCATracking
COMPONENT_NAME tpc
LABELS tpc
PUBLIC_LINK_LIBRARIES O2::TPCReconstruction
PUBLIC_LINK_LIBRARIES O2::TPCReconstruction O2::GPUO2Interface
SOURCES test/testGPUCATracking.cxx
ENVIRONMENT O2_ROOT=${CMAKE_BINARY_DIR}/stage)

Expand Down
5 changes: 3 additions & 2 deletions Detectors/TPC/reconstruction/test/testGPUCATracking.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "CorrectionMapsHelper.h"
#include "TPCFastTransform.h"
#include "GPUO2Interface.h"
#include "GPUO2InterfaceUtils.h"
#include "GPUO2InterfaceConfiguration.h"
#include "TPCPadGainCalib.h"
#include "CalibdEdxContainer.h"
Expand Down Expand Up @@ -79,9 +80,9 @@ BOOST_AUTO_TEST_CASE(CATracking_test1)
fastTransformHelper->setCorrMap(fastTransform.get());
config.configCalib.fastTransform = fastTransform.get();
config.configCalib.fastTransformHelper = fastTransformHelper.get();
auto dEdxCalibContainer = GPUO2Interface::getCalibdEdxContainerDefault();
auto dEdxCalibContainer = GPUO2InterfaceUtils::getCalibdEdxContainerDefault();
config.configCalib.dEdxCalibContainer = dEdxCalibContainer.get();
std::unique_ptr<TPCPadGainCalib> gainCalib = GPUO2Interface::getPadGainCalibDefault();
std::unique_ptr<TPCPadGainCalib> gainCalib = GPUO2InterfaceUtils::getPadGainCalibDefault();
config.configCalib.tpcPadGain = gainCalib.get();

tracker.Initialize(config);
Expand Down
7 changes: 3 additions & 4 deletions Detectors/TPC/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ o2_add_library(TPCWorkflow
O2::TPCQC O2::DetectorsCalibration
O2::TPCReaderWorkflow
O2::CTPWorkflowIO
PRIVATE_LINK_LIBRARIES O2::GPUTracking # For the Zero Suppression includes
O2::GPUWorkflow
O2::GPUWorkflow
PRIVATE_LINK_LIBRARIES O2::GPUTracking
)

o2_add_library(TPCWorkflowGUI
Expand All @@ -62,7 +62,6 @@ o2_add_library(TPCWorkflowGUI
O2::TPCMonitor
)


o2_add_executable(chunkeddigit-merger
COMPONENT_NAME tpc
TARGETVARNAME mergertargetName
Expand Down Expand Up @@ -250,7 +249,7 @@ o2_add_test(workflow

o2_add_executable(digits-to-rawzs
COMPONENT_NAME tpc
PUBLIC_LINK_LIBRARIES O2::TPCBase O2::SimulationDataFormat O2::GPUO2Interface O2::GPUTracking O2::DetectorsRaw O2::TPCReconstruction
PUBLIC_LINK_LIBRARIES O2::TPCBase O2::SimulationDataFormat O2::GPUO2Interface O2::DetectorsRaw O2::TPCReconstruction
SOURCES src/convertDigitsToRawZS.cxx)

o2_add_executable(monitor-workflow
Expand Down
9 changes: 3 additions & 6 deletions Detectors/TPC/workflow/src/CalibProcessingHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include <fmt/format.h>
#include <fmt/chrono.h>

#include "GPUO2Interface.h"
#include "GPUParam.h"
#include "GPUReconstructionConvert.h"
#include "GPUO2InterfaceUtils.h"
#include "Framework/ConcreteDataMatcher.h"
#include "Framework/InputRecordWalker.h"
#include "Framework/Logger.h"
Expand Down Expand Up @@ -290,9 +288,8 @@ void processLinkZS(o2::framework::RawParser<>& parser, std::unique_ptr<o2::tpc::

if ((decoderType == 1) && (linkID == rdh_utils::ILBZSLinkID || linkID == rdh_utils::DLBZSLinkID) && (detField == raw_data_types::Type::ZS)) {
std::vector<Digit> digits;
static o2::gpu::GPUParam gpuParam;
static o2::gpu::GPUReconstructionZSDecoder gpuDecoder;
gpuDecoder.DecodePage(digits, (const void*)it.raw(), firstOrbit, gpuParam, static_cast<unsigned int>((triggerBC > 0) ? triggerBC : 0));
static o2::gpu::GPUO2InterfaceUtils::GPUReconstructionZSDecoder gpuDecoder;
gpuDecoder.DecodePage(digits, (const void*)it.raw(), firstOrbit, nullptr, static_cast<unsigned int>((triggerBC > 0) ? triggerBC : 0));
for (const auto& digit : digits) {
reader->getManager()->getLinkZSCallback()(digit.getCRU(), digit.getRow(), digit.getPad(), digit.getTimeStamp(), digit.getChargeFloat());
}
Expand Down
10 changes: 3 additions & 7 deletions Detectors/TPC/workflow/src/ZSSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
#include <array>
#include <unistd.h>
#include <atomic>
#include "GPUParam.h"
#include "GPUReconstructionConvert.h"
#include "GPUO2InterfaceUtils.h"
#include "DetectorsRaw/RawFileWriter.h"
#include "DetectorsRaw/HBFUtils.h"
#include "DetectorsRaw/RDHUtils.h"
Expand Down Expand Up @@ -100,10 +99,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
auto& sizes = processAttributes->sizes;
auto& verbosity = processAttributes->verbosity;

GPUParam _GPUParam;

processAttributes->config.configGRP.solenoidBz = 5.00668;
_GPUParam.SetDefaults(&processAttributes->config.configGRP, &processAttributes->config.configReconstruction, &processAttributes->config.configProcessing, nullptr);
std::function<void(std::vector<o2::tpc::Digit>&)> digitsFilter = nullptr;
if (processAttributes->globalConfig.zsOnTheFlyDigitsFilter) {
digitsFilter = [processAttributes](std::vector<o2::tpc::Digit>& digits) {
Expand All @@ -119,7 +115,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
const auto& inputs = getWorkflowTPCInput(pc, 0, false, false, tpcSectorMask, true);
sizes.resize(NSectors * NEndpoints);
o2::InteractionRecord ir{0, pc.services().get<o2::framework::TimingInfo>().firstTForbit};
o2::gpu::GPUReconstructionConvert::RunZSEncoder<DigitArray>(inputs->inputDigits, &zsoutput, sizes.data(), nullptr, &ir, _GPUParam, 4, verify, processAttributes->config.configReconstruction.tpc.zsThreshold, false, digitsFilter);
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder<DigitArray>(inputs->inputDigits, &zsoutput, sizes.data(), nullptr, &ir, processAttributes->config, 4, verify, false, digitsFilter);
ZeroSuppressedContainer8kb* page = reinterpret_cast<ZeroSuppressedContainer8kb*>(zsoutput.get());
unsigned int offset = 0;
for (unsigned int i = 0; i < NSectors; i++) {
Expand Down Expand Up @@ -172,7 +168,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
writer.useCaching();
}
ir = o2::raw::HBFUtils::Instance().getFirstSampledTFIR();
o2::gpu::GPUReconstructionConvert::RunZSEncoder(inputs->inputDigits, nullptr, nullptr, &writer, &ir, _GPUParam, 4, false, processAttributes->config.configReconstruction.tpc.zsThreshold, false, digitsFilter);
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder(inputs->inputDigits, nullptr, nullptr, &writer, &ir, processAttributes->config, 4, false, false, digitsFilter);
writer.writeConfFile("TPC", "RAWDATA", fmt::format("{}tpcraw.cfg", outDir));
}
zsoutput.reset(nullptr);
Expand Down
9 changes: 2 additions & 7 deletions Detectors/TPC/workflow/src/convertDigitsToRawZS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#include "TTree.h"
#include "TROOT.h"

#include "GPUO2Interface.h"
#include "GPUReconstructionConvert.h"
#include "GPUO2InterfaceUtils.h"
#include "GPUHostDataTypes.h"
#include "GPUParam.h"

#include "Framework/Logger.h"
#include "DetectorsRaw/RawFileWriter.h"
Expand Down Expand Up @@ -233,13 +231,10 @@ void convertDigitsToZSfinal(std::string_view digitsFile, std::string_view output
void convert(DigitArray& inputDigits, ProcessAttributes* processAttributes, o2::raw::RawFileWriter& writer)
{
const auto zsThreshold = processAttributes->zsThreshold;
GPUParam _GPUParam;
_GPUParam.SetDefaults(5.00668);
const GPUParam mGPUParam = _GPUParam;

o2::InteractionRecord ir = o2::raw::HBFUtils::Instance().getFirstSampledTFIR();
ir.bc = 0; // By convention the TF starts at BC = 0
o2::gpu::GPUReconstructionConvert::RunZSEncoder(inputDigits, nullptr, nullptr, &writer, &ir, mGPUParam, processAttributes->version, false, zsThreshold, processAttributes->padding, processAttributes->digitsFilter);
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder(inputDigits, nullptr, nullptr, &writer, &ir, processAttributes->version, false, zsThreshold, processAttributes->padding, processAttributes->digitsFilter);
}

int main(int argc, char** argv)
Expand Down
1 change: 0 additions & 1 deletion Detectors/TRD/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ o2_add_library(TRDCalibration
O2::DetectorsBase
O2::DetectorsCalibration
O2::MathUtils
O2::GPUTracking
O2::DetectorsDCS)

o2_target_root_dictionary(TRDCalibration
Expand Down
1 change: 0 additions & 1 deletion Detectors/TRD/pid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ o2_add_library(TRDPID
O2::DataFormatsGlobalTracking
O2::DetectorsBase
O2::MathUtils
O2::GPUTracking
O2::Framework
O2::ReconstructionDataFormats
fmt::fmt
Expand Down
3 changes: 1 addition & 2 deletions Detectors/TRD/qc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ o2_add_library(TRDQC
O2::DataFormatsTRD
O2::DataFormatsGlobalTracking
O2::DetectorsBase
O2::MathUtils
O2::GPUTracking)
O2::MathUtils)

o2_target_root_dictionary(TRDQC
HEADERS include/TRDQC/Tracking.h
Expand Down
2 changes: 2 additions & 0 deletions GPU/Common/GPUCommonDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#ifdef GPUCA_NOCOMPAT
#define CON_DELETE = delete
#define CON_DEFAULT = default
#define GPUCA_CPP11_INIT(...) __VA_ARGS__
#if defined(__cplusplus) && __cplusplus >= 201703L
#define CONSTEXPR constexpr
#else
Expand All @@ -63,6 +64,7 @@
#define CON_DELETE
#define CON_DEFAULT
#define CONSTEXPR
#define GPUCA_CPP11_INIT(...)
#endif
#if defined(__ROOT__) && !defined(GPUCA_NOCOMPAT)
#define VOLATILE // ROOT5 has a problem with volatile in CINT
Expand Down
33 changes: 10 additions & 23 deletions GPU/GPUTracking/Base/GPUReconstructionConvert.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1464,10 +1464,14 @@ void GPUReconstructionConvert::RunZSFilter(std::unique_ptr<o2::tpc::Digit[]>* bu

#ifdef GPUCA_O2_LIB
template <class T>
static inline auto GetDecoder_internal(const GPUParam& param, int version)
static inline auto GetDecoder_internal(const GPUParam* param, int version)
{
std::shared_ptr<T> enc = std::make_shared<T>();
enc->param = &param;
if (param == nullptr) {
static GPUParam dummyParam;
param = &dummyParam;
}
enc->param = param;
enc->zsVersion = version;
enc->init();
return [enc](std::vector<o2::tpc::Digit>& outBuffer, const void* page, unsigned int firstTfOrbit, unsigned int triggerBC = 0) {
Expand All @@ -1485,33 +1489,16 @@ static inline auto GetDecoder_internal(const GPUParam& param, int version)
};
}

std::function<void(std::vector<o2::tpc::Digit>&, const void*, unsigned int, unsigned int)> GPUReconstructionConvert::GetDecoder(int version, const GPUParam& param)
std::function<void(std::vector<o2::tpc::Digit>&, const void*, unsigned int, unsigned int)> GPUReconstructionConvert::GetDecoder(int version, const GPUParam* param)
{
if (version >= ZSVersion::ZSVersionRowBased10BitADC && version <= ZSVersion::ZSVersionRowBased12BitADC) {
if (version >= o2::tpc::ZSVersion::ZSVersionRowBased10BitADC && version <= o2::tpc::ZSVersion::ZSVersionRowBased12BitADC) {
return GetDecoder_internal<zsEncoderRow>(param, version);
} else if (version == ZSVersion::ZSVersionLinkBasedWithMeta) {
} else if (version == o2::tpc::ZSVersion::ZSVersionLinkBasedWithMeta) {
return GetDecoder_internal<zsEncoderImprovedLinkBased>(param, version);
} else if (version >= ZSVersion::ZSVersionDenseLinkBased && version <= ZSVersion::ZSVersionDenseLinkBasedV2) {
} else if (version >= o2::tpc::ZSVersion::ZSVersionDenseLinkBased && version <= o2::tpc::ZSVersion::ZSVersionDenseLinkBasedV2) {
return GetDecoder_internal<zsEncoderDenseLinkBased>(param, version);
} else {
throw std::runtime_error("Invalid ZS version "s + std::to_string(version) + ", cannot create decoder"s);
}
}

void GPUReconstructionZSDecoder::DecodePage(std::vector<o2::tpc::Digit>& outputBuffer, const void* page, unsigned int tfFirstOrbit, const GPUParam& param, unsigned int triggerBC)
{
const o2::header::RAWDataHeader* rdh = (const o2::header::RAWDataHeader*)page;
if (o2::raw::RDHUtils::getMemorySize(*rdh) == sizeof(o2::header::RAWDataHeader)) {
return;
}
TPCZSHDR* const hdr = (TPCZSHDR*)(rdh_utils::getLink(o2::raw::RDHUtils::getFEEID(*rdh)) == rdh_utils::DLBZSLinkID ? ((const char*)page + o2::raw::RDHUtils::getMemorySize(*rdh) - sizeof(TPCZSHDRV2)) : ((const char*)page + sizeof(o2::header::RAWDataHeader)));

if (mDecoders.size() < hdr->version + 1) {
mDecoders.resize(hdr->version + 1);
}
if (mDecoders[hdr->version] == nullptr) {
mDecoders[hdr->version] = GPUReconstructionConvert::GetDecoder(hdr->version, param);
}
mDecoders[hdr->version](outputBuffer, page, tfFirstOrbit, triggerBC);
}
#endif
11 changes: 1 addition & 10 deletions GPU/GPUTracking/Base/GPUReconstructionConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ class GPUReconstructionConvert
static int GetMaxTimeBin(const o2::tpc::ClusterNativeAccess& native);
static int GetMaxTimeBin(const GPUTrackingInOutDigits& digits);
static int GetMaxTimeBin(const GPUTrackingInOutZS& zspages);
static std::function<void(std::vector<o2::tpc::Digit>&, const void*, unsigned int, unsigned int)> GetDecoder(int version, const GPUParam& param);
};

class GPUReconstructionZSDecoder
{
public:
void DecodePage(std::vector<o2::tpc::Digit>& outputBuffer, const void* page, unsigned int tfFirstOrbit, const GPUParam& param, unsigned int triggerBC = 0);

private:
std::vector<std::function<void(std::vector<o2::tpc::Digit>&, const void*, unsigned int, unsigned int)>> mDecoders;
static std::function<void(std::vector<o2::tpc::Digit>&, const void*, unsigned int, unsigned int)> GetDecoder(int version, const GPUParam* param);
};

} // namespace gpu
Expand Down
Loading

0 comments on commit b6c1a14

Please sign in to comment.