From 52f2662f8293487044bc61e20c89b0b122dc1c26 Mon Sep 17 00:00:00 2001 From: Juan Fumero Date: Tue, 13 Aug 2024 16:25:41 +0200 Subject: [PATCH 1/2] Fix ComputeAorta/OCK thread scheduler for the OpenCL backend --- .../opencl/scheduler/OCLScheduler.java | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java b/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java index d3563ff5b6..e87017f4ff 100644 --- a/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java +++ b/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java @@ -31,8 +31,27 @@ public class OCLScheduler { - private static final String AMD_VENDOR = "Advanced Micro Devices"; - private static final String NVIDIA = "NVIDIA"; + /** + * Supported Vendors for specific Thread-Schedulers + */ + public enum SUPPORTED_VENDORS { + AMD("Advanced Micro Devices"), // + CODEPLAY("Codeplay"), // + INTEL("Intel"), // + NVIDIA("NVIDIA"), // + XILINX("Xilinx"); + + private String name; + + SUPPORTED_VENDORS(String name) { + this.name = name; + } + + String getName() { + return this.name; + } + } + private static final int NVIDIA_MAJOR_VERSION_GENERIC_SCHEDULER = 550; private static final int NVIDIA_MINOR_VERSION_GENERIC_SCHEDULER = 67; @@ -45,9 +64,9 @@ private static boolean isDriverVersionCompatible(OCLTargetDevice device) { private static OCLKernelScheduler getInstanceGPUScheduler(final OCLDeviceContext context) { OCLTargetDevice device = context.getDevice(); - if (device.getDeviceVendor().contains(AMD_VENDOR)) { + if (device.getDeviceVendor().contains(SUPPORTED_VENDORS.AMD.getName())) { return new OCLAMDScheduler(context); - } else if (device.getDeviceVendor().contains(NVIDIA)) { + } else if (device.getDeviceVendor().contains(SUPPORTED_VENDORS.NVIDIA.getName())) { if (isDriverVersionCompatible(device)) { return new OCLNVIDIAGPUScheduler(context); } else { @@ -62,8 +81,15 @@ public static OCLKernelScheduler instanceScheduler(OCLDeviceType type, final OCL switch (type) { case CL_DEVICE_TYPE_GPU: return getInstanceGPUScheduler(context); - case CL_DEVICE_TYPE_ACCELERATOR: - return context.isPlatformFPGA() ? new OCLFPGAScheduler(context) : new OCLCPUScheduler(context); + case CL_DEVICE_TYPE_ACCELERATOR: { + if (context.getDevice().getDeviceVendor().contains(SUPPORTED_VENDORS.CODEPLAY.getName())) { + return getInstanceGPUScheduler(context); + } else if (context.isPlatformFPGA()) { + return new OCLFPGAScheduler(context); + } else { + return new OCLCPUScheduler(context); + } + } case CL_DEVICE_TYPE_CPU: return TornadoOptions.USE_BLOCK_SCHEDULER ? new OCLCPUScheduler(context) : getInstanceGPUScheduler(context); default: From dd7c9065c341726b98f650b2c1938ef1cfd6380f Mon Sep 17 00:00:00 2001 From: Juan Fumero Date: Tue, 13 Aug 2024 16:52:59 +0200 Subject: [PATCH 2/2] minor change --- .../drivers/opencl/scheduler/OCLScheduler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java b/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java index e87017f4ff..7f88208b14 100644 --- a/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java +++ b/tornado-drivers/opencl/src/main/java/uk/ac/manchester/tornado/drivers/opencl/scheduler/OCLScheduler.java @@ -79,9 +79,10 @@ private static OCLKernelScheduler getInstanceGPUScheduler(final OCLDeviceContext public static OCLKernelScheduler instanceScheduler(OCLDeviceType type, final OCLDeviceContext context) { switch (type) { - case CL_DEVICE_TYPE_GPU: + case CL_DEVICE_TYPE_GPU -> { return getInstanceGPUScheduler(context); - case CL_DEVICE_TYPE_ACCELERATOR: { + } + case CL_DEVICE_TYPE_ACCELERATOR -> { if (context.getDevice().getDeviceVendor().contains(SUPPORTED_VENDORS.CODEPLAY.getName())) { return getInstanceGPUScheduler(context); } else if (context.isPlatformFPGA()) { @@ -90,11 +91,10 @@ public static OCLKernelScheduler instanceScheduler(OCLDeviceType type, final OCL return new OCLCPUScheduler(context); } } - case CL_DEVICE_TYPE_CPU: + case CL_DEVICE_TYPE_CPU -> { return TornadoOptions.USE_BLOCK_SCHEDULER ? new OCLCPUScheduler(context) : getInstanceGPUScheduler(context); - default: - new TornadoLogger().fatal("No scheduler available for device: %s", context); - break; + } + default -> new TornadoLogger().fatal("No scheduler available for device: %s", context); } return null; }