forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProductBase.cc
29 lines (26 loc) · 1004 Bytes
/
ProductBase.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "CUDACore/ProductBase.h"
#include "CUDACore/eventWorkHasCompleted.h"
namespace cms::cuda {
bool ProductBase::isAvailable() const {
// if default-constructed, the product is not available
if (not event_) {
return false;
}
return eventWorkHasCompleted(event_.get());
}
ProductBase::~ProductBase() {
// Make sure that the production of the product in the GPU is
// complete before destructing the product. This is to make sure
// that the EDM stream does not move to the next event before all
// asynchronous processing of the current is complete.
// TODO: a callback notifying a WaitingTaskHolder (or similar)
// would avoid blocking the CPU, but would also require more work.
//
// Intentionally not checking the return value to avoid throwing
// exceptions. If this call would fail, we should get failures
// elsewhere as well.
if (event_) {
cudaEventSynchronize(event_.get());
}
}
} // namespace cms::cuda