MCPcopy
hub / github.com/tinygrad/tinygrad / test_profile_multiops

Method test_profile_multiops

test/backend/test_profiler.py:79–97  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

77 assert len(kernel_runs) == 1, "one kernel run is expected"
78
79 def test_profile_multiops(self):
80 runner_name = TestProfiler.runtime.name
81 buf1 = Buffer(Device.DEFAULT, 2, dtypes.float, options=BufferSpec(nolru=True)).ensure_allocated()
82
83 with helper_collect_profile(TestProfiler.d0) as profile:
84 buf1.copyin(memoryview(bytearray(struct.pack("ff", 0, 1))))
85 gs, ls = TestProfiler.prg.arg.launch_dims({})
86 TestProfiler.runtime(buf1._buf, TestProfiler.a.uop.buffer._buf, global_size=gs, local_size=ls)
87 buf1.copyout(memoryview(bytearray(buf1.nbytes)))
88
89 evs = [x for x in profile if isinstance(x, ProfileRangeEvent) and x.device.startswith(TestProfiler.d0.device)]
90
91 assert len(evs) == 3, "3 kernel runs are expected"
92 # NOTE: order of events does not matter, the tool is responsible for sorting them
93 prg_events = [e for e in evs if e.device == TestProfiler.d0.device]
94 assert any(e.name == runner_name for e in prg_events), "kernel name is not correct"
95
96 #for i in range(1, 3):
97 # assert evs[i].st > evs[i-1].en, "timestamp not aranged"
98
99 def test_profile_multidev(self):
100 try: d1 = Device[f"{Device.DEFAULT}:1"]

Callers

nothing calls this directly

Calls 7

BufferClass · 0.90
BufferSpecClass · 0.90
helper_collect_profileFunction · 0.85
ensure_allocatedMethod · 0.80
copyinMethod · 0.80
launch_dimsMethod · 0.80
copyoutMethod · 0.80

Tested by

no test coverage detected