ATLAS Offline Software
Loading...
Searching...
No Matches
AthHIP::Details::Stream Class Reference

Helper class for managing a HIP stream in memory. More...

#include <Stream.h>

Collaboration diagram for AthHIP::Details::Stream:

Public Member Functions

 Stream ()
 Constructor, creating the HIP stream.
 ~Stream ()
 Destructor, destroying the HIP stream.
hipStream_t stream () const
 Get the HIP stream.
std::string name () const
 Get the name of the device associated with the stream.

Private Attributes

hipStream_t m_stream {nullptr}
 The HIP stream to use for asynchronous copies.

Detailed Description

Helper class for managing a HIP stream in memory.

Definition at line 16 of file AthHIP/AthHIPComps/src/Stream.h.

Constructor & Destructor Documentation

◆ Stream()

AthHIP::Details::Stream::Stream ( )

Constructor, creating the HIP stream.

Definition at line 28 of file AthHIP/AthHIPComps/src/Stream.cxx.

28 {
29 HIP_ERROR_CHECK(hipStreamCreate(&m_stream));
30}
#define HIP_ERROR_CHECK(EXP)
Helper macro used for checking hipError_t type return values.
hipStream_t m_stream
The HIP stream to use for asynchronous copies.

◆ ~Stream()

AthHIP::Details::Stream::~Stream ( )

Destructor, destroying the HIP stream.

Let's not check for errors here.

Since that would introduce a struct that may throw in its destructor. Which we don't want.

Definition at line 34 of file AthHIP/AthHIPComps/src/Stream.cxx.

34 {
35 [[maybe_unused]] hipError_t error = hipStreamDestroy(m_stream);
36}

Member Function Documentation

◆ name()

std::string AthHIP::Details::Stream::name ( ) const

Get the name of the device associated with the stream.

Definition at line 48 of file AthHIP/AthHIPComps/src/Stream.cxx.

48 {
49
50 // Get the device's properties.
51 int device = -1;
52 HIP_ERROR_CHECK(hipStreamGetDevice(stream(), &device));
53 hipDeviceProp_t props;
54 HIP_ERROR_CHECK(hipGetDeviceProperties(&props, device));
55
56 // Construct a unique name out of those properties.
57 return std::format("{} [id: {}, bus: {}, device: {}]", props.name, device,
58 props.pciBusID, props.pciDeviceID);
59}
hipStream_t stream() const
Get the HIP stream.

◆ stream()

hipStream_t AthHIP::Details::Stream::stream ( ) const

Get the HIP stream.

Definition at line 38 of file AthHIP/AthHIPComps/src/Stream.cxx.

38 {
39
40 // The HIP runtime promises thread safety for handling streams in parallel
41 // from different CPU threads. Returning a non-const pointer of course allows
42 // us to cause harm. But as long as user code is not trying to actively break
43 // things, we should be fine.
44 hipStream_t result ATLAS_THREAD_SAFE = m_stream;
45 return result;
46}
#define ATLAS_THREAD_SAFE

Member Data Documentation

◆ m_stream

hipStream_t AthHIP::Details::Stream::m_stream {nullptr}
private

The HIP stream to use for asynchronous copies.

Definition at line 32 of file AthHIP/AthHIPComps/src/Stream.h.

32{nullptr};

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