I am working on this example:
http://numba.pydata.org/numba-doc/0.15.1/examples.html#multi-threading
and he claims that:
You must make sure that the inner_func file is compiled at this point, because compilation must happen in the main thread. This is the case in this example because we use jit ().
The example shows that calling jit on a function provides compilation at this time.
Will a multi-threaded example work if, instead of calling jitthe function we used jit, with argument types specified as decorators? I think this is equivalent to asking the question whether the function will compile when determining if it is associated with a decorator.
import numba as nb
import numpy as np
def inner_func(result, a, b):
threadstate = savethread()
for i in range(len(result)):
result[i] = np.exp(2.1 * a[i] + 3.2 * b[i])
restorethread(threadstate)
signature = nb.void(nb.double[:], nb.double[:], nb.double[:])
inner_func_nb = nb.jit(signature, nopython=True)(inner_func)
against
import numba as nb
import numpy as np
signature = nb.void(nb.double[:], nb.double[:], nb.double[:])
@nb.jit(signature, nopython=True)
def inner_func(result, a, b):
threadstate = savethread()
for i in range(len(result)):
result[i] = np.exp(2.1 * a[i] + 3.2 * b[i])
restorethread(threadstate)