ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthCUDA
AthCUDAServices
src
StreamPoolSvc.cxx
Go to the documentation of this file.
1
//
2
// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
//
4
5
// Local include(s).
6
#include "
StreamPoolSvc.h
"
7
8
// Project include(s).
9
#include "
AthCUDACore/Info.h
"
10
11
// System include(s).
12
#include <cassert>
13
14
namespace
AthCUDA
{
15
16
StatusCode
StreamPoolSvc::initialize
() {
17
18
// If there are no CUDA capable devices available, then don't try to
19
// set up any streams.
20
if
(
Info::instance
().nDevices() == 0 ) {
21
ATH_MSG_INFO
(
"CUDA device(s) not available. Not setting up "
22
"streams."
);
23
return
StatusCode::SUCCESS;
24
}
25
26
// Create the implementation object.
27
m_impl
=
28
std::make_unique< StreamPoolSvcImpl >(
m_nStreams
.value(), *
this
);
29
30
// Tell the user what happened.
31
ATH_MSG_INFO
(
"Allocated "
<<
m_nStreams
.value() <<
" stream(s)"
);
32
33
// Return gracefully.
34
return
StatusCode::SUCCESS;
35
}
36
37
StatusCode
StreamPoolSvc::finalize
() {
38
39
// Destroy the implementation object.
40
m_impl
.reset();
41
42
// Tell the user what happened.
43
ATH_MSG_INFO
(
"Destroyed all streams"
);
44
45
// Return gracefully.
46
return
StatusCode::SUCCESS;
47
}
48
49
bool
StreamPoolSvc::isEmpty
()
const
{
50
51
return
(
m_nStreams
.value() == 0 );
52
}
53
54
StreamHolder
StreamPoolSvc::getAvailableStream
() {
55
56
// If we don't have streams available, return right away.
57
if
(
m_nStreams
.value() == 0 ) {
58
return
StreamHolder
();
59
}
60
61
// A security check.
62
assert(
m_impl
);
63
64
// Get the next available stream for the user.
65
return
m_impl
->getAvailableStream();
66
}
67
68
void
StreamPoolSvc::yieldStream
(
StreamHolder
& stream ) {
69
70
// A security check.
71
assert(
m_impl
);
72
73
// Put the stream back into our queue.
74
m_impl
->yieldStream( stream );
75
return
;
76
}
77
78
}
// namespace AthCUDA
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
Info.h
StreamPoolSvc.h
AthCUDA::Info::instance
static const Info & instance()
Singleton accessor function.
AthCUDA::StreamHolder
Helper class for handling CUDA streams.
Definition
StreamHolder.h:24
AthCUDA::StreamPoolSvc::initialize
virtual StatusCode initialize() override
Initialise the service.
Definition
StreamPoolSvc.cxx:16
AthCUDA::StreamPoolSvc::getAvailableStream
virtual StreamHolder getAvailableStream() override
Get a stream from the pool.
Definition
StreamPoolSvc.cxx:54
AthCUDA::StreamPoolSvc::yieldStream
virtual void yieldStream(StreamHolder &stream) override
Put a given stream back into the pool.
Definition
StreamPoolSvc.cxx:68
AthCUDA::StreamPoolSvc::isEmpty
virtual bool isEmpty() const override
Check whether any streams are available for the job.
Definition
StreamPoolSvc.cxx:49
AthCUDA::StreamPoolSvc::m_nStreams
Gaudi::Property< unsigned int > m_nStreams
The number of streams to use.
Definition
StreamPoolSvc.h:86
AthCUDA::StreamPoolSvc::finalize
virtual StatusCode finalize() override
Finalise the service.
Definition
StreamPoolSvc.cxx:37
AthCUDA::StreamPoolSvc::m_impl
std::unique_ptr< StreamPoolSvcImpl > m_impl
The object implementing the interaction with CUDA.
Definition
StreamPoolSvc.h:95
AthCUDA
Definition
Info.h:14
Generated on
for ATLAS Offline Software by
1.17.0