Does cuda.jit support default values for arguments?

46 views
Skip to first unread message

Gao Shuhua

unread,
Jun 24, 2020, 9:09:41 AM6/24/20
to Numba Public Discussion - Public
Hi, everyone,

The normal @jit indeed supports default values for function arguments. (See here in the documentation.) However, it seems @cuda.jit does not allow default values. 

@cuda.jit
def just_test(N, K=10):
   pos = cuda.grid(1)
   if pos == 0:
       print(N, K)

If we run 
just_test[1, 1](100)
the following error happens:
TypeError: Failed in nopython mode pipeline (step: fix up args) Signature mismatch: 1 argument types given, but function takes 2 arguments

Does numba support default arguments in CUDA kernels? Or did I miss anything?

Thank you!

Valentin Haenel

unread,
Jun 25, 2020, 2:17:48 AM6/25/20
to numba...@continuum.io
Dear Gao,

I just tried the following snippet on a cuda enabled machine:

```
from numba import cuda



@cuda.jit
def just_test(N, K=10):
    pos = cuda.grid(1)
    if pos == 0:
        print(N, K)

try:
    just_test[1, 1](100)
except Exception as e:
    print(e)
else:
    print("no exception")

try:
    just_test[1, 1](100, K=1)
except Exception as e:
    print(e)
else:
    print("no exception")

try:
    just_test[1, 1](100, 1)
except Exception as e:
    print(e)
else:
    print("no exception")
````

The only invocation that works, is the last one. It seems like this might be a bug. Would you be so kind as to open an issue on our issue tracker:


Thanks!

V-

--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/5a2fe4f0-7dcb-4491-97d0-503292530900o%40continuum.io.
Reply all
Reply to author
Forward
0 new messages