ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthHIP
AthHIPComps
src
AthHIP/AthHIPComps/src/Stream.cxx
Go to the documentation of this file.
1
//
2
// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
//
4
5
// Local include(s).
6
#include "
Stream.h
"
7
8
// Framework include(s).
9
#include "
CxxUtils/checker_macros.h
"
10
11
// System include(s).
12
#include <format>
13
#include <stdexcept>
14
16
#define HIP_ERROR_CHECK(EXP) \
17
do { \
18
hipError_t errorCode = EXP; \
19
if (errorCode != hipSuccess) { \
20
throw std::runtime_error(std::format("{}:{} Failed to execute: {} ({})", \
21
__FILE__, __LINE__, #EXP, \
22
hipGetErrorString(errorCode))); \
23
} \
24
} while (false)
25
26
namespace
AthHIP::Details
{
27
28
Stream::Stream
() {
29
HIP_ERROR_CHECK
(hipStreamCreate(&
m_stream
));
30
}
31
34
Stream::~Stream
() {
35
[[maybe_unused]] hipError_t
error
= hipStreamDestroy(
m_stream
);
36
}
37
38
hipStream_t
Stream::stream
()
const
{
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
}
47
48
std::string
Stream::name
()
const
{
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
}
60
61
}
// namespace AthHIP::Details
HIP_ERROR_CHECK
#define HIP_ERROR_CHECK(EXP)
Helper macro used for checking hipError_t type return values.
Definition
AthHIP/AthHIPComps/src/Stream.cxx:16
Stream.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
AthHIP::Details::Stream::m_stream
hipStream_t m_stream
The HIP stream to use for asynchronous copies.
Definition
AthHIP/AthHIPComps/src/Stream.h:32
AthHIP::Details::Stream::name
std::string name() const
Get the name of the device associated with the stream.
Definition
AthHIP/AthHIPComps/src/Stream.cxx:48
AthHIP::Details::Stream::stream
hipStream_t stream() const
Get the HIP stream.
Definition
AthHIP/AthHIPComps/src/Stream.cxx:38
AthHIP::Details::Stream::~Stream
~Stream()
Destructor, destroying the HIP stream.
Definition
AthHIP/AthHIPComps/src/Stream.cxx:34
AthHIP::Details::Stream::Stream
Stream()
Constructor, creating the HIP stream.
Definition
AthHIP/AthHIPComps/src/Stream.cxx:28
AthHIP::Details
Definition
AthHIP/AthHIPComps/src/Stream.cxx:26
error
Definition
IImpactPoint3dEstimator.h:72
Generated on
for ATLAS Offline Software by
1.17.0