Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:45

0001 #include "CUDADataFormats/Common/interface/ProductBase.h"
0002 #include "HeterogeneousCore/CUDAUtilities/interface/eventWorkHasCompleted.h"
0003 
0004 namespace cms::cuda {
0005   bool ProductBase::isAvailable() const {
0006     // if default-constructed, the product is not available
0007     if (not event_) {
0008       return false;
0009     }
0010     return eventWorkHasCompleted(event_.get());
0011   }
0012 
0013   ProductBase::~ProductBase() {
0014     // Make sure that the production of the product in the GPU is
0015     // complete before destructing the product. This is to make sure
0016     // that the EDM stream does not move to the next event before all
0017     // asynchronous processing of the current is complete.
0018 
0019     // TODO: a callback notifying a WaitingTaskHolder (or similar)
0020     // would avoid blocking the CPU, but would also require more work.
0021     //
0022     // Intentionally not checking the return value to avoid throwing
0023     // exceptions. If this call would fail, we should get failures
0024     // elsewhere as well.
0025     if (event_) {
0026       cudaEventSynchronize(event_.get());
0027     }
0028   }
0029 }  // namespace cms::cuda