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

Helper class for handling CUDA streams. More...

#include <StreamHolder.h>

Collaboration diagram for AthCUDA::StreamHolder:

Public Member Functions

 StreamHolder ()
 Friend declaration(s).
 StreamHolder (void *stream, IStreamPoolSvc *pool)
 Constructor with the stream and the pool service.
 StreamHolder (const StreamHolder &)=delete
 Copy constructor.
 StreamHolder (StreamHolder &&parent)
 Move constructor.
 ~StreamHolder ()
 Destructor.
StreamHolderoperator= (const StreamHolder &)=delete
 Copy assignment operator.
StreamHolderoperator= (StreamHolder &&rhs)
 Move assignment operator.
 operator bool () const
 Convenience operator for checking if the holder has a valid object.

Private Attributes

void * m_stream
 The managed stream.
IStreamPoolSvcm_pool
 The pool that this holder is attached to.

Detailed Description

Helper class for handling CUDA streams.

This class is used to:

  • be able to handle CUDA streams using pure C++ code;
  • manage the ownership of CUDA streams during the job.

Note that objects of this type can only be moved, they can not be copied.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 24 of file StreamHolder.h.

Constructor & Destructor Documentation

◆ StreamHolder() [1/4]

AthCUDA::StreamHolder::StreamHolder ( )

Friend declaration(s).

Default constructor

Definition at line 11 of file StreamHolder.cxx.

12 : m_stream( nullptr ), m_pool( nullptr ) {
13
14 }
IStreamPoolSvc * m_pool
The pool that this holder is attached to.
void * m_stream
The managed stream.

◆ StreamHolder() [2/4]

AthCUDA::StreamHolder::StreamHolder ( void * stream,
IStreamPoolSvc * pool )

Constructor with the stream and the pool service.

Definition at line 16 of file StreamHolder.cxx.

17 : m_stream( stream ), m_pool( pool ) {
18
19 }

◆ StreamHolder() [3/4]

AthCUDA::StreamHolder::StreamHolder ( const StreamHolder & )
delete

Copy constructor.

◆ StreamHolder() [4/4]

AthCUDA::StreamHolder::StreamHolder ( StreamHolder && parent)

Move constructor.

Definition at line 21 of file StreamHolder.cxx.

22 : m_stream( parent.m_stream ), m_pool( parent.m_pool ) {
23
24 parent.m_stream = nullptr;
25 parent.m_pool = nullptr;
26 }

◆ ~StreamHolder()

AthCUDA::StreamHolder::~StreamHolder ( )

Destructor.

Definition at line 28 of file StreamHolder.cxx.

28 {
29
30 if( ( m_stream != nullptr ) && ( m_pool != nullptr ) ) {
31 m_pool->yieldStream( *this );
32 }
33 }

Member Function Documentation

◆ operator bool()

AthCUDA::StreamHolder::operator bool ( ) const

Convenience operator for checking if the holder has a valid object.

Definition at line 50 of file StreamHolder.cxx.

50 {
51
52 return ( m_stream != nullptr );
53 }

◆ operator=() [1/2]

StreamHolder & AthCUDA::StreamHolder::operator= ( const StreamHolder & )
delete

Copy assignment operator.

◆ operator=() [2/2]

StreamHolder & AthCUDA::StreamHolder::operator= ( StreamHolder && rhs)

Move assignment operator.

Definition at line 35 of file StreamHolder.cxx.

35 {
36
37 // Check if anything needs to be done.
38 if( this == &rhs ) {
39 return *this;
40 }
41
42 // Perform the move.
43 m_stream = rhs.m_stream;
44 rhs.m_stream = nullptr;
45 m_pool = rhs.m_pool;
46 rhs.m_pool = nullptr;
47 return *this;
48 }

Member Data Documentation

◆ m_pool

IStreamPoolSvc* AthCUDA::StreamHolder::m_pool
private

The pool that this holder is attached to.

Definition at line 55 of file StreamHolder.h.

◆ m_stream

void* AthCUDA::StreamHolder::m_stream
private

The managed stream.

Definition at line 53 of file StreamHolder.h.


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