mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-22 13:28:06 -05:00
* Revert "Revert "ops rdna"" This reverts commit0400315078. * Revert "Revert "writing 2"" This reverts commit325a3bf2cf. * no dump * 2x 2 * simple asm * local size * sub * lil work * support args != 3 * assembler work * generate that * ptx assembler * begin index renderer * max * ptx loops * gemms work * valid works * asm working a bit more * close * passing all ops tests * ptx is a codegen only, not a backend * ptx * float16 support * rdna goes here * install types * make amd disassemble * ansilen for pretty print * fix ptx log2/exp2 * assemblyinstruction * new asm * working gemm * fix cmp * more passing * mod * ptx works again * rdan3 add works * log exp * sin is sin 2pi * fix types * progress * loops work * rdna xyz * better addressing * cleanups * handle exception in early process * div support * rdna float4 * locals work * fix neg index * cast * smaller diff * yaml * import only if selected * fromimport * types * this all needs rewriting * a few more
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from tinygrad.helpers import Timing
|
|
import subprocess
|
|
import multiprocessing
|
|
|
|
def _early_exec_process(qin, qout):
|
|
while True:
|
|
path, inp = qin.get()
|
|
try:
|
|
qout.put(subprocess.check_output(path, input=inp))
|
|
except subprocess.CalledProcessError as e:
|
|
qout.put(e)
|
|
|
|
def enable_early_exec():
|
|
qin: multiprocessing.Queue = multiprocessing.Queue()
|
|
qout: multiprocessing.Queue = multiprocessing.Queue()
|
|
p = multiprocessing.Process(target=_early_exec_process, args=(qin, qout))
|
|
p.daemon = True
|
|
p.start()
|
|
def early_exec(x):
|
|
qin.put(x)
|
|
ret = qout.get()
|
|
if isinstance(ret, Exception): raise ret
|
|
else: return ret
|
|
return early_exec
|
|
|
|
def proc(itermaker, q) -> None:
|
|
for x in itermaker(): q.put(x)
|
|
q.close()
|
|
|
|
def cross_process(itermaker, maxsize=8):
|
|
# TODO: use cloudpickle for itermaker
|
|
q: multiprocessing.Queue = multiprocessing.Queue(maxsize)
|
|
p = multiprocessing.Process(target=proc, args=(itermaker, q))
|
|
p.daemon = True
|
|
p.start()
|
|
|
|
# TODO: write tests and handle exit case
|
|
while True: yield q.get()
|