 |
ATLAS Offline Software
|
Go to the documentation of this file.
26 #include "boost/chrono/chrono.hpp"
27 #include "boost/chrono/thread_clock.hpp"
35 m_constantDataSent(false)
51 bool any_failed =
false;
53 auto retrieve_and_report = [&](
auto &
var,
const auto &
type,
bool & falsify_if_empty)
57 falsify_if_empty =
false;
60 else if (
var.retrieve().isFailure())
105 return StatusCode::FAILURE;
122 return StatusCode::SUCCESS;
160 return StatusCode::SUCCESS;
170 ATH_CHECK( cluster_collection.
record (std::make_unique<xAOD::CaloClusterContainer>(), std::make_unique<xAOD::CaloClusterTrigAuxContainer> () ));
183 std::lock_guard<std::mutex> lock_guard(
m_mutex);
200 ATH_MSG_ERROR(
"Could not get valid Event Data Holder! Event: " << ctx.evt() );
201 return StatusCode::FAILURE;
213 if (!temporaries_data_ptr_holder)
215 ATH_MSG_ERROR(
"temporaries_data_ptr_holder is null in CaloGPUHybridClusterProcessor::execute" );
216 return StatusCode::FAILURE;
223 ATH_MSG_ERROR(
"Could not get valid temporary buffer holder! Event: " << ctx.evt() );
224 return StatusCode::FAILURE;
230 using clock_type = boost::chrono::thread_clock;
231 auto time_cast = [](
const auto & before,
const auto & after)
233 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
236 std::vector<size_t>
times;
238 size_t plot_time = 0;
245 times.reserve(time_size);
255 plot_time += time_cast(
t1,
t2);
262 ATH_CHECK( pre_GPU_tool->execute(ctx, cluster_collection_ptr) );
275 plot_time += time_cast(
t3,
t4);
298 plot_time += time_cast(
t1,
t2);
305 ATH_CHECK( GPU_tool->execute(ctx, constant_data_holder, *event_data_ptr, temporaries_data_ptr_holder->
get_pointer()) );
314 ATH_CHECK(
m_plotterTool->update_plots(ctx, constant_data_holder, cluster_collection_ptr, *event_data_ptr, GPU_tool.get()) );
318 plot_time += time_cast(
t3,
t4);
341 plot_time += time_cast(
t1,
t2);
348 ATH_CHECK( post_GPU_tool->execute(ctx, cluster_collection_ptr) );
352 times.push_back(time_cast(t9, t10));
361 plot_time += time_cast(
t3,
t4);
373 plot_time += time_cast(
t1,
t2);
386 decor_handle(*
cl) = 0;
390 decor_handle(*
cl) = cell_links->
size();
395 ATH_MSG_DEBUG(
"Created cluster container with " << cluster_collection->
size() <<
" clusters");
405 times.push_back(plot_time);
410 return StatusCode::SUCCESS;
417 std::string header_string;
419 auto add_name_to_string = [&](
const auto &
obj)
421 std::string
rep =
obj->name();
423 header_string +=
rep +
" ";
428 add_name_to_string(pre_GPU_tool);
438 add_name_to_string(GPU_tool);
448 add_name_to_string(post_GPU_tool);
464 return StatusCode::SUCCESS;
std::vector< LUCID_DigitContainer_p2 > t6
std::string replace(std::string s, const std::string &s2, const std::string &s3)
ToolHandle< ICaloClusterGPUOutputTransformer > m_transformBackToCPU
The tool that will convert the data from the GPU back to the CPU.
Gaudi::Property< bool > m_skipConversions
If true, both constant and event data conversion is skipped.
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
virtual StatusCode finalize() override
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
std::vector< LUCID_SimHit_p3 > t8
void allocate(const size_t size)
std::vector< LUCID_RawData_p1 > t3
size_t m_temporariesSize
The size of the temporary buffer to allocate for the GPU tools that will be called.
std::vector< ALFA_RawDataCollection_p1 > t1
Gaudi::Property< bool > m_writeTriggerSpecificInfo
If true, writes some trigger-specific decorations.
ToolHandle< ICaloClusterGPUPlotter > m_plotterTool
An optional plotter, for testing and/or debugging purposes.
std::vector< LUCID_SimHit_p2 > t7
const T * get(size_type n) const
Access an element, as an rvalue.
const std::string & key() const
Return the StoreGate ID for the referenced object.
ToolHandleArray< CaloClusterGPUProcessor > m_GPUoperations
Tools to be applied to the clusters on the GPU.
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize_CUDA() override
Initialization that invokes CUDA functions.
Base class to provide some basic common infrastructure for timing measurements...
CaloGPUHybridClusterProcessor(const std::string &name, ISvcLocator *pSvcLocator)
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< bool > m_doPlots
If true, calls the plotter specified by m_plotterTool at every tool execution.
virtual StatusCode initialize_non_CUDA() override
Initialization that does not invoke CUDA functions.
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
Description of a calorimeter cluster.
CaloRecGPU::Helpers::separate_thread_holder< CaloRecGPU::EventDataHolder > m_eventDataThreadedHolder ATLAS_THREAD_SAFE
A way to reduce allocations over multiple threads by keeping a cache of previously allocated objects ...
std::mutex m_mutex
This mutex is locked when sending the constant data on the first event to ensure thread safety.
void allocate(const bool also_GPU=true)
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
Handle class for adding a decoration to an object.
Handle class for adding a decoration to an object.
void print_times(const std::string &header, const size_t time_size) const
Gaudi::Property< bool > m_deferConstantDataToFirstEvent
If true, the constant data is only converted and sent to the GPU on the first event,...
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Header file to be included by clients of the Monitored infrastructure.
std::atomic< bool > m_constantDataSent
A flag to signal that the constant data has been adequately sent to the GPU.
std::vector< LUCID_RawDataContainer_p1 > t4
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_clusterCellLinkOutput
The name of the key in StoreGate for the output CaloClusterCellLinkContainer.
size_t size() const
size method
Helpers for checking error return status codes and reporting errors.
ToolHandleArray< CaloClusterCollectionProcessor > m_postGPUoperations
Tools to be applied to the clusters after returning from the GPU.
std::vector< LUCID_Digit_p2 > t5
std::vector< ALFA_RawDataContainer_p1 > t2
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_mDecor_ncells
Key to the handle for writing the number of cells as a decoration.
A simple RAII wrapper to ensure proper allocation and deallocation of GPU memory in a void * for the ...
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void record_times(const size_t event_num, const std::vector< size_t > ×) const
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
Gaudi::Property< size_t > m_numPreAllocatedGPUData
Number of events for which to pre-allocate space on GPU memory (should ideally be set to the expected...
ToolHandleArray< CaloClusterCollectionProcessor > m_preGPUoperations
Tools to be applied to the clusters before being sent to the GPU for processing.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_clusterOutput
The name of the key in StoreGate for the output CaloClusterContainer.
ToolHandle< ICaloClusterGPUConstantTransformer > m_transformConstantData
The tool that will convert the constant data from the CPU to the GPU.
ToolHandle< ICaloClusterGPUInputTransformer > m_transformForGPU
The tool that will actually convert the data from the CPU to the GPU.