-
Notifications
You must be signed in to change notification settings - Fork 223
Standardize use of Device arguments #1238
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
Conversation
5ea1aea to
fa327db
Compare
|
|
||
| """ | ||
| __slots__ = ("_id", "_mr", "_has_inited", "_properties", "_uuid") | ||
| __slots__ = ("_id", "_memory_resource", "_has_inited", "_properties", "_uuid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this to match a request in a recent change to _memory/_buffer.*
| # If the device is in TCC mode, or does not support memory pools for some other reason, | ||
| # use the SynchronousMemoryResource which does not use memory pools. | ||
| with nogil: | ||
| HANDLE_RETURN( | ||
| cydriver.cuDeviceGetAttribute( | ||
| &attr, cydriver.CUdevice_attribute.CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED, dev_id | ||
| ) | ||
| ) | ||
| if attr == 1: | ||
| from cuda.core.experimental._memory import DeviceMemoryResource | ||
| device._mr = DeviceMemoryResource(dev_id) | ||
| else: | ||
| from cuda.core.experimental._memory import _SynchronousMemoryResource | ||
| device._mr = _SynchronousMemoryResource(dev_id) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to @property memory_resource (lazy init). This was resulting in a circularity with DeviceMemoryResource using Device.
…public APIs taking a device to accept either.
fa327db to
267b268
Compare
|
/ok to test 267b268 |
This comment has been minimized.
This comment has been minimized.
rparolin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Description
Standardizes the way device arguments are accepted in public APIs. Previously, some functions could accept either a
Deviceorintrepresenting a device ordinal, whereas other would accept only an ordinal. This change updates everything to accept either.Also, rather than use
getattrto convert argument, this change usesDevice(arg)to convert any supported argument to a device (or raise an exception), matching the wayStreamarguments are converted.