Access the device status directly, remove the getter
[alexxy/gromacs.git] / src / gromacs / ewald / tests / testhardwarecontexts.cpp
index 6ae36951d5ad20d5ac9e807ea5c1ef8cd43c2958..5b7cb0532793440c1653807d72af3c724397c52e 100644 (file)
@@ -105,16 +105,13 @@ void PmeTestEnvironment::SetUp()
         return;
     }
     // Constructing contexts for all compatible GPUs - will be empty on non-GPU builds
-    for (int gpuIndex : getCompatibleGpus(hardwareInfo_->gpu_info))
+    for (const DeviceInformation& compatibleDeviceInfo : getCompatibleDevices(hardwareInfo_->deviceInfoList))
     {
-        const DeviceInformation* deviceInfo = getDeviceInfo(hardwareInfo_->gpu_info, gpuIndex);
-        init_gpu(deviceInfo);
-
-        char stmp[200] = {};
-        get_gpu_device_info_string(stmp, hardwareInfo_->gpu_info, gpuIndex);
-        std::string description = "(GPU " + std::string(stmp) + ") ";
+        setActiveDevice(compatibleDeviceInfo);
+        std::string deviceDescription = getDeviceInformationString(compatibleDeviceInfo);
+        std::string description       = "(GPU " + deviceDescription + ") ";
         hardwareContexts_.emplace_back(std::make_unique<TestHardwareContext>(
-                CodePath::GPU, description.c_str(), *deviceInfo));
+                CodePath::GPU, description.c_str(), compatibleDeviceInfo));
     }
 }