Fix: opencl gpu id

This commit is contained in:
FluxTape
2020-01-02 13:41:01 +01:00
parent 2ceecb5830
commit 83ce5b6f6c
2 changed files with 14 additions and 5 deletions

View File

@@ -106,9 +106,13 @@ public class OpenCL implements GPULister {
for (int j = 0; j < device_count.getValue(); j++) { for (int j = 0; j < device_count.getValue(); j++) {
String name = getInfodeviceString(lib, devices[j], OpenCLLib.CL_DEVICE_BOARD_NAME_AMD); String name = getInfodeviceString(lib, devices[j], OpenCLLib.CL_DEVICE_BOARD_NAME_AMD);
String platform_name = getInfoPlatform(lib, plateforms[i], OpenCLLib.CL_PLATFORM_NAME);
long vram = getInfodeviceLong(lib, devices[j], OpenCLLib.CL_DEVICE_GLOBAL_MEM_SIZE); long vram = getInfodeviceLong(lib, devices[j], OpenCLLib.CL_DEVICE_GLOBAL_MEM_SIZE);
if (name != null && vram > 0) { if (name != null && vram > 0) {
GPUDevice gpu = new GPUDevice(TYPE, new String(name).trim(), vram, getBlenderId(lib, devices[j])); if (name.equals("Radeon RX Vega")) {
name += " " + getInfodeviceLong(lib, devices[j], OpenCLLib.CL_DEVICE_MAX_COMPUTE_UNITS);
}
GPUDevice gpu = new GPUDevice(TYPE, name, vram, getBlenderId(lib, devices[j], platform_name, name));
gpu.setOldId(TYPE + "_" + id); gpu.setOldId(TYPE + "_" + id);
available_devices.add(gpu); available_devices.add(gpu);
} }
@@ -158,15 +162,15 @@ public class OpenCL implements GPULister {
return new String(name).trim(); return new String(name).trim();
} }
private static String getBlenderId(OpenCLLib lib, CLDeviceId.ByReference device) { private static String getBlenderId(OpenCLLib lib, CLDeviceId.ByReference device, String platform, String name) {
byte topology[] = new byte[24]; byte topology[] = new byte[24];
int status = lib.clGetDeviceInfo(device, 0x4037, 24, topology, null); int status = lib.clGetDeviceInfo(device, lib.CL_DEVICE_TOPOLOGY_AMD, 24, topology, null);
if (status != OpenCLLib.CL_SUCCESS) { if (status != OpenCLLib.CL_SUCCESS) {
System.out.println("OpenCL::getBlenderId failed(I) status: " + status); System.out.println("OpenCL::getBlenderId failed(I) status: " + status);
return ""; return "";
} }
return String.format("%02x:%02x.%01x", topology[21], topology[22], topology[23]); return String.format("%s_%s_%s_%02x:%02x.%01x", TYPE, platform, name, topology[21], topology[22], topology[23]);
} }
} }

View File

@@ -32,6 +32,7 @@ public interface OpenCLLib extends Library {
public static final int CL_DEVICE_NOT_FOUND = -1; public static final int CL_DEVICE_NOT_FOUND = -1;
public static final int CL_PLATFORM_VENDOR = 0x0903; public static final int CL_PLATFORM_VENDOR = 0x0903;
public static final int CL_PLATFORM_NAME = 0x0902;
// cl_device_type // cl_device_type
public static final int CL_DEVICE_TYPE_DEFAULT = (1 << 0); public static final int CL_DEVICE_TYPE_DEFAULT = (1 << 0);
@@ -43,8 +44,12 @@ public interface OpenCLLib extends Library {
// cl_device_info // cl_device_info
public static final int CL_DEVICE_NAME = 0x102B; public static final int CL_DEVICE_NAME = 0x102B;
public static final int CL_DEVICE_VENDOR = 0x102C;
public static final int CL_DEVICE_VERSION = 0x102D;
public static final int CL_DEVICE_MAX_COMPUTE_UNITS = 0x1002;
public static final int CL_DEVICE_GLOBAL_MEM_SIZE = 0x101F; public static final int CL_DEVICE_GLOBAL_MEM_SIZE = 0x101F;
public static final int CL_DEVICE_BOARD_NAME_AMD = 0x4038; public static final int CL_DEVICE_BOARD_NAME_AMD = 0x4038;
public static final int CL_DEVICE_TOPOLOGY_AMD = 0x4037;
public int clGetPlatformIDs(int num_entries, CLPlatformId.ByReference[] platforms, IntByReference num_platforms); public int clGetPlatformIDs(int num_entries, CLPlatformId.ByReference[] platforms, IntByReference num_platforms);