1 parent
6a7e31b549
commit
0e45a22094
3 files changed
+11
-11
No files matched your search
@@ -176,21 +176,21 @@ def _benchmark(fn, warmup: int = 20, iters: int = 100) -> float:
|
||||
cache_flusher = torch.empty(int(256 * 1024 * 1024 / 4), dtype=torch.int32, device="cuda")
|
||||
for _ in range(warmup):
|
||||
fn()
|
||||
torch.cuda.synchronize()
|
||||
torch.accelerator.synchronize()
|
||||
|
||||
t_flush_start = time.perf_counter()
|
||||
for _ in range(iters):
|
||||
cache_flusher.zero_()
|
||||
torch.cuda.synchronize()
|
||||
torch.accelerator.synchronize()
|
||||
flush_time_total = time.perf_counter() - t_flush_start
|
||||
|
||||
# 3. Measure the total time of "flush cache + operator execution"
|
||||
torch.cuda.synchronize()
|
||||
torch.accelerator.synchronize()
|
||||
t_total_start = time.perf_counter()
|
||||
for _ in range(iters):
|
||||
cache_flusher.zero_()
|
||||
fn()
|
||||
torch.cuda.synchronize()
|
||||
torch.accelerator.synchronize()
|
||||
total_time = time.perf_counter() - t_total_start
|
||||
|
||||
# 4. Asynchronous subtraction separation
|
||||
|
||||
@@ -51,11 +51,11 @@ def _benchmark(fn, warmup: int = 20, iters: int = 200) -> float:
|
||||
"""Return mean latency in milliseconds."""
|
||||
for _ in range(warmup):
|
||||
fn()
|
||||
torch.cuda.synchronize()
|
||||
torch.accelerator.synchronize()
|
||||
t0 = time.perf_counter()
|
||||
for _ in range(iters):
|
||||
fn()
|
||||
torch.cuda.synchronize()
|
||||
torch.accelerator.synchronize()
|
||||
return (time.perf_counter() - t0) / iters * 1000.0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user