Skip to content

[FEA] Keyword argument support at kernel launch #868

Description

@a-ellison

Is your feature request related to a problem? Please describe.

Python supports passing function arguments either positionally or by keyword,
but Numba CUDA kernel launches do not appear to support keyword arguments.

Minimal repro:

from numba import cuda


def f(flag):
    return flag


@cuda.jit
def kernel_1(flag):
    return


@cuda.jit
def kernel_2(flag=True):
    return


print("plain Python call:", f(flag=True))

try:
    kernel_1[1, 1](flag=True)
except TypeError as exc:
    print(f"kernel_1: {exc}")

try:
    kernel_2[1, 1](flag=True)
except TypeError as exc:
    print(f"kernel_2: {exc}")

This fails with:

plain Python call: True
kernel_1: _LaunchConfiguration.__call__() got an unexpected keyword argument 'flag'
kernel_2: _LaunchConfiguration.__call__() got an unexpected keyword argument 'flag'

Describe the solution you'd like

Support keyword arguments as in regular Python. It's used often in Pythonic code.

Describe alternatives you've considered

N/A

Additional context

Observed with numba-cuda 0.30.0 and numba 0.65.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions