src
CUDADataFormats
Common
src
ProductBase.cc
Go to the documentation of this file.
1
#include "
CUDADataFormats/Common/interface/ProductBase.h
"
2
#include "
HeterogeneousCore/CUDAUtilities/interface/eventWorkHasCompleted.h
"
3
4
namespace
cms::cuda
{
5
bool
ProductBase::isAvailable
()
const
{
6
// if default-constructed, the product is not available
7
if
(not
event_
) {
8
return
false
;
9
}
10
return
eventWorkHasCompleted
(
event_
.get());
11
}
12
13
ProductBase::~ProductBase
() {
14
// Make sure that the production of the product in the GPU is
15
// complete before destructing the product. This is to make sure
16
// that the EDM stream does not move to the next event before all
17
// asynchronous processing of the current is complete.
18
19
// TODO: a callback notifying a WaitingTaskHolder (or similar)
20
// would avoid blocking the CPU, but would also require more work.
21
//
22
// Intentionally not checking the return value to avoid throwing
23
// exceptions. If this call would fail, we should get failures
24
// elsewhere as well.
25
if
(
event_
) {
26
cudaEventSynchronize(
event_
.get());
27
}
28
}
29
}
// namespace cms::cuda
cms::cuda
Definition:
PortableDeviceCollection.h:9
eventWorkHasCompleted.h
cms::cuda::ProductBase::~ProductBase
~ProductBase()
Definition:
ProductBase.cc:13
cms::cuda::ProductBase::isAvailable
bool isAvailable() const
Definition:
ProductBase.cc:5
cms::cuda::ProductBase::event_
SharedEventPtr event_
Definition:
ProductBase.h:80
ProductBase.h
cms::cuda::eventWorkHasCompleted
bool eventWorkHasCompleted(cudaEvent_t event)
Definition:
eventWorkHasCompleted.h:18
Generated for CMSSW Reference Manual by
1.8.14