ATLAS Offline Software
Loading...
Searching...
No Matches
TracccMeasurementDeviceConverterAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ACTSGPUEVENT_TRACCCMEASUREMENTDEVICECONVERTERALG_H
5#define ACTSGPUEVENT_TRACCCMEASUREMENTDEVICECONVERTERALG_H
6
15#include "GaudiKernel/ToolHandle.h"
20
21#include <traccc/edm/measurement_collection.hpp>
22#include <traccc/geometry/detector.hpp>
23#include <vecmem/memory/memory_resource.hpp>
24#include <traccc/geometry/detector_conditions_description.hpp>
25#include <traccc/geometry/detector_buffer.hpp>
26
27#include <cuda_runtime_api.h>
28
30#define CUDA_ERROR_CHECK(EXP) \
31 do { \
32 cudaError_t errorCode = EXP; \
33 if (errorCode != cudaSuccess) { \
34 errorcheck::ReportMessage(MSG::ERROR, ERRORCHECK_ARGS, \
35 __PRETTY_FUNCTION__, \
36 StatusCode::FAILURE) \
37 .msgstream() \
38 << "Failed to execute: " << #EXP << " (" \
39 << cudaGetErrorString(errorCode) << ")"; \
40 return StatusCode::FAILURE; \
41 } \
42 } while (false)
43
44namespace ActsTrk {
45
61{
62public:
63 using AthReentrantAlgorithm::AthReentrantAlgorithm;
64
66 virtual StatusCode initialize() override;
68 virtual StatusCode execute(const EventContext& ctx) const override;
70 virtual StatusCode finalize() override;
71
72private:
73
76 this, "InputMeasurements", "TracccMeasurements",
77 "Input traccc measurement collection buffer"};
78
82 this, "OutputPixelClusters", "ITkTracccPixelClusters",
83 "Output xAOD pixel cluster container"};
85 this, "OutputStripClusters", "ITkTracccStripClusters",
86 "Output xAOD strip cluster container"};
87
88
90 ToolHandle<AthDevice::IMemoryResourcesTool> m_mrTool{
91 this, "MemoryResourcesTool", "", "Tool that provides memory resources"};
92
93 ToolHandle<AthDevice::ICopiesTool> m_copiesTool{
94 this, "CopiesProviderTool", "", "Tool that provides vecmem copy objects"};
95
96 ToolHandle<AthCUDA::IStreamTool> m_streamTool{
97 this, "StreamTool", "", "Tool that provides CUDA streams"};
98
99 Gaudi::Property<std::string> m_deviceDetectorName{
100 this, "DeviceDetectorName", "",
101 "Detray device detector object"};
103 this, "DeviceConditionsObjectName", "",
104 "Key for reading the per-IOV traccc device conditions object"};
105
106 const traccc::detector_buffer* m_detector{nullptr};
107
110 mutable std::atomic<int> m_nPix = 0;
111 mutable std::atomic<int> m_nStrip = 0;
112 mutable std::atomic<int> m_nMeas = 0;
114};
115
116// Converts the "input" traccc measurements into the output GPU buffer,
117// output_pixel_meas and output_strip_meas.
118//
119// The provided output buffers are allocated during this function and their
120// respective sizes are returned in output_n_pixels and output_n_strips.
121//
122// If nb_measurements is 0 this function returns immediately, no allocation
123// takes place and no output counter is set.
124//
125// The input measurement container contains both Pixels and Strips measurements
126// that need to be separated. Internally this functions counts each type and
127// then allocate the output buffers, and finally converts the input measurements
128// in place in the output buffers.
130 cudaStream_t stream
131 , vecmem::memory_resource & mr
132 , vecmem::copy const & copy
133 , traccc::itk_detector::view_type const & detector_view
134 , traccc::detector_conditions_description::const_view const & detector_conditions_view
135 , traccc::edm::measurement_collection::const_view::size_type nb_measurements
136 , const traccc::edm::measurement_collection::const_view & input
137 , DevicePixelMeasurementContainer::view::size_type & output_n_pixels
138 , DeviceStripMeasurementContainer::view::size_type & output_n_strips
139 , std::unique_ptr<DevicePixelMeasurementContainer::buffer> & output_pixel_meas
140 , std::unique_ptr<DeviceStripMeasurementContainer::buffer> & output_strip_meas
141 );
142
143
144} // namespace ActsTrk
145
146#endif // ACTSGPUEVENT_TRACCCMEASUREMENTDEVICECONVERTERALG_H
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Algorithm converting traccc measurements (device buffer) to xAOD clusters (host container).
SG::ReadCondHandleKey< traccc::detector_conditions_description::buffer > m_deviceCondKey
std::atomic< int > m_nPix
The object counters for debug prints in finalize method {.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_outputPixelKey
virtual StatusCode finalize() override
Function finalizing the algorthm.
SG::ReadHandleKey< traccc::edm::measurement_collection::buffer > m_inputMeasKey
virtual StatusCode initialize() override
Function initializing the algorithm.
ToolHandle< AthDevice::IMemoryResourcesTool > m_mrTool
SG::WriteHandleKey< xAOD::StripClusterContainer > m_outputStripKey
An algorithm that can be simultaneously executed in multiple threads.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
StatusCode convertMeasurementsOnGPU(cudaStream_t stream, vecmem::memory_resource &mr, vecmem::copy const &copy, traccc::itk_detector::view_type const &detector_view, traccc::detector_conditions_description::const_view const &detector_conditions_view, traccc::edm::measurement_collection::const_view::size_type nb_measurements, const traccc::edm::measurement_collection::const_view &input, DevicePixelMeasurementContainer::view::size_type &output_n_pixels, DeviceStripMeasurementContainer::view::size_type &output_n_strips, std::unique_ptr< DevicePixelMeasurementContainer::buffer > &output_pixel_meas, std::unique_ptr< DeviceStripMeasurementContainer::buffer > &output_strip_meas)