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;
} }
@@ -171,28 +171,27 @@ public class HIP implements GPULister {
System.out.println("HIP::getGpus failed(C) generic exception " + e); System.out.println("HIP::getGpus failed(C) generic exception " + e);
return null; return null;
} }
List<GPUDevice> gpuDevices = new ArrayList<>(); List<GPUDevice> gpuDevices = new ArrayList<>();
int numberOfDevices = getNumberOfDevices(); int numberOfDevices = getNumberOfDevices();
if (numberOfDevices < 1) { if (numberOfDevices < 1) {
return null; return null;
} }
//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();
if (driverVersion == null) { if (driverVersion == null) {
return null; return null;
} }
boolean driverTooOld = compareVersions(driverVersion, MINIMAL_WINDOWS_DRIVER_VERSION) < 0;
driverVersionAsLong = Long.parseLong(driverVersion.replace(".", "")); if (driverTooOld) {
long minimumVersionAsLong = Long.parseLong(MINIMAL_WINDOWS_DRIVER_VERSION.replace(".",""));
if (driverVersionAsLong < minimumVersionAsLong) {
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;
}
} }