Files
StarPilot/tinygrad_repo/extra/ring_copy.py
T
Vehicle Researcher 33d5cfc393 openpilot v0.10.3 release
date: 2025-12-18T23:23:16
master commit: 3cdee7b54718ee14bd85befd6c5bad3d699c5479
2025-12-18 23:23:21 -08:00

15 lines
472 B
Python

from tinygrad import Tensor, Device, GlobalCounters
from tinygrad.helpers import Timing
N = 512
GPUS = 5
ds = tuple([f"{Device.DEFAULT}:{i+1}" for i in range(GPUS)])
t = [Tensor.ones(N, N, N, device=d).contiguous().realize() for d in ds]
for _ in range(10):
GlobalCounters.reset()
with Timing():
for ti in t:
ti.to_(ds[(ds.index(ti.device)+1+len(ds))%len(ds)])
# ti.to_(ds[(ds.index(ti.device)-1+len(ds))%len(ds)]) # reversed order
ti.realize()