MCPcopy Create free account
hub / github.com/MeshInfra/WaferLLM / decode_timing

Function decode_timing

MeshGEMV/host_common.py:39–80  ·  view source on GitHub ↗

Decode the on-chip TSC timestamps into (mean_cycle, max_cycle).

(time_memcpy_hwl, time_ref_hwl, P, total_repeat_times)

Source from the content-addressed store, hash-verified

37
38
39def decode_timing(time_memcpy_hwl, time_ref_hwl, P, total_repeat_times):
40 """Decode the on-chip TSC timestamps into (mean_cycle, max_cycle)."""
41 time_start = np.zeros((P, P)).astype(int)
42 time_end = np.zeros((P, P)).astype(int)
43 word = np.zeros(3).astype(np.uint16)
44 for w in range(P):
45 for h in range(P):
46 hex_t0 = int(float_to_hex(time_memcpy_hwl[(h, w, 0)]), base=16)
47 hex_t1 = int(float_to_hex(time_memcpy_hwl[(h, w, 1)]), base=16)
48 hex_t2 = int(float_to_hex(time_memcpy_hwl[(h, w, 2)]), base=16)
49 word[0] = hex_t0 & 0x0000ffff
50 word[1] = (hex_t0 >> 16) & 0x0000ffff
51 word[2] = hex_t1 & 0x0000ffff
52 time_start[(h, w)] = make_u48(word)
53 word[0] = (hex_t1 >> 16) & 0x0000ffff
54 word[1] = hex_t2 & 0x0000ffff
55 word[2] = (hex_t2 >> 16) & 0x0000ffff
56 time_end[(h, w)] = make_u48(word)
57
58 time_ref = np.zeros((P, P)).astype(int)
59 word = np.zeros(3).astype(np.uint16)
60 for w in range(P):
61 for h in range(P):
62 hex_t0 = int(float_to_hex(time_ref_hwl[(h, w, 0)]), base=16)
63 hex_t1 = int(float_to_hex(time_ref_hwl[(h, w, 1)]), base=16)
64 word[0] = hex_t0 & 0x0000ffff
65 word[1] = (hex_t0 >> 16) & 0x0000ffff
66 word[2] = hex_t1 & 0x0000ffff
67 time_ref[(h, w)] = make_u48(word)
68
69 for py in range(P):
70 for px in range(P):
71 time_ref[(py, px)] = time_ref[(py, px)] - (px + py)
72
73 time_start = time_start - time_ref
74 time_end = time_end - time_ref
75
76 min_time_start = time_start.min()
77 max_time_end = time_end.max()
78 mean_cycle = np.mean(time_end - time_start) / total_repeat_times
79 max_cycle = (max_time_end - min_time_start) / total_repeat_times
80 return mean_cycle, max_cycle

Callers

nothing calls this directly

Calls 2

float_to_hexFunction · 0.70
make_u48Function · 0.70

Tested by

no test coverage detected