faster program start in llvm (#3897)

This commit is contained in:
nimlgen 2024-03-23 15:20:15 +03:00 committed by GitHub
parent 46a3501cec
commit 4e18dd78d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -27,6 +27,7 @@ class LLVMProgram:
self.fxn = device.engine.get_function_address(name)
def __call__(self, *bufs, vals:Tuple[int, ...]=(), wait=False):
if not hasattr(self, 'cfunc'):
self.cfunc = ctypes.CFUNCTYPE(ctypes.c_int, *([ctypes.c_void_p]*len(bufs)), *([ctypes.c_int32]*len(vals)))(self.fxn)
return cpu_time_execution(lambda: self.cfunc(*bufs, *vals), enable=wait)