From af6a9eedd118b0e3d7f1a2098c10ff90b27b5d0e Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sat, 11 May 2019 20:39:00 +0200 Subject: Added a function to set the OpenCL kernel standard, either 1.1 or 1.2 --- src/utilities/compile.cpp | 1 + src/utilities/utilities.cpp | 13 +++++++++++++ src/utilities/utilities.hpp | 4 ++++ 3 files changed, 18 insertions(+) (limited to 'src/utilities') diff --git a/src/utilities/compile.cpp b/src/utilities/compile.cpp index 00cb90cb..aeb7a3e2 100644 --- a/src/utilities/compile.cpp +++ b/src/utilities/compile.cpp @@ -111,6 +111,7 @@ std::shared_ptr CompileFromSource( // Compiles the kernel auto program = std::make_shared(context, kernel_string); try { + SetOpenCLKernelStandard(device, options); program->Build(device, options); } catch (const CLCudaAPIBuildError &e) { if (program->StatusIsCompilationWarningOrError(e.status()) && !silent) { diff --git a/src/utilities/utilities.cpp b/src/utilities/utilities.cpp index a0e89c98..29161e74 100644 --- a/src/utilities/utilities.cpp +++ b/src/utilities/utilities.cpp @@ -498,6 +498,19 @@ std::string GetDeviceName(const Device& device) { // ================================================================================================= +void SetOpenCLKernelStandard(const Device &device, std::vector &options) { + // Inclusion of one of the following extensions needs OpenCL 1.2 kernels + if (device.HasExtension(kKhronosIntelSubgroups)) { + options.push_back("-cl-std=CL1.2"); + } + // Otherwise we fall-back to the default CLBlast OpenCL 1.1 + else { + options.push_back("-cl-std=CL1.1"); + } +} + +// ================================================================================================= + // Solve Bezout's identity // a * p + b * q = r = GCD(a, b) void EuclidGCD(int a, int b, int &p, int &q, int &r) { diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp index 23486d35..b66df118 100644 --- a/src/utilities/utilities.hpp +++ b/src/utilities/utilities.hpp @@ -375,6 +375,10 @@ std::string GetDeviceName(const Device& device); // ================================================================================================= +void SetOpenCLKernelStandard(const Device &device, std::vector &options); + +// ================================================================================================= + // Solve Bezout's identity // a * p + b * q = r = GCD(a, b) void EuclidGCD(int a, int b, int &p, int &q, int &r); -- cgit v1.2.3