forked from tinygrad/tinygrad
* start gpu * progress * fixes * read correct * libusb * libusb works * support asm24 * hmm * one access file * fix extra * start AMBar * works on am * back to usb * patch fw * full fast write into a bar * ugh, minus one gpus, next please * mute libusb for now * usb for asm24 * 63 * hmm * ops * rescan * and gpu shoudl be there * enumerate them? * usbgpu bus 4, 100% reliable (draft) * lil * works * comments * add DEBUG * cleaner * simplest * Revert "simplest" This reverts commit1d00354c16. * Revert "cleaner" This reverts commitc5662de956. * assert we find gpu * that's simpler * this back * simpler? * correcT * work * nonsense * works with more checks * this works * the 6s in the right place * reliable now * fix after reboot * set config * 1s timeouts * close to fw loading * streams * usbhub works * endpoints * fix * want to test tiny10 * move to tiny 10 * fix gpu * ugly speed * smth * mostly broken, but signals and dmas * do not reset gpu every time * changes to run kernels * ugh, not working * t10 * pg and sc files * some prog * um? * somehow it works * patched for 24 * some tries * minimal * moving * back to working * so sloooooow * move to controller * usb.py rewrite * rework * cleaner 1 * cleaner 2 * cleaner 3 * new abstractions * aft merge * init controller * cleaner 4 * cleaner 5 * patcher + tiny changes * ignore that * cleaner 6 * after rebase * cleaner 7 * bring it back * start linter war * linter 2 * autogen was missing * fix autogen * typing * better? * mypy * extra/legacy rename and cleaner * shuffle * better printing * tiny changes and tests --------- Co-authored-by: George Hotz <[email protected]>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import unittest, time
|
|
from tinygrad.runtime.support.usb import ASM24Controller
|
|
|
|
class TestASMController(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.ctrl = ASM24Controller()
|
|
|
|
def test_write_and_read(self):
|
|
base = 0xF000
|
|
data = b"hello!"
|
|
self.ctrl.write(base, data)
|
|
out = self.ctrl.read(base, len(data))
|
|
self.assertEqual(out, data)
|
|
|
|
def test_scsi_write_and_read_from_f000(self):
|
|
payload = bytes([0x5B]) * 4096
|
|
self.ctrl.scsi_write(payload, lba=0)
|
|
back = self.ctrl.read(0xF000, len(payload))
|
|
self.assertEqual(back, payload)
|
|
|
|
def test_scsi_write_speed_4k(self):
|
|
payload = bytes([0x5A]) * 4096
|
|
start = time.perf_counter()
|
|
self.ctrl.scsi_write(payload, lba=0)
|
|
dur_ms = (time.perf_counter() - start) * 1000
|
|
print(f"scsi_write 4K took {dur_ms:.3f} ms")
|
|
|
|
def test_read_speed_4k(self):
|
|
payload = bytes([0xA5]) * 4096
|
|
self.ctrl.write(0xF000, payload)
|
|
start = time.perf_counter()
|
|
out = self.ctrl.read(0xF000, 4096)
|
|
dur_ms = (time.perf_counter() - start) * 1000
|
|
print(f"read 4K took {dur_ms:.3f} ms")
|
|
self.assertEqual(out, payload)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() |