Merge branch 'fix/hip_version' into 'master'

Fix: driver version comparison

See merge request sheepitrenderfarm/client!170
This commit is contained in:
harlekin
2022-10-30 13:44:12 +00:00

View File

@@ -73,7 +73,7 @@ public class HIP implements GPULister {
} }
String driverVersion = ""; String driverVersion = "";
for (var gpu : gpus) { for (var gpu : gpus) {
if (gpu.getName().contains("AMD ")) { if (gpu.getName().contains("AMD ") || gpu.getName().contains("Radeon ")) {
driverVersion = gpu.getVersionInfo(); driverVersion = gpu.getVersionInfo();
break; break;
} }
@@ -180,7 +180,6 @@ public class HIP implements GPULister {
} }
//check that the driver is capable //check that the driver is capable
long driverVersionAsLong = -1;
String driverVersion = ""; String driverVersion = "";
try { try {
driverVersion = getDriverVersion(); driverVersion = getDriverVersion();
@@ -188,11 +187,11 @@ public class HIP implements GPULister {
return null; return null;
} }
driverVersionAsLong = Long.parseLong(driverVersion.replace(".", "")); boolean driverTooOld = compareVersions(driverVersion, MINIMAL_WINDOWS_DRIVER_VERSION) < 0;
long minimumVersionAsLong = Long.parseLong(MINIMAL_WINDOWS_DRIVER_VERSION.replace(".",""));
if (driverVersionAsLong < minimumVersionAsLong) { if (driverTooOld) {
System.out.println("HIP::getGpus AMD driver too old"); System.out.println("HIP::getGpus AMD driver too old");
System.out.println("Driver version: " + driverVersion);
return null; return null;
} }
} }
@@ -214,4 +213,23 @@ public class HIP implements GPULister {
return gpuDevices; return gpuDevices;
} }
private int compareVersions(String version1, String version2) {
int comparisonResult = 0;
String[] version1Splits = version1.split("\\.");
String[] version2Splits = version2.split("\\.");
int maxLengthOfVersionSplits = Math.max(version1Splits.length, version2Splits.length);
for (int i = 0; i < maxLengthOfVersionSplits; i++){
Integer v1 = i < version1Splits.length ? Integer.parseInt(version1Splits[i]) : 0;
Integer v2 = i < version2Splits.length ? Integer.parseInt(version2Splits[i]) : 0;
int compare = v1.compareTo(v2);
if (compare != 0) {
comparisonResult = compare;
break;
}
}
return comparisonResult;
}
} }