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

[DOC]: Modernize cuda.parallel.experimental.reduce_info example in the docstring #2307

Open
1 task done
leofang opened this issue Aug 28, 2024 · 0 comments · May be fixed by #2335
Open
1 task done

[DOC]: Modernize cuda.parallel.experimental.reduce_info example in the docstring #2307

leofang opened this issue Aug 28, 2024 · 0 comments · May be fixed by #2335
Assignees
Labels
doc Documentation-related items.

Comments

@leofang
Copy link
Member

leofang commented Aug 28, 2024

Is this a duplicate?

Is this for new documentation, or an update to existing docs?

Update

Describe the incorrect/future/missing documentation

The existing docs is based on this test file:

def test_device_reduce():
# example-begin reduce-min
def op(a, b):
return a if a < b else b
dtype = numpy.int32
h_init = numpy.array([42], dtype)
h_input = numpy.array([8, 6, 7, 5, 3, 0, 9])
d_output = cuda.device_array(1, dtype)
d_input = cuda.to_device(h_input)
# Instantiate reduction for the given operator and initial value
reduce_into = cudax.reduce_into(d_output, d_output, op, h_init)
# Deterrmine temporary device storage requirements
temp_storage_size = reduce_into(None, d_input, d_output, h_init)
# Allocate temporary storage
d_temp_storage = cuda.device_array(temp_storage_size, dtype=numpy.uint8)
# Run reduction
reduce_into(d_temp_storage, d_input, d_output, h_init)
expected_output = 0
# example-end reduce-min

However it is not the modern/canonical usage that we'd like to encourage. For example, CuPy ndarrays should be used instead of the primitive Numba device arrays. It might require some internal changes in how cuda.parallel fetches the pointer to the ndarray's buffer.

If this is a correction, please provide a link to the incorrect documentation. If this is a new documentation request, please link to where you have looked.

https://nvidia.github.io/cccl/cuda_parallel/#cuda.parallel.experimental.reduce_into

@leofang leofang added the doc Documentation-related items. label Aug 28, 2024
@leofang leofang self-assigned this Aug 28, 2024
@leofang leofang linked a pull request Aug 30, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Documentation-related items.
Projects
Status: In Review
Development

Successfully merging a pull request may close this issue.

1 participant