ATLAS Offline Software
BasicGPUClusterInfoCalculator.cxx
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 //
4 // Dear emacs, this is -*- c++ -*-
5 //
6 
9 
10 #include "boost/chrono/chrono.hpp"
11 #include "boost/chrono/thread_clock.hpp"
12 
13 using namespace CaloRecGPU;
14 using namespace BasicClusterInfoCalculator;
15 
16 BasicGPUClusterInfoCalculator::BasicGPUClusterInfoCalculator(const std::string & type, const std::string & name, const IInterface * parent):
18  CaloGPUTimed(this)
19 {
20  declareInterface<CaloClusterGPUProcessor> (this);
21 }
22 
24 {
25  ATH_CHECK( m_kernelSizeOptimizer.retrieve() );
26  return StatusCode::SUCCESS;
27 }
28 
30 {
32  return StatusCode::SUCCESS;
33 }
34 
35 StatusCode BasicGPUClusterInfoCalculator::execute(const EventContext & ctx, const ConstantDataHolder & constant_data,
36  EventDataHolder & event_data, void * temporary_buffer) const
37 {
38  using clock_type = boost::chrono::thread_clock;
39  auto time_cast = [](const auto & before, const auto & after)
40  {
41  return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
42  };
43 
44  const auto start = clock_type::now();
45 
46  void * temp_store = (m_preserveClusterMoments ? temporary_buffer : (ClusterMomentsArr *) event_data.m_moments_dev);
47 
49 
50  const auto before_seed_properties = clock_type::now();
51 
52  updateSeedCellProperties(event_data, temporaries, constant_data, *(m_kernelSizeOptimizer.get()), m_measureTimes);
53 
54  const auto before_calculating = clock_type::now();
55 
57 
58  const auto end = clock_type::now();
59 
60 
61  if (m_measureTimes)
62  {
63  record_times(ctx.evt(),
64  time_cast(start, before_seed_properties),
65  time_cast(before_seed_properties, before_calculating),
66  time_cast(before_calculating, end)
67  );
68  }
69 
70 
71  return StatusCode::SUCCESS;
72 
73 }
74 
75 
77 {
78  if (m_measureTimes)
79  {
80  print_times("Preprocessing Seed_Cell_Properties_Updating Cluster_Properties_Calculation", 3);
81  }
82  return StatusCode::SUCCESS;
83 }
84 
BasicGPUClusterInfoCalculator::m_kernelSizeOptimizer
ServiceHandle< IGPUKernelSizeOptimizerSvc > m_kernelSizeOptimizer
Handle to the CUDA kernel block and grid size optimization service.
Definition: BasicGPUClusterInfoCalculator.h:96
BasicClusterInfoCalculator::calculateClusterProperties
void calculateClusterProperties(CaloRecGPU::EventDataHolder &holder, CaloRecGPU::Helpers::CUDA_kernel_object< ClusterInfoCalculatorTemporaries > temps, const CaloRecGPU::ConstantDataHolder &instance_data, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, const bool cut_in_absolute_ET=true, const float absolute_ET_threshold=-1, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
BasicGPUClusterInfoCalculator::m_clusterETThreshold
Gaudi::Property< float > m_clusterETThreshold
cut on the clusters.
Definition: BasicGPUClusterInfoCalculator.h:93
BasicGPUClusterInfoCalculator.h
CaloRecGPU::EventDataHolder::m_moments_dev
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::ClusterMomentsArr > m_moments_dev
Definition: DataHolders.h:91
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
BasicClusterInfoCalculator::updateSeedCellProperties
void updateSeedCellProperties(CaloRecGPU::EventDataHolder &holder, CaloRecGPU::Helpers::CUDA_kernel_object< ClusterInfoCalculatorTemporaries > temps, const CaloRecGPU::ConstantDataHolder &instance_data, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
BasicClusterInfoCalculator::ClusterInfoCalculatorTemporaries
Definition: BasicGPUClusterInfoCalculatorImpl.h:19
CaloRecGPU::Helpers::SimpleHolder
Holds one objects of type \T in memory context Context.
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:1067
BasicClusterInfoCalculator
Definition: BasicGPUClusterInfoCalculatorImpl.h:16
BasicGPUClusterInfoCalculator::BasicGPUClusterInfoCalculator
BasicGPUClusterInfoCalculator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: BasicGPUClusterInfoCalculator.cxx:16
BasicGPUClusterInfoCalculator::initialize_non_CUDA
virtual StatusCode initialize_non_CUDA() override
Initialization that does not invoke CUDA functions.
Definition: BasicGPUClusterInfoCalculator.cxx:23
CaloGPUTimed
Base class to provide some basic common infrastructure for timing measurements...
Definition: CaloGPUTimed.h:25
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
python.handimod.now
now
Definition: handimod.py:675
CaloRecGPU::EventDataHolder
Definition: DataHolders.h:35
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloGPUTimed::print_times
void print_times(const std::string &header, const size_t time_size) const
Definition: CaloGPUTimed.h:143
BasicGPUClusterInfoCalculator::execute
virtual StatusCode execute(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, CaloRecGPU::EventDataHolder &event_data, void *temporary_buffer) const override
Process the clusters on GPU.
Definition: BasicGPUClusterInfoCalculator.cxx:35
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BasicGPUClusterInfoCalculator::initialize_CUDA
virtual StatusCode initialize_CUDA() override
Initialization that invokes CUDA functions.
Definition: BasicGPUClusterInfoCalculator.cxx:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloRecGPU::ClusterMomentsArr
Definition: EventInfoDefinitions.h:342
BasicGPUClusterInfoCalculator::finalize
virtual StatusCode finalize() override
Definition: BasicGPUClusterInfoCalculator.cxx:76
CaloGPUTimed::record_times
void record_times(const size_t event_num, const std::vector< size_t > &times) const
Definition: CaloGPUTimed.h:86
CaloGPUTimed::m_measureTimes
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
Definition: CaloGPUTimed.h:46
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
BasicClusterInfoCalculator::register_kernels
void register_kernels(IGPUKernelSizeOptimizer &optimizer)
CaloRecGPU::ConstantDataHolder
Definition: DataHolders.h:19
BasicGPUClusterInfoCalculatorImpl.h
AthAlgTool
Definition: AthAlgTool.h:26
CaloRecGPU
Definition: BaseDefinitions.h:11
BasicGPUClusterInfoCalculator::m_cutClustersInAbsE
Gaudi::Property< bool > m_cutClustersInAbsE
if set to true cluster cuts are on , if false on .
Definition: BasicGPUClusterInfoCalculator.h:84
BasicGPUClusterInfoCalculator::m_preserveClusterMoments
Gaudi::Property< bool > m_preserveClusterMoments
If set to true, allocates a temporary array to store some temporary intermediate results instead of u...
Definition: BasicGPUClusterInfoCalculator.h:78