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 1340 of file DataHolders.cxx.

1341{
1342 m_cell_info.allocate();
1343 m_clusters.allocate();
1344
1345 if (also_GPU)
1346 {
1347 m_cell_info_dev.allocate();
1348 m_clusters_dev.allocate();
1349 }
1350}
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 1352 of file DataHolders.cxx.

1353{
1354 m_cell_info_dev.clear();
1355 m_clusters_dev.clear();
1356}

◆ 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 1262 of file DataHolders.cxx.

1271{
1272 using clock_type = boost::chrono::thread_clock;
1273 auto time_cast = [](const auto & before, const auto & after)
1274 {
1275 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
1276 };
1277
1278 xAOD::CaloClusterContainer * cluster_collection = static_cast<xAOD::CaloClusterContainer *>(p_cluster_collection);
1279 const DataLink<CaloCellContainer> & cell_collection_link = *(static_cast<const DataLink<CaloCellContainer> *>(p_cell_collection_link));
1280
1281 const auto start = clock_type::now();
1282
1283 m_clusters.allocate();
1284
1285 CaloRecGPU::CUDA_Helpers::GPU_to_CPU_async(static_cast<ClusterBaseInfo *>(m_clusters),
1286 static_cast<const ClusterBaseInfo *>(m_clusters_dev),
1287 sizeof(ClusterBaseInfo), stream);
1288
1290
1291 const auto after_first_transfer = clock_type::now();
1292
1294
1295 std::vector<std::unique_ptr<CaloClusterCellLink>> cell_links;
1296
1297 export_cluster_initialize_links(m_clusters, cell_links, cell_collection_link, true);
1298
1299 const auto after_link_creation = clock_type::now();
1300
1302
1304
1305 export_cluster_process_cells(m_clusters, m_cell_info, cell_links, extra_cells_to_fill);
1306
1307 const auto after_cell_processing = clock_type::now();
1308
1309 std::vector<int> cluster_order;
1310
1311 export_cluster_sort(m_clusters, cluster_order, sort_clusters);
1312
1313 const auto after_sorting = clock_type::now();
1314
1316
1318
1319 export_cluster_fill_cells_and_basic_info(m_clusters, cluster_collection, cell_links, cluster_order, save_uncalibrated);
1320
1321 const auto after_basic_info = clock_type::now();
1322
1324
1325 export_cluster_fill_moments(m_clusters, cluster_collection, cluster_order, moments_to_add, output_extra_moments);
1326
1327 const auto after_moments = clock_type::now();
1328
1329 if (time_measurements)
1330 {
1331 time_measurements[0] = time_cast(start, after_first_transfer);
1332 time_measurements[1] = time_cast(after_first_transfer, after_link_creation);
1333 time_measurements[2] = time_cast(after_link_creation, after_cell_processing);
1334 time_measurements[3] = time_cast(after_cell_processing, after_sorting);
1335 time_measurements[4] = time_cast(after_sorting, after_basic_info);
1336 time_measurements[5] = time_cast(after_basic_info, after_moments);
1337 }
1338}
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: