Created
January 31, 2018 03:07
-
-
Save Terminus-IMRC/66247f79a9e841a7b160c958fcdac395 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
from videocore.assembler import qpu, assemble | |
from videocore.driver import Driver | |
@qpu | |
def bench(asm, n): | |
ldi(r0, int(n//4), set_flags=True) | |
L.loop | |
if 1: | |
jzc(L.loop) | |
iadd(r0, r0, -1, set_flags=True) | |
nop() | |
nop() | |
exit(interrupt=True) | |
def main(): | |
n = 400e6 / 4 | |
with Driver() as drv: | |
code = drv.program(bench, n) | |
start = time.clock_gettime(time.CLOCK_MONOTONIC) | |
drv.execute(n_threads=1, program=code) | |
end = time.clock_gettime(time.CLOCK_MONOTONIC) | |
print('%g [s], %g [insn/s]' % (end - start, n / (end - start))) | |
print('Estimated clock: %g [MHz]' % (n / (end - start) * 4 * 1e-6)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment