Repository navigation
Add attributes property to Device - #1869
Conversation
|
@kmaehashi Could you take a look at the changes? |
kmaehashi
left a comment
There was a problem hiding this comment.
Thanks! LGTM except comments.
| name = k.replace('cudaDevAttr', '') | ||
| d[name] = runtime.deviceGetAttribute(v, device_id) | ||
| except runtime.CUDARuntimeError: | ||
| pass |
There was a problem hiding this comment.
Reraise the warning if the error code is not cudaErrorInvalidValue.
| """Return a dict containing all device attributes.""" | ||
| d = {} | ||
| for k, v in runtime.__dict__.items(): | ||
| if 'cudaDevAttr' in k: |
There was a problem hiding this comment.
Use k.startswith('cudaDevAttr').
|
|
||
|
|
||
| @util.memoize() | ||
| def get_attributes_dict(device_id): |
There was a problem hiding this comment.
Please move this function to device.pyx and name it _get_attributes to make it explicitly private.
|
|
||
| errorMemoryAllocation = 2 | ||
|
|
||
| cudaDevAttrMaxThreadsPerBlock = 1 # Maximum number of threads per block |
There was a problem hiding this comment.
Could you remove the comment part? (our coding rule (PEP8) requires max. 80 chars for each line)
| for k, v in runtime.__dict__.items(): | ||
| if 'cudaDevAttr' in k: | ||
| try: | ||
| name = k.replace('cudaDevAttr', '') |
There was a problem hiding this comment.
Use k.replace('cudaDevAttr', '', 1).
|
Could you try adding documentation for |
add errorInvalidValue
|
Hi @kmaehashi . Thanks for the quick and helpful review! I have implemented your suggestions and added some tests. |
|
Thanks @grlee77! Will take a look. |
This was renamed to _get_attributes and moved to device.pyx
|
LGTM! Jenkins, test this please. |
|
Jenkins CI test (for commit 1405b3a, target branch master) succeeded! |
attributes property to Device
|
@grlee77 Thanks! |
This PR adds a memoized
attributesproperty to theDeviceclass for easy querying of device attributes such as the maximum block size, etc.The approach follows the suggestions made by @kmaehashi in #1867, although I am not certain if all of the changes are located in the expected files.
closes #1867