- threadedInteractions_[thread], x, threadedForceBuffers_[thread].get(), NoPbc{});
+ threadedInteractions_[thread], x, threadBuffer, shiftForceBuffer, NoPbc{});
+ }
+ }
+
+ // reduce shift forces
+ // This is a potential candidate for OMP parallelization, but attention should be paid to the
+ // relative costs of thread synchronization overhead vs reduction cost in contexts where the
+ // number of threads could be large vs where number of threads could be small
+ if constexpr (haveShiftForces)
+ {
+ for (int i = 0; i < gmx::c_numShiftVectors; ++i)
+ {
+ Vec3 threadSum{ 0, 0, 0 };
+ for (int thread = 0; thread < numThreads; ++thread)
+ {
+ threadSum += (threadedShiftForceBuffers_[thread])[i];
+ }
+ shiftForces[i] += threadSum;