Added a function to set the OpenCL kernel standard, either 1.1 or 1.2
parent
9cbffc9b7c
commit
af6a9eedd1
|
@ -485,7 +485,6 @@ class Program {
|
||||||
|
|
||||||
// Compiles the device program and checks whether or not there are any warnings/errors
|
// Compiles the device program and checks whether or not there are any warnings/errors
|
||||||
void Build(const Device &device, std::vector<std::string> &options) {
|
void Build(const Device &device, std::vector<std::string> &options) {
|
||||||
options.push_back("-cl-std=CL1.1");
|
|
||||||
auto options_string = std::accumulate(options.begin(), options.end(), std::string{" "});
|
auto options_string = std::accumulate(options.begin(), options.end(), std::string{" "});
|
||||||
const cl_device_id dev = device();
|
const cl_device_id dev = device();
|
||||||
CheckError(clBuildProgram(program_, 1, &dev, options_string.c_str(), nullptr, nullptr));
|
CheckError(clBuildProgram(program_, 1, &dev, options_string.c_str(), nullptr, nullptr));
|
||||||
|
|
|
@ -97,6 +97,7 @@ void Routine::InitProgram(std::initializer_list<const char *> source) {
|
||||||
&has_binary);
|
&has_binary);
|
||||||
if (has_binary) {
|
if (has_binary) {
|
||||||
program_ = std::make_shared<Program>(device_, context_, binary);
|
program_ = std::make_shared<Program>(device_, context_, binary);
|
||||||
|
SetOpenCLKernelStandard(device_, options);
|
||||||
program_->Build(device_, options);
|
program_->Build(device_, options);
|
||||||
ProgramCache::Instance().Store(ProgramKey{ context_(), device_(), precision_, routine_info },
|
ProgramCache::Instance().Store(ProgramKey{ context_(), device_(), precision_, routine_info },
|
||||||
std::shared_ptr<Program>{program_});
|
std::shared_ptr<Program>{program_});
|
||||||
|
|
|
@ -111,6 +111,7 @@ std::shared_ptr<Program> CompileFromSource(
|
||||||
// Compiles the kernel
|
// Compiles the kernel
|
||||||
auto program = std::make_shared<Program>(context, kernel_string);
|
auto program = std::make_shared<Program>(context, kernel_string);
|
||||||
try {
|
try {
|
||||||
|
SetOpenCLKernelStandard(device, options);
|
||||||
program->Build(device, options);
|
program->Build(device, options);
|
||||||
} catch (const CLCudaAPIBuildError &e) {
|
} catch (const CLCudaAPIBuildError &e) {
|
||||||
if (program->StatusIsCompilationWarningOrError(e.status()) && !silent) {
|
if (program->StatusIsCompilationWarningOrError(e.status()) && !silent) {
|
||||||
|
|
|
@ -498,6 +498,19 @@ std::string GetDeviceName(const Device& device) {
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
|
void SetOpenCLKernelStandard(const Device &device, std::vector<std::string> &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
|
// Solve Bezout's identity
|
||||||
// a * p + b * q = r = GCD(a, b)
|
// a * p + b * q = r = GCD(a, b)
|
||||||
void EuclidGCD(int a, int b, int &p, int &q, int &r) {
|
void EuclidGCD(int a, int b, int &p, int &q, int &r) {
|
||||||
|
|
|
@ -375,6 +375,10 @@ std::string GetDeviceName(const Device& device);
|
||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
|
void SetOpenCLKernelStandard(const Device &device, std::vector<std::string> &options);
|
||||||
|
|
||||||
|
// =================================================================================================
|
||||||
|
|
||||||
// Solve Bezout's identity
|
// Solve Bezout's identity
|
||||||
// a * p + b * q = r = GCD(a, b)
|
// a * p + b * q = r = GCD(a, b)
|
||||||
void EuclidGCD(int a, int b, int &p, int &q, int &r);
|
void EuclidGCD(int a, int b, int &p, int &q, int &r);
|
||||||
|
|
Loading…
Reference in New Issue