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

Function of len() is invalid to dynamic share array #5206

Open
mantouRobot opened this issue Feb 6, 2020 · 3 comments
Open

Function of len() is invalid to dynamic share array #5206

mantouRobot opened this issue Feb 6, 2020 · 3 comments
Labels
CUDA CUDA related issue/PR good first issue A good issue for a first time contributor Task

Comments

@mantouRobot
Copy link

Hi~
I found the function of len() is invalid to dynamic share array. Here is my code snippet:

@cuda.jit
def kern_fun()
    dynamic_share_array = cuda.shared.array(0, numba.float32)
    fill_value(dynamic_share_array)
    print(len(dynamic_share_array))

main():
    kern_fun[1, 10, 0, 100]()

the output of print is '0'. Any ideas?

@mantouRobot
Copy link
Author

Also, I found the negative index of dynamic share array is invalid.

@gmarkall
Copy link
Member

gmarkall commented Feb 6, 2020

This may be fixed by #5099 - in any case, it won't work without it.

@gmarkall
Copy link
Member

This is now working, probably because of #5099

@cuda.jit
def kern_fun():
    dsa = cuda.shared.array(0, numba.float32)
    print(len(dsa))

kern_fun[1, 1, 0, 100]()

prints:

25

Negative indices also seem to be working (from a quick check):

@cuda.jit
def fill_last(x):
    dsa = cuda.shared.array(0, numba.float64)
    dsa[-1] = 99
    i = cuda.grid(1)
    x[i] = dsa[i]

x = np.zeros(10)
fill_last[1, 10, 0, 80](x)
print(x)

prints:

array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 99.])

I'll suggest leaving this issue open as I'd like to make a PR for a few test cases to check that length and negative indexing is robust.

@gmarkall gmarkall added the good first issue A good issue for a first time contributor label Aug 17, 2020
@stuartarchibald stuartarchibald added Task and removed bug labels Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CUDA CUDA related issue/PR good first issue A good issue for a first time contributor Task
Projects
None yet
Development

No branches or pull requests

5 participants