MojoLlama
Archived Mojo/MAX quantizer and serving research repository (read-only history)
Brought by drakestapleton
MojoLlama / src / mojollama / mojo_engine / test_perf.mojo
| 1 | # test_perf.mojo — Test @extern for performance helpers |
| 2 | # Tests if custom .so functions resolve via LD_PRELOAD |
| 3 | |
| 4 | @extern("_ml_memalign") |
| 5 | def _ml_alloc(sz: Int, align: Int) abi("C") -> Int: ... |
| 6 | |
| 7 | @extern("_ml_free") |
| 8 | def _ml_dealloc(p: Int) abi("C") -> None: ... |
| 9 | |
| 10 | @extern("_ml_prefetch_L1") |
| 11 | def _ml_pf_L1(addr: Int) abi("C") -> None: ... |
| 12 | |
| 13 | @extern("_ml_pin_process") |
| 14 | def _ml_pin_proc() abi("C") -> None: ... |
| 15 | |
| 16 | def main(): |
| 17 | print("Testing perf helper @extern...") |
| 18 | var p = _ml_alloc(1024, 64) |
| 19 | print(" _ml_alloc: address =", p) |
| 20 | _ml_pf_L1(p) |
| 21 | print(" _ml_prefetch_L1: OK") |
| 22 | _ml_pin_proc() |
| 23 | print(" _ml_pin_process: OK") |
| 24 | _ml_dealloc(p) |
| 25 | print(" All @extern resolved OK!") |