ATLAS Offline Software
Loading...
Searching...
No Matches
CaloRecGPU::EventDataHolder Class Reference

Holds the mutable per-event information (clusters and cells) and provides utilities to convert between this representation and the Athena data structures (i. More...

#include <DataHolders.h>

Collaboration diagram for CaloRecGPU::EventDataHolder:

Public Member Functions

void returnAndExportClusters (void *cluster_collection, const void *cell_collection_link, const MomentsOptionsArray &moments_to_add, const bool sort_clusters=true, const bool save_uncalibrated=true, const bool output_extra_moments=false, const std::vector< int > &extra_cells_to_fill={}, size_t *time_measurements=nullptr, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream={})
 We are using a void* for API to make this able to compile on the GPU without Athena-specific dependencies.
void allocate (const bool also_GPU=true)
void clear_GPU ()

Public Attributes

CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::CellInfoArrm_cell_info
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::ClusterInfoArrm_clusters
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::CellInfoArrm_cell_info_dev
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::ClusterInfoArrm_clusters_dev

Detailed Description

Holds the mutable per-event information (clusters and cells) and provides utilities to convert between this representation and the Athena data structures (i.

e. xAOD::CaloClusterContainer).

Definition at line 72 of file DataHolders.h.

Member Function Documentation

◆ allocate()

void CaloRecGPU::EventDataHolder::allocate ( const bool also_GPU = true)

Definition at line 1347 of file DataHolders.cxx.

1348{
1349 m_cell_info.allocate();
1350 m_clusters.allocate();
1351
1352 if (also_GPU)
1353 {
1354 m_cell_info_dev.allocate();
1355 m_clusters_dev.allocate();
1356 }
1357}
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::CellInfoArr > m_cell_info
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::CellInfoArr > m_cell_info_dev
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::ClusterInfoArr > m_clusters
CaloRecGPU::Helpers::CUDA_object< CaloRecGPU::ClusterInfoArr > m_clusters_dev

◆ clear_GPU()

void CaloRecGPU::EventDataHolder::clear_GPU ( )

Definition at line 1359 of file DataHolders.cxx.

1360{
1361 m_cell_info_dev.clear();
1362 m_clusters_dev.clear();
1363}

◆ returnAndExportClusters()

void CaloRecGPU::EventDataHolder::returnAndExportClusters ( void * cluster_collection,
const void * cell_collection_link,
const MomentsOptionsArray & moments_to_add,
const bool sort_clusters = true,
const bool save_uncalibrated = true,
const bool output_extra_moments = false,
const std::vector< int > & extra_cells_to_fill = {},
size_t * time_measurements = nullptr,
CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream = {} )

We are using a void* for API to make this able to compile on the GPU without Athena-specific dependencies.

The user should pass a const CaloCellCollection *. void importCells(const void * cell_collection, const std::vector<int> & extra_cells_to_fill = {});

/We are using a void* for API to make this able to compile on the GPU /without Athena-specific dependencies. The user should pass a /const xAOD::CaloClusterContainer *. /moments_to_add specifies which moments we will import. void importClusters(const void * cluster_collection, const MomentsOptionsArray & moments_to_add, const bool output_tags = true, const bool consider_shared_cells = true, const bool output_moments = false, const bool output_extra_moments = false, const std::vector<int> & extra_cells_to_fill = {});

/This function is asynchronous if clear_CPU and synchronize are false. /moments_to_add specifies which moments we will transfer to the GPU. /If full_copy is true, we will memcopy the whole structure /in bulk instead of enqueuing separate transfers up to the necessary size /(this will also ignore the moments_to_add). /If clear_CPU is true, we will wait until the transfers are finished /before deallocating. If synchronize is true, we will synchronize anyway. void sendToGPU(const MomentsOptionsArray & moments_to_add, const bool full_copy = false, const bool clear_CPU = false, const bool synchronize = false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream = {});

/moments_to_add specifies which moments we will transfer from the GPU. /If full_copy is true, we will memcopy the whole structure /in bulk instead of enqueuing separate transfers up to the necessary size /(this will also ignore the moments_to_add). /If full_copy is false, we will have a synchronization point before /enqueuing the transfers to know the sizes. /If clear_GPU is true, we will wait until the transfers are finished /before deallocating. If synchronize is true, we will synchronize anyway. void returnToCPU(const MomentsOptionsArray & moments_to_add, const bool full_copy = false, const bool clear_GPU = false, const bool synchronize = false, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream = {}, const bool also_return_cells = false);

/We are using a void* for API to make this able to compile on the GPU /without Athena-specific dependencies. The user should pass a /xAOD::CaloClusterContainer * and a const DataLink<CaloCellContainer> *. /moments_to_add specifies which moments we will import. /If sort_clusters is true, the clusters will be sorted based on /the transverse energy, otherwise the same order will be kept. /If save_uncalibrated, the basic cluster information will be saved /as raw. /If time_measurements is not null, separate time measurements /for the five stages (cell link creation, cell assignment, /sorting, basic info filling and moments filling) will be stored. void exportClusters(void * cluster_collection, const void * cell_collection_link, const MomentsOptionsArray & moments_to_add, const bool sort_clusters = true, const bool save_uncalibrated = true, const bool output_extra_moments = false, const std::vector<int> & extra_cells_to_fill = {}, size_t * time_measurements = nullptr);

/We are using a void* for API to make this able to compile on the GPU /without Athena-specific dependencies. The user should pass a /xAOD::CaloClusterContainer * and a const DataLink<CaloCellContainer> *. moments_to_add specifies which moments we will import. If sort_clusters is true, the clusters will be sorted based on the transverse energy, otherwise the same order will be kept. If save_uncalibrated, the basic cluster information will be saved as raw. If time_measurements is not null, separate time measurements for the six stages (initial transfer, cell link creation, cell assignment, sorting, basic info filling and moments filling) will be stored.

Definition at line 1269 of file DataHolders.cxx.

1278{
1279 using clock_type = boost::chrono::thread_clock;
1280 auto time_cast = [](const auto & before, const auto & after)
1281 {
1282 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
1283 };
1284
1285 xAOD::CaloClusterContainer * cluster_collection = static_cast<xAOD::CaloClusterContainer *>(p_cluster_collection);
1286 const DataLink<CaloCellContainer> & cell_collection_link = *(static_cast<const DataLink<CaloCellContainer> *>(p_cell_collection_link));
1287
1288 const auto start = clock_type::now();
1289
1290 m_clusters.allocate();
1291
1292 CaloRecGPU::CUDA_Helpers::GPU_to_CPU_async(static_cast<ClusterBaseInfo *>(m_clusters),
1293 static_cast<const ClusterBaseInfo *>(m_clusters_dev),
1294 sizeof(ClusterBaseInfo), stream);
1295
1297
1298 const auto after_first_transfer = clock_type::now();
1299
1301
1302 std::vector<std::unique_ptr<CaloClusterCellLink>> cell_links;
1303
1304 export_cluster_initialize_links(m_clusters, cell_links, cell_collection_link, true);
1305
1306 const auto after_link_creation = clock_type::now();
1307
1309
1311
1312 export_cluster_process_cells(m_clusters, m_cell_info, cell_links, extra_cells_to_fill);
1313
1314 const auto after_cell_processing = clock_type::now();
1315
1316 std::vector<int> cluster_order;
1317
1318 export_cluster_sort(m_clusters, cluster_order, sort_clusters);
1319
1320 const auto after_sorting = clock_type::now();
1321
1323
1325
1326 export_cluster_fill_cells_and_basic_info(m_clusters, cluster_collection, cell_links, cluster_order, save_uncalibrated);
1327
1328 const auto after_basic_info = clock_type::now();
1329
1331
1332 export_cluster_fill_moments(m_clusters, cluster_collection, cluster_order, moments_to_add, output_extra_moments);
1333
1334 const auto after_moments = clock_type::now();
1335
1336 if (time_measurements)
1337 {
1338 time_measurements[0] = time_cast(start, after_first_transfer);
1339 time_measurements[1] = time_cast(after_first_transfer, after_link_creation);
1340 time_measurements[2] = time_cast(after_link_creation, after_cell_processing);
1341 time_measurements[3] = time_cast(after_cell_processing, after_sorting);
1342 time_measurements[4] = time_cast(after_sorting, after_basic_info);
1343 time_measurements[5] = time_cast(after_basic_info, after_moments);
1344 }
1345}
static void cluster_transfer_helper_moments(ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, const MomentsOptionsArray &moments_to_add, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)
static void export_cluster_fill_moments(const ClusterInfoArr *clusters, xAOD::CaloClusterContainer *cluster_collection, std::vector< int > &cluster_order, const MomentsOptionsArray &moments_to_add, const bool output_extra_moments)
static void export_cluster_fill_cells_and_basic_info(const ClusterInfoArr *clusters, xAOD::CaloClusterContainer *cluster_collection, std::vector< std::unique_ptr< CaloClusterCellLink > > &cell_links, std::vector< int > &cluster_order, const bool save_uncalibrated)
static void export_cluster_sort(const ClusterInfoArr *clusters, std::vector< int > &cluster_order, const bool really_sort)
static void cluster_transfer_helper_cell_assignment(ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream, const int num_total_cells=NCaloCells)
static void export_cluster_process_cells(const ClusterInfoArr *clusters, const CellInfoArr *cells, std::vector< std::unique_ptr< CaloClusterCellLink > > &cell_links, const std::vector< int > &extra_cells_to_fill)
static void cluster_transfer_helper_basic_info(ReadStateFrom &state_holder, OutputClusters &output_clusters, InputClusters &input_clusters, CopyFunc copy_func, CaloRecGPU::CUDA_Helpers::CUDAStreamPtrHolder stream)
static void export_cluster_initialize_links(const ClusterInfoArr *clusters, std::vector< std::unique_ptr< CaloClusterCellLink > > &cell_links, const DataLink< CaloCellContainer > &cell_collection_link, const bool skip_validation)
size_type size() const noexcept
Returns the number of elements in the collection.
void GPU_synchronize(CUDAStreamPtrHolder stream={})
Synchronizes the stream.
void GPU_to_CPU_async(void *dest, const void *const source, const size_t num, CUDAStreamPtrHolder stream={})
Copies num bytes from source in GPU memory to dest in CPU memory, asynchronously.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.

Member Data Documentation

◆ m_cell_info

CaloRecGPU::Helpers::CUDA_pinned_CPU_object<CaloRecGPU::CellInfoArr> CaloRecGPU::EventDataHolder::m_cell_info

Definition at line 168 of file DataHolders.h.

◆ m_cell_info_dev

CaloRecGPU::Helpers::CUDA_object<CaloRecGPU::CellInfoArr> CaloRecGPU::EventDataHolder::m_cell_info_dev

Definition at line 178 of file DataHolders.h.

◆ m_clusters

Definition at line 169 of file DataHolders.h.

◆ m_clusters_dev

CaloRecGPU::Helpers::CUDA_object<CaloRecGPU::ClusterInfoArr> CaloRecGPU::EventDataHolder::m_clusters_dev

Definition at line 179 of file DataHolders.h.


The documentation for this class was generated from the following files: