JIT decorated function fails compiling with "parallel=True"

I’m trying to accelerate my code using numba.
I wrote a jit decorated function that is correctly compiled when “parallel=False”, but it doesn’t when “parallel=True”.

This is my function:

@jit(nopython=True, parallel=True, cache=True)
def I_obj_func(y_bar,ni,beta):
    I_func = np.empty((2,beta.shape[0]),dtype=np.float64)
    for k in prange(2):
        D_a_k_conj_diag = np.exp(-1j*2*np.pi/P*ni[k]*np.arange(P))
        Ryy_conj_cycl_tmp = np.zeros((P,P), dtype=np.complex128)
        for j in prange(J):
            for r in prange(-1,2):
                Ryy_conj_cycl_tmp += np.exp(1j*2*np.pi*ni[k]*r)*cycl_conj_corr(y_bar[j],2*ni[k],r)
        Phi_a_k = np.expand_dims(D_a_k_conj_diag,-1) * Ryy_conj_cycl_tmp * D_a_k_conj_diag
        phi_a_k = np.diag(W_p.conj().T @ Phi_a_k @ W_p.conj())
        tmp = phi_a_k[:P//2]*upsilon.conj()[:P//2]
        for idx in prange(beta.shape[0]):
            I_func[k,idx] = np.abs(np.sum(tmp*np.exp(1j*4*np.pi/Ts*beta[idx]*np.arange(P//2))))
    return I_func

and this is the compilation error:

LoweringError: '$push_global_to_block.74504'

Please, let me know If you need more information.
Thanks a lot.

Ivan

Hi @krono86,

Thanks for reporting this, looks like a bug. I’ve opened a ticket to track: parfors lowering error from missing entry in varmap · Issue #7213 · numba/numba · GitHub

@krono86 I have fixed the error that you were seeing. However, even after that fix, your code is not going to work because currently, parallel=True does not support broadcasting, which your code uses. Right now, to use parallel=True you are going to have to write your code such that it does the broadcast manually as NumPy’s broadcast_to function is also not supported by Numba.