Skip to content

Add support for getting the UUID of a device #71

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

Merged
merged 2 commits into from
May 12, 2022

Conversation

vmx
Copy link
Contributor

@vmx vmx commented May 11, 2022

Device::uuid() was added to get the UUID of a device via the underlying
cuDevuceGetUuid() call.

unsafe {
let mut cu_uuid = CUuuid { bytes: [0i8; 16] };
cuDeviceGetUuid(&mut cu_uuid, self.device).to_result()?;
let uuid: [u8; 16] = ::std::mem::transmute(cu_uuid.bytes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a transmute for just i8 -> u8 seems a bit odd, just using array.map() would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with the most recent push (I also fixed the commit message to match the usual style).

`Device::uuid()` was added to get the UUID of a device via the underlying
`cuDevuceGetUuid()` call.
Instead of using the `to_ne_bytes()` function, cast directly as `u8`.

Co-authored-by: Riccardo D'Ambrosio <[email protected]>
@vmx
Copy link
Contributor Author

vmx commented May 11, 2022

I can also squash and rebase the commit if you prefer that.

@RDambrosio016
Copy link
Member

I usually squash commits anyways, so this is fine :)

@RDambrosio016 RDambrosio016 merged commit 2de8180 into Rust-GPU:master May 12, 2022
@vmx vmx deleted the uuid branch May 12, 2022 07:47
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

Successfully merging this pull request may close these issues.

2 participants