I’m trying to call a DLL function with Numba using Ctypes. However, the function receives multiple arguments, including pointers. And it seems impossible to pass the values from a jit function.
Example:
a_ = np.asarray([1.5930, 1.9597, 0.0263*1000])
a = a_.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
It is not accepted.
Cannot determine Numba type of <class 'ctypes.wintypes.LP_c_float'>
Does anybody know a way around this? Thanks!
I managed to use ‘intrinsic’ decorator, but I don’t really know how to use it properly
@intrinsic
def callingDLL(typingctx, T, P):
a_ = np.array([28.05/1000, 42.05/1000, 1])
b_ = np.array([1.5930, 1.9597, 0.0263*1000])
a = a_.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
b = b_.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
result = types.CPointer(types.float64)
def functiontobecalled(T, P, a, b):
return functionDLL(T, P, a, b)
return result, functiontobecalled
@jit(nopython=True)
def Teste(T, P):
result = functiontobecalled(T, P)
print("Answer is:", result )
return