From: Andrey Alekseenko Date: Tue, 12 Oct 2021 12:55:37 +0000 (+0200) Subject: Stop timers in GpuForceReduction with no atoms X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=7992d01cd70bc6895b131238bfff646c672d94e8;p=alexxy%2Fgromacs.git Stop timers in GpuForceReduction with no atoms The early return, as implemented earlier, was happening after starting the timers. Now we properly stop them. The large "if" was used here instead of just moving the "return" up in order to accomodate future manual event handling (see Issue #3988 and MR !2015). Thanks to Artem Zhmurov for noticing the problem. --- diff --git a/src/gromacs/mdlib/gpuforcereduction_impl.cpp b/src/gromacs/mdlib/gpuforcereduction_impl.cpp index fb9ab131bd..2a3e48c4ad 100644 --- a/src/gromacs/mdlib/gpuforcereduction_impl.cpp +++ b/src/gromacs/mdlib/gpuforcereduction_impl.cpp @@ -118,35 +118,33 @@ void GpuForceReduction::Impl::execute() wallcycle_start_nocount(wcycle_, WallCycleCounter::LaunchGpu); wallcycle_sub_start(wcycle_, WallCycleSubCounter::LaunchGpuNBFBufOps); - if (numAtoms_ == 0) + if (numAtoms_ != 0) { - return; - } - - GMX_ASSERT(nbnxmForceToAdd_, "Nbnxm force for reduction has no data"); - - // Enqueue wait on all dependencies passed - for (auto* synchronizer : dependencyList_) - { - synchronizer->enqueueWaitEvent(deviceStream_); - } - - const bool addRvecForce = static_cast(rvecForceToAdd_); // True iff initialized - - launchForceReductionKernel(numAtoms_, - atomStart_, - addRvecForce, - accumulate_, - nbnxmForceToAdd_, - rvecForceToAdd_, - baseForce_, - cellInfo_.d_cell, - deviceStream_); - - // Mark that kernel has been launched - if (completionMarker_ != nullptr) - { - completionMarker_->markEvent(deviceStream_); + GMX_ASSERT(nbnxmForceToAdd_, "Nbnxm force for reduction has no data"); + + // Enqueue wait on all dependencies passed + for (auto* synchronizer : dependencyList_) + { + synchronizer->enqueueWaitEvent(deviceStream_); + } + + const bool addRvecForce = static_cast(rvecForceToAdd_); // True iff initialized + + launchForceReductionKernel(numAtoms_, + atomStart_, + addRvecForce, + accumulate_, + nbnxmForceToAdd_, + rvecForceToAdd_, + baseForce_, + cellInfo_.d_cell, + deviceStream_); + + // Mark that kernel has been launched + if (completionMarker_ != nullptr) + { + completionMarker_->markEvent(deviceStream_); + } } wallcycle_sub_stop(wcycle_, WallCycleSubCounter::LaunchGpuNBFBufOps);