Skip to content

Commit b4043cf

Browse files
authored
add a sync after flush cache when doing benchmark (#2503)
I'm doing some benchmarks in pytorch and I find this benchmark always record the time of flush cache kernel. I want to add a sync in each iteration before kernel start. Pytorch calls this function here: https://github.com/pytorch/pytorch/blob/main/torch/_inductor/runtime/benchmarking.py#L176
1 parent de5302d commit b4043cf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

python/triton/testing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def do_bench(fn, warmup=25, rep=100, grad_to_none=None, quantiles=None, return_m
204204
x.grad = None
205205
# we clear the L2 cache before each run
206206
cache.zero_()
207+
if USE_WALL_TIME:
208+
di.synchronize()
207209
# record time of `fn`
208210
start_event[i].record()
209211
fn()

0 commit comments

Comments
 (0)