From 83ce5b6f6c8c16a8c8a9dbdad78097a17b695ac1 Mon Sep 17 00:00:00 2001 From: FluxTape Date: Thu, 2 Jan 2020 13:41:01 +0100 Subject: [PATCH] Fix: opencl gpu id --- .../sheepit/client/hardware/gpu/opencl/OpenCL.java | 14 +++++++++----- .../client/hardware/gpu/opencl/OpenCLLib.java | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java b/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java index 835b50c..77cefd6 100644 --- a/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java +++ b/src/com/sheepit/client/hardware/gpu/opencl/OpenCL.java @@ -106,9 +106,13 @@ public class OpenCL implements GPULister { for (int j = 0; j < device_count.getValue(); j++) { 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); 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); available_devices.add(gpu); } @@ -158,15 +162,15 @@ public class OpenCL implements GPULister { 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]; - 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) { System.out.println("OpenCL::getBlenderId failed(I) status: " + status); 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]); } } diff --git a/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java b/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java index f9c23cc..1b8b363 100644 --- a/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java +++ b/src/com/sheepit/client/hardware/gpu/opencl/OpenCLLib.java @@ -32,6 +32,7 @@ public interface OpenCLLib extends Library { public static final int CL_DEVICE_NOT_FOUND = -1; public static final int CL_PLATFORM_VENDOR = 0x0903; + public static final int CL_PLATFORM_NAME = 0x0902; // cl_device_type public static final int CL_DEVICE_TYPE_DEFAULT = (1 << 0); @@ -43,8 +44,12 @@ public interface OpenCLLib extends Library { // cl_device_info 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_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);