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

Enable string-based UID for GPUs #842

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pennylane_lightning/core/src/bindings/BindingsCudaUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ void registerCudaUtils(py::module_ &m) {
.def("syncDevice", &DevicePool<int>::syncDevice)
.def("refresh", &DevicePool<int>::refresh)
.def_static("getTotalDevices", &DevicePool<int>::getTotalDevices)
.def_static("getDeviceUIDs", &DevicePool<int>::getDeviceUIDs)
.def_static("getDeviceUIDs", [](){
auto data = DevicePool<int>::getDeviceUIDs();
std::vector<py::bytes> data_conv;
data_conv.reserve(data.size());
for(auto d : data){
data_conv.push_back(py::bytes(std::move(d)));
}
return data_conv;
})
.def_static("setDeviceID", &DevicePool<int>::setDeviceIdx)
.def(py::pickle(
[]([[maybe_unused]] const DevicePool<int> &self) { // __getstate__
Expand Down
6 changes: 3 additions & 3 deletions pennylane_lightning/core/src/utils/cuda_utils/DevicePool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ template <typename DeviceIndexType = int> class DevicePool {
*
* @return std::vector<cudaUUID_t>
*/
static std::vector<cudaUUID_t> getDeviceUIDs() {
static std::vector<std::string> getDeviceUIDs() {
int deviceCount;
cudaGetDeviceCount(&deviceCount);
int device;
std::vector<cudaUUID_t> dev_uid(deviceCount);
std::vector<std::string> dev_uid(deviceCount);
for (device = 0; device < deviceCount; device++) {
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, device);
dev_uid[device] = deviceProp.uuid;
dev_uid[device] = std::string(deviceProp.uuid.bytes);
}
return dev_uid;
}
Expand Down
Loading