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

Documented return types in cudart.pyx are inconsistent with implementation. #15

Closed
bdice opened this issue Dec 6, 2021 · 2 comments
Closed

Comments

@bdice
Copy link

bdice commented Dec 6, 2021

The function signature of many APIs in the docs appear to return a 2-tuple like (status, None) but the actual return value is a 1-tuple like (status,).

For example:
Docs link: https://nvidia.github.io/cuda-python/api.html#cuda.cudart.cudaSetDevice
Source:

cuda-python/cuda/cudart.pyx

Lines 7903 to 7910 in d7a354d

Returns
-------
cudaError_t
cudaSuccess
cudaErrorInvalidDevice
cudaErrorDeviceAlreadyInUse
None
None

Rendered docs: image

In some cases, there is a second element like a string or memory pool in the tuple but the documented type indicates it as None.

For example:

cuda-python/cuda/cudart.pyx

Lines 7164 to 7193 in d7a354d

def cudaGetErrorName(error not None : cudaError_t):
""" Returns the string representation of an error code enum name.
Returns a string containing the name of an error code in the enum. If
the error code is not recognized, "unrecognized error code" is
returned.
Parameters
----------
error : cudaError_t
Error code to convert to string
Returns
-------
cudaError_t
`char*` pointer to a NULL-terminated string
None
None
See Also
--------
cudaGetErrorString
cudaGetLastError
cudaPeekAtLastError
cudaError
cuGetErrorName
"""
cdef ccudart.cudaError_t cerror = error.value
err = ccudart.cudaGetErrorName(cerror)
return (cudaError_t.cudaSuccess, err)

cuda-python/cuda/cudart.pyx

Lines 7641 to 7670 in d7a354d

def cudaDeviceGetDefaultMemPool(int device):
""" Returns the default mempool of a device.
The default mempool of a device contains device memory from that
device.
Returns
-------
cudaError_t
cudaSuccess
cudaErrorInvalidDevice
cudaErrorInvalidValue
cudaErrorNotSupported
None
None
See Also
--------
cuDeviceGetDefaultMemPool
cudaMallocAsync
cudaMemPoolTrimTo
cudaMemPoolGetAttribute
cudaDeviceSetMemPool
cudaMemPoolSetAttribute
cudaMemPoolSetAccess
"""
cdef cudaMemPool_t memPool = cudaMemPool_t()
with nogil:
err = ccudart.cudaDeviceGetDefaultMemPool(<ccudart.cudaMemPool_t*>memPool._ptr, device)
return (cudaError_t(err), memPool)

Let me know if you'd like me to work on this issue. I would be happy to contribute a pull request to improve the docs. 👍 I see PRs are not currently accepted.

@bdice bdice changed the title Docstring return values in cudart.pyx are inconsistent with implementation. Documented return values in cudart.pyx are inconsistent with implementation. Dec 6, 2021
@bdice bdice changed the title Documented return values in cudart.pyx are inconsistent with implementation. Documented return types in cudart.pyx are inconsistent with implementation. Dec 6, 2021
@vzhurba01
Copy link
Collaborator

Thanks for the notice! Fix submitted.

@bdice
Copy link
Author

bdice commented Feb 16, 2022

Thank you @vzhurba01! 😊

vzhurba01 added a commit that referenced this issue Oct 3, 2022
Squash existing commits, preserving description history:

Preserve the original commit

fixes to quickstart

docs feedback

removed docs rendering from main branch

overview -> motivation

more feedback

re-adding docs

Revert GIT HEAD to v11.4.0

Rebase to CTK 11.5

Update docs to CTK 11.5

Add EGL, GL, VDPAU as unsupported APIs

Fix Numba link in motivation.html

Closes #10

Docs Overview: Note for correct gpu-architecture

By default the example uses Turing architecture.
Add a note for when the first detectable incompatibility occures
(i.e. when calling cuModuleLoadData)

Update docs with Future of CUDA Python

Revert "Update docs with Future of CUDA Python"

This reverts commit 71ca262.

Update docs with Future of CUDA Python

Resolve doc consistency errors

- Missing parameters fields
- Missing return fields
- Remove None None return value for APIs with single tuple attribute
	- Assumes each API returns a tuple
	- Returns description describe each valid tuple element

Fixes #15

Patch fixes for error handling and C type interoperability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants