Home > Net >  multiple type signatures of Numba cuda.jit
multiple type signatures of Numba cuda.jit

Time:10-30

I meet a problem if I have multiple choices of type signatures in cuda.jit. In my function, I will reset data back to ref if done flag is on. The data type could be int32 or float32 array. It is just for experiment, do not bother with the dummy function itself. This function is running well if I just use cuda.jit, so I am pretty sure there is some issue with my type declare, but it looks like a correct way from the documentation. BTW, I am using Numba 0.54.

from numba import cuda 
from numba import float32, int32


@cuda.jit([(int32[:], int32[:], int32[:], int32),
           (float32[:], float32[:], int32[:], int32)])
def reset_when_done(data, ref, done, force_reset):
    env_id = cuda.blockIdx.x
    tid = cuda.threadIdx.x
    if tid == 0:
        if force_reset > 0.5 or done[env_id] > 0.5:
            data[env_id] = ref[env_id]

And I got the error

TypeError: [(array(int32, 1d, A), array(int32, 1d, A), array(int32, 1d, A), int32), (array(float32, 1d, A), array(float32, 1d, A), array(int32, 1d, A), int32)] is not a callable object

CodePudding user response:

The first parameter of cuda.jit needs to be either a signature or a function regarding the documentation. The same is true for the CPU JIT. The thing is the signature can be a list of basic signatures with the CPU JIT and not with CUDA JIT so far. This is a bug. It has been reported, still opened and plan to be fixed in Numba 0.57.

  • Related