Skip to content

Commit fd62012

Browse files
Removing costly atomics when hipEvent timing is used
1 parent 137f03d commit fd62012

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/client/Presets/HbmBandwidth.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void HbmReadBwKernel(const void* __restrict pSrcBuffer,
105105

106106
// Update min/max start times
107107
__syncthreads();
108-
if (threadIdx.x == 0) {
108+
if (threadIdx.x == 0 && minStartCycle != NULL) {
109109
int64_t stopTime = GetTimestamp();
110110
atomicMin(minStartCycle, startTime);
111111
atomicMax(maxStopCycle, stopTime);
@@ -473,13 +473,15 @@ int HbmBandwidthPreset(EnvVars& ev,
473473
if (!useWallClock) {
474474
HIP_CALL(hipEventRecord(startEvent, stream));
475475
}
476-
kernel<<<gridDim, blockDim, 0, stream>>>(inputBuffers[currBufferIdx++], NULL, numSteps, minStartCycle, maxStopCycle);
476+
kernel<<<gridDim, blockDim, 0, stream>>>(inputBuffers[currBufferIdx++], NULL, numSteps,
477+
useWallClock ? minStartCycle : NULL, maxStopCycle);
477478
if (!useWallClock) {
478479
HIP_CALL(hipEventRecord(stopEvent, stream));
479480
}
480481
#else
481482
hipExtLaunchKernelGGL(kernel, gridDim, blockDim, 0, stream, useWallClock ? NULL : startEvent, useWallClock ? NULL : stopEvent, 0,
482-
inputBuffers[currBufferIdx], nullptr , numSteps, minStartCycle, maxStopCycle);
483+
inputBuffers[currBufferIdx], nullptr , numSteps,
484+
useWallClock ? minStartCycle : NULL, maxStopCycle);
483485
#endif
484486
HIP_CALL(hipStreamSynchronize(stream));
485487
if (currBufferIdx == numBuffers) currBufferIdx = 0;

0 commit comments

Comments
 (0)