Bugfix: by default the compute method should cpu_only because now the server handle correctly cpu+gpu and gpu only

This commit is contained in:
Laurent Clouet
2014-12-02 20:21:12 +00:00
parent 3dcf3cafb1
commit 957e5bb6d5
2 changed files with 29 additions and 12 deletions

View File

@@ -56,7 +56,7 @@ public class Configuration {
this.static_exeDirName = "exe"; this.static_exeDirName = "exe";
this.maxUploadingJob = 1; this.maxUploadingJob = 1;
this.nbCores = -1; // ie not set this.nbCores = -1; // ie not set
this.computeMethod = ComputeType.CPU_GPU; this.computeMethod = ComputeType.CPU_ONLY;
this.GPUDevice = null; this.GPUDevice = null;
this.userSpecifiedACacheDir = false; this.userSpecifiedACacheDir = false;
this.workingDirectory = null; this.workingDirectory = null;
@@ -117,9 +117,6 @@ public class Configuration {
public void setUseGPU(GPUDevice device) { public void setUseGPU(GPUDevice device) {
this.GPUDevice = device; this.GPUDevice = device;
if (device == null) {
this.computeMethod = ComputeType.CPU_GPU;
}
} }
public void setComputeMethod(ComputeType meth) { public void setComputeMethod(ComputeType meth) {

View File

@@ -62,7 +62,7 @@ public class Worker {
@Option(name = "-gpu", usage = "CUDA name of the GPU used for the render, for example CUDA_0", metaVar = "CUDA_0", required = false) @Option(name = "-gpu", usage = "CUDA name of the GPU used for the render, for example CUDA_0", metaVar = "CUDA_0", required = false)
private String gpu_device = null; private String gpu_device = null;
@Option(name = "-compute-method", usage = "CPU: only use cpu, GPU: only use gpu, CPU_GPU: can use cpu and gpu (not at the same time) if -gpu is not use it will not use the gpu", metaVar = "CPU_GPU", required = false) @Option(name = "-compute-method", usage = "CPU: only use cpu, GPU: only use gpu, CPU_GPU: can use cpu and gpu (not at the same time) if -gpu is not use it will not use the gpu", metaVar = "CPU", required = false)
private String method = null; private String method = null;
@Option(name = "-cores", usage = "Number of core/thread to use for the render", metaVar = "3", required = false) @Option(name = "-cores", usage = "Number of core/thread to use for the render", metaVar = "3", required = false)
@@ -110,7 +110,7 @@ public class Worker {
return; return;
} }
ComputeType compute_method = ComputeType.CPU_GPU; ComputeType compute_method = ComputeType.CPU_ONLY;
Configuration config = new Configuration(null, login, password); Configuration config = new Configuration(null, login, password);
config.setPrintLog(print_log); config.setPrintLog(print_log);
@@ -206,6 +206,14 @@ public class Worker {
System.exit(2); System.exit(2);
} }
} }
else {
if (config.getGPUDevice() == null) {
compute_method = ComputeType.CPU_ONLY;
}
else {
compute_method = ComputeType.GPU_ONLY;
}
}
if (proxy != null) { if (proxy != null) {
try { try {
@@ -240,14 +248,26 @@ public class Worker {
config.setExtras(extras); config.setExtras(extras);
} }
if (compute_method == ComputeType.CPU_ONLY) { // the client was to render with cpu but on the server side project type are cpu+gpu or gpu prefered but never cpu only if (compute_method == ComputeType.CPU_ONLY && config.getGPUDevice() != null) {
compute_method = ComputeType.CPU_GPU; System.err.println("You choose to only use the CPU but a GPU was also provided. You can not do bought.");
config.setComputeMethod(compute_method); System.err.println("Aborting");
System.exit(2);
}
else if (compute_method == ComputeType.CPU_GPU && config.getGPUDevice() == null) {
System.err.println("You choose to only use the CPU and GPU but no GPU device was provided.");
System.err.println("Aborting");
System.exit(2);
}
else if (compute_method == ComputeType.GPU_ONLY && config.getGPUDevice() == null) {
System.err.println("You choose to only use the GPU but no GPU device was provided.");
System.err.println("Aborting");
System.exit(2);
}
else if (compute_method == ComputeType.CPU_ONLY) {
config.setUseGPU(null); // remove the GPU config.setUseGPU(null); // remove the GPU
} }
else {
config.setComputeMethod(compute_method); // doing it here because it have to be done after the setUseGPU config.setComputeMethod(compute_method);
}
Log.getInstance(config).debug("client version " + config.getJarVersion()); Log.getInstance(config).debug("client version " + config.getJarVersion());