Add openCL support
This commit is contained in:
@@ -28,6 +28,7 @@ import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
|
||||
import com.sheepit.client.Configuration;
|
||||
import com.sheepit.client.hardware.gpu.GPU;
|
||||
import com.sheepit.client.hardware.gpu.GPUDevice;
|
||||
|
||||
@@ -38,10 +39,10 @@ public class ListGpuParameterHandler<T> extends OptionHandler<T> {
|
||||
|
||||
@Override
|
||||
public int parseArguments(Parameters params) throws CmdLineException {
|
||||
List<GPUDevice> gpus = GPU.listDevices();
|
||||
List<GPUDevice> gpus = GPU.listDevices(new Configuration(null, null, null));
|
||||
if (gpus != null) {
|
||||
for (GPUDevice gpu : gpus) {
|
||||
System.out.println("CUDA Name : " + gpu.getCudaName());
|
||||
System.out.println("Id : " + gpu.getId());
|
||||
System.out.println("Model : " + gpu.getModel());
|
||||
System.out.println("Memory, MB: " + (int) (gpu.getMemory() / (1024 * 1024)));
|
||||
System.out.println();
|
||||
|
||||
@@ -40,6 +40,8 @@ import com.sheepit.client.SettingsLoader;
|
||||
import com.sheepit.client.ShutdownHook;
|
||||
import com.sheepit.client.hardware.gpu.GPU;
|
||||
import com.sheepit.client.hardware.gpu.GPUDevice;
|
||||
import com.sheepit.client.hardware.gpu.nvidia.Nvidia;
|
||||
import com.sheepit.client.hardware.gpu.opencl.OpenCL;
|
||||
import com.sheepit.client.network.Proxy;
|
||||
|
||||
public class Worker {
|
||||
@@ -58,9 +60,12 @@ public class Worker {
|
||||
@Option(name = "-max-uploading-job", usage = "", metaVar = "1", required = false)
|
||||
private int max_upload = -1;
|
||||
|
||||
@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 = "Name of the GPU used for the render, for example CUDA_0 for Nvidia or OPENCL_0 for AMD/Intel card", metaVar = "CUDA_0", required = false)
|
||||
private String gpu_device = null;
|
||||
|
||||
@Option(name = "--no-gpu", usage = "Don't detect GPUs", required = false)
|
||||
private boolean no_gpu_detection = 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;
|
||||
|
||||
@@ -128,6 +133,7 @@ public class Worker {
|
||||
Configuration config = new Configuration(null, login, password);
|
||||
config.setPrintLog(print_log);
|
||||
config.setUsePriority(priority);
|
||||
config.setDetectGPUs(! no_gpu_detection);
|
||||
|
||||
if (cache_dir != null) {
|
||||
File a_dir = new File(cache_dir);
|
||||
@@ -146,16 +152,22 @@ public class Worker {
|
||||
}
|
||||
|
||||
if (gpu_device != null) {
|
||||
String cuda_str = "CUDA_";
|
||||
if (gpu_device.startsWith(cuda_str) == false) {
|
||||
System.err.println("CUDA_DEVICE should look like 'CUDA_X' where X is a number");
|
||||
if (gpu_device.startsWith(Nvidia.TYPE) == false && gpu_device.startsWith(OpenCL.TYPE) == false) {
|
||||
System.err.println("CUDA_DEVICE should look like '" + Nvidia.TYPE + "_X' or '" + OpenCL.TYPE + "_X' where X is a number");
|
||||
return;
|
||||
}
|
||||
String family = "";
|
||||
try {
|
||||
Integer.parseInt(gpu_device.substring(cuda_str.length()));
|
||||
if (gpu_device.startsWith(Nvidia.TYPE)) {
|
||||
family = Nvidia.TYPE;
|
||||
}
|
||||
else if (gpu_device.startsWith(OpenCL.TYPE)) {
|
||||
family = OpenCL.TYPE;
|
||||
}
|
||||
Integer.parseInt(gpu_device.substring(family.length() + 1)); // for the _
|
||||
}
|
||||
catch (NumberFormatException en) {
|
||||
System.err.println("CUDA_DEVICE should look like 'CUDA_X' where X is a number");
|
||||
System.err.println("Gpu device code should look like '" + family + "_X' where X is a number");
|
||||
return;
|
||||
}
|
||||
GPUDevice gpu = GPU.getGPUDevice(gpu_device);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class Settings implements Activity {
|
||||
Configuration config = parent.getConfiguration();
|
||||
new SettingsLoader().merge(config);
|
||||
|
||||
List<GPUDevice> gpus = GPU.listDevices();
|
||||
List<GPUDevice> gpus = GPU.listDevices(config);
|
||||
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
int currentRow = 0;
|
||||
@@ -208,10 +208,10 @@ public class Settings implements Activity {
|
||||
|
||||
for (GPUDevice gpu : gpus) {
|
||||
JCheckBoxGPU gpuCheckBox = new JCheckBoxGPU(gpu);
|
||||
gpuCheckBox.setToolTipText(gpu.getCudaName());
|
||||
gpuCheckBox.setToolTipText(gpu.getId());
|
||||
if (gpuChecked) {
|
||||
GPUDevice config_gpu = config.getGPUDevice();
|
||||
if (config_gpu != null && config_gpu.getCudaName().equals(gpu.getCudaName())) {
|
||||
if (config_gpu != null && config_gpu.getId().equals(gpu.getId())) {
|
||||
gpuCheckBox.setSelected(gpuChecked);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user