ATLAS Offline Software
Loading...
Searching...
No Matches
GPUClusterSorter.cxx
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3//
4// Dear emacs, this is -*- c++ -*-
5//
6
7#include "GPUClusterSorter.h"
9
10#include "boost/chrono/chrono.hpp"
11#include "boost/chrono/thread_clock.hpp"
12
13using namespace CaloRecGPU;
14using namespace GPUClusterSorting;
15
16GPUClusterSorter::GPUClusterSorter(const std::string & type, const std::string & name, const IInterface * parent):
17 base_class(type, name, parent),
18 CaloGPUTimed(this)
19{
20}
21
23{
24 ATH_CHECK( m_kernelSizeOptimizer.retrieve() );
25 return StatusCode::SUCCESS;
26}
27
29{
31 return StatusCode::SUCCESS;
32}
33
34StatusCode GPUClusterSorter::execute(const EventContext & ctx, const ConstantDataHolder & constant_data,
35 EventDataHolder & event_data, void * /*temporary_buffer*/) const
36{
37 using clock_type = boost::chrono::thread_clock;
38 auto time_cast = [](const auto & before, const auto & after)
39 {
40 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
41 };
42
43 const auto start = clock_type::now();
44
45 const auto before_properties = clock_type::now();
46
48
49 const auto before_sort = clock_type::now();
50
51 sortClusters(event_data, constant_data, *(m_kernelSizeOptimizer.get()), m_measureTimes);
52
53 const auto before_finalize = clock_type::now();
54
55 finalizeClusterAssignment(event_data, constant_data, *(m_kernelSizeOptimizer.get()), m_measureTimes);
56
57 const auto end = clock_type::now();
58
60 {
61 record_times(ctx.evt(),
62 time_cast(start, before_properties),
63 time_cast(before_properties, before_sort),
64 time_cast(before_sort, before_finalize),
65 time_cast(before_finalize, end)
66 );
67 }
68
69
70 return StatusCode::SUCCESS;
71
72}
73
75{
77 {
78 print_times("Preprocessing Calculating_ET Sorting_Clusters Finalizing_Clusters", 4);
79 }
80 return StatusCode::SUCCESS;
81}
82
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
CaloGPUTimed(T *ptr)
void print_times(const std::string &header, const size_t time_size) const
void record_times(const size_t event_num, const std::vector< size_t > &times) const
Holds CPU and GPU versions of the geometry and cell noise information, which are assumed to be consta...
Definition DataHolders.h:27
Holds the mutable per-event information (clusters and cells) and provides utilities to convert betwee...
Definition DataHolders.h:73
virtual StatusCode execute(const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, CaloRecGPU::EventDataHolder &event_data, void *temporary_buffer) const override
Gaudi::Property< float > m_clusterETThreshold
cut on the clusters.
Gaudi::Property< bool > m_cutClustersInAbsE
if set to true cluster cuts are on , if false on .
virtual StatusCode initialize_CUDA() override
Initialization that invokes CUDA functions.
ServiceHandle< IGPUKernelSizeOptimizerSvc > m_kernelSizeOptimizer
Handle to the CUDA kernel block and grid size optimization service.
GPUClusterSorter(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode finalize() override
virtual StatusCode initialize_non_CUDA() override
Initialization that does not invoke CUDA functions.
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
void register_kernels(IGPUKernelSizeOptimizer &optimizer)
void sortClusters(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})
void initialPropertiesCalculation(CaloRecGPU::EventDataHolder &holder, 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={})
void finalizeClusterAssignment(CaloRecGPU::EventDataHolder &holder, const CaloRecGPU::ConstantDataHolder &instance_data, const IGPUKernelSizeOptimizer &optimizer, const bool synchronize=false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream_to_use={})