Fix: -compute-method not set when configuration file present (#268)

This commit is contained in:
Luis Uguina
2020-06-21 02:31:31 +10:00
committed by GitHub
parent 7685051662
commit 608e1d7aea
2 changed files with 26 additions and 21 deletions

View File

@@ -361,10 +361,16 @@ public class SettingsLoader {
config.setUsePriority(priority); config.setUsePriority(priority);
} }
try { try {
if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType if (config.getComputeMethod() == null && computeMethod == null) {
config.setComputeMethod(ComputeType.CPU);
}
else if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType
.valueOf(computeMethod))) { .valueOf(computeMethod))) {
if (config.getComputeMethod() == null) {
config.setComputeMethod(ComputeType.valueOf(computeMethod)); config.setComputeMethod(ComputeType.valueOf(computeMethod));
} }
}
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
System.err.println("SettingsLoader::merge failed to handle compute method (raw value: '" + computeMethod + "')"); System.err.println("SettingsLoader::merge failed to handle compute method (raw value: '" + computeMethod + "')");

View File

@@ -112,7 +112,7 @@ public class Worker {
return; return;
} }
ComputeType compute_method = ComputeType.CPU; ComputeType compute_method = null;
Configuration config = new Configuration(null, login, password); Configuration config = new Configuration(null, login, password);
config.setPrintLog(print_log); config.setPrintLog(print_log);
config.setUsePriority(priority); config.setUsePriority(priority);
@@ -223,10 +223,7 @@ public class Worker {
} }
} }
else { else {
if (config.getGPUDevice() == null) { if (config.getGPUDevice() != null) {
compute_method = ComputeType.CPU;
}
else {
compute_method = ComputeType.GPU; compute_method = ComputeType.GPU;
} }
} }
@@ -246,6 +243,7 @@ public class Worker {
config.setExtras(extras); config.setExtras(extras);
} }
if (compute_method != null) {
if (compute_method == ComputeType.CPU && config.getGPUDevice() != null) { if (compute_method == ComputeType.CPU && config.getGPUDevice() != null) {
System.err.println( System.err.println(
"ERROR: The compute method is set to use CPU only, but a GPU has also been specified. Change the compute method to CPU_GPU or remove the GPU"); "ERROR: The compute method is set to use CPU only, but a GPU has also been specified. Change the compute method to CPU_GPU or remove the GPU");
@@ -263,6 +261,7 @@ public class Worker {
else if (compute_method == ComputeType.CPU) { else if (compute_method == ComputeType.CPU) {
config.setGPUDevice(null); // remove the GPU config.setGPUDevice(null); // remove the GPU
} }
}
config.setComputeMethod(compute_method); config.setComputeMethod(compute_method);