ATLAS Offline Software
Loading...
Searching...
No Matches
AthCUDA::PerEventStreamSvc Class Reference

Service providing CUDA streams to (reentrant) algorithms. More...

#include <PerEventStreamSvc.h>

Inheritance diagram for AthCUDA::PerEventStreamSvc:
Collaboration diagram for AthCUDA::PerEventStreamSvc:

Public Member Functions

Function(s) inherited from @c AthAlgTool
virtual StatusCode initialize () override
 Initialize the tool.
Function(s) inherited from @c IStreamSvc
virtual cudaStream_t stream (const EventContext &ctx) const override
 Get the CUDA stream to use.

Private Attributes

std::unique_ptr< const SG::SlotSpecificObj< Details::Stream, SG::InvalidSlot::Enabled > > m_streams
 Slot specific CUDA stream(s).

Detailed Description

Service providing CUDA streams to (reentrant) algorithms.

In a very simple way. By having one CUDA stream per concurrent event (slot), and having algorithms all use a single CUDA stream for a given event.

Definition at line 27 of file PerEventStreamSvc.h.

Member Function Documentation

◆ initialize()

StatusCode AthCUDA::PerEventStreamSvc::initialize ( )
overridevirtual

Initialize the tool.

Definition at line 14 of file PerEventStreamSvc.cxx.

14 {
15
16 // Create the streams object.
17 m_streams = std::make_unique<
18 const SG::SlotSpecificObj<Details::Stream, SG::InvalidSlot::Enabled>>();
19
20 // Tell the user what happened.
21 ATH_MSG_INFO("Initialized "
22 << std::distance(m_streams->begin(), m_streams->end())
23 << " CUDA stream(s):");
24 for (const auto& stream : *m_streams) {
25 ATH_MSG_INFO(" - " << stream.name());
26 }
27
28 // Return gracefully.
29 return StatusCode::SUCCESS;
30}
#define ATH_MSG_INFO(x)
std::unique_ptr< const SG::SlotSpecificObj< Details::Stream, SG::InvalidSlot::Enabled > > m_streams
Slot specific CUDA stream(s).
virtual cudaStream_t stream(const EventContext &ctx) const override
Get the CUDA stream to use.

◆ stream()

cudaStream_t AthCUDA::PerEventStreamSvc::stream ( const EventContext & ctx) const
overridevirtual

Get the CUDA stream to use.

Parameters
ctxThe event context for which the stream is requested
Returns
The CUDA stream to use for the current event context

Definition at line 32 of file PerEventStreamSvc.cxx.

32 {
33
34 // Get the stream corresponding to the current slot.
35 assert(m_streams);
36 return m_streams->get(ctx)->stream();
37}

Member Data Documentation

◆ m_streams

std::unique_ptr< const SG::SlotSpecificObj<Details::Stream, SG::InvalidSlot::Enabled> > AthCUDA::PerEventStreamSvc::m_streams
private

Slot specific CUDA stream(s).

Definition at line 57 of file PerEventStreamSvc.h.


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