Skip to content

Commit

Permalink
Call alpaka::wait() in EDMetadata destructor only when its Queue has …
Browse files Browse the repository at this point in the history
…not been reused by a consuming module

If the consuming module does not produce any device-side products, the
EDMetadata destructor should result in blocking alpaka::wait() call.
  • Loading branch information
makortel committed Apr 24, 2024
1 parent d18a254 commit c237b97
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion HeterogeneousCore/AlpakaCore/src/alpaka/EDMetadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// TODO: a callback notifying a WaitingTaskHolder (or similar)
// would avoid blocking the CPU, but would also require more work.

if (event_ and not eventComplete_) {
// If event_ is null, the EDMetadata was either
// default-constructed, or fully synchronized before leaving the
// produce() call, so no synchronization is needed.
// If the queue was re-used, then some other EDMetadata object in
// the same edm::Event records the event_ (in the same queue) and
// calls alpaka::wait(), and therefore this wait() call can be
// skipped).
if (event_ and not eventComplete_ and mayReuseQueue_) {
// Must not throw in a destructor, and if there were an
// exception could not really propagate it anyway.
CMS_SA_ALLOW try { alpaka::wait(*event_); } catch (...) {
Expand Down

0 comments on commit c237b97

Please sign in to comment.