The Wayback Machine - https://web.archive.org/web/20200824084031/https://github.com/numba/numba/issues/6050
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support zero-length arrays in numba.cuda #6050

Open
eric-wieser opened this issue Jul 29, 2020 · 5 comments
Open

Support zero-length arrays in numba.cuda #6050

eric-wieser opened this issue Jul 29, 2020 · 5 comments

Comments

@eric-wieser
Copy link
Contributor

@eric-wieser eric-wieser commented Jul 29, 2020

As an example,

@numba.cuda.jit
def foo():
    x = numba.cuda.local.array(shape=(2, 0), dtype=numba.int64)

foo()

gives ValueError: array length <= 0.

Currently these lines contain a workaround because of this issue:

if ndim == 0:
# the (2, ndim) allocation below is not yet supported, so avoid it
@cuda.jit
def kernel(lhs, rhs):
lhs[()] = rhs[()]
return kernel
@cuda.jit
def kernel(lhs, rhs):
location = cuda.grid(1)
n_elements = 1
for i in range(lhs.ndim):
n_elements *= lhs.shape[i]
if location >= n_elements:
# bake n_elements into the kernel, better than passing it in
# as another argument.
return
# [0, :] is the to-index (into `lhs`)
# [1, :] is the from-index (into `rhs`)
idx = cuda.local.array(
shape=(2, ndim),
dtype=types.int64)
@gmarkall
Copy link
Member

@gmarkall gmarkall commented Jul 29, 2020

Thanks for the report / request!

@gmarkall
Copy link
Member

@gmarkall gmarkall commented Aug 17, 2020

See also #5234

@eric-wieser
Copy link
Contributor Author

@eric-wieser eric-wieser commented Aug 17, 2020

#5234 is about arrays with shape () (len(shape) == 0), this issue is about arrays with shape (0,), (0, n) etc (0 in shape).

@gmarkall
Copy link
Member

@gmarkall gmarkall commented Aug 17, 2020

Yes, I don't think they're duplicates, I was just trying to gather together a few shape-related issues in case someone is looking at fixing up things in these areas.

@eric-wieser
Copy link
Contributor Author

@eric-wieser eric-wieser commented Aug 17, 2020

I think I already fixed the other one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.