summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG3
-rw-r--r--README.md2
-rw-r--r--src/routine.cpp10
3 files changed, 13 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1995dc84..e3feafb2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,7 @@
+Development version (next release)
+- It is now possible to set OpenCL compiler options through the env variable CLBLAST_BUILD_OPTIONS
+
Version 0.9.0
- Updated to version 6.0 of the CLCudaAPI C++11 OpenCL header
- Improved performance significantly of rotated GEMV computations
diff --git a/README.md b/README.md
index 7f6a3d96..025052a6 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,8 @@ Afterwards, any of CLBlast's routines can be called directly: there is no need t
cmake -DSAMPLES=ON ..
+Furthermore, it is possible to optionally set an OS environmental variable `CLBLAST_BUILD_OPTIONS` to pass specific build options to the OpenCL compiler.
+
Using the tuners (optional)
-------------
diff --git a/src/routine.cpp b/src/routine.cpp
index 189ae190..d938d66f 100644
--- a/src/routine.cpp
+++ b/src/routine.cpp
@@ -14,6 +14,7 @@
#include <string>
#include <vector>
#include <chrono>
+#include <cstdlib>
#include "routine.hpp"
@@ -42,13 +43,19 @@ StatusCode Routine::SetUp() {
// Queries the cache to see whether or not the program (context-specific) is already there
if (ProgramIsInCache(context_, precision_, routine_name_)) { return StatusCode::kSuccess; }
+ // Sets the build options from an environmental variable (if set)
+ auto options = std::vector<std::string>();
+ const auto environment_variable = std::getenv("CLBLAST_BUILD_OPTIONS");
+ if (environment_variable != nullptr) {
+ options.push_back(std::string(environment_variable));
+ }
+
// Queries the cache to see whether or not the binary (device-specific) is already there. If it
// is, a program is created and stored in the cache
if (BinaryIsInCache(device_name_, precision_, routine_name_)) {
try {
auto& binary = GetBinaryFromCache(device_name_, precision_, routine_name_);
auto program = Program(device_, context_, binary);
- auto options = std::vector<std::string>();
program.Build(device_, options);
StoreProgramToCache(program, context_, precision_, routine_name_);
} catch (...) { return StatusCode::kBuildProgramFailure; }
@@ -115,7 +122,6 @@ StatusCode Routine::SetUp() {
// Compiles the kernel
try {
auto program = Program(context_, source_string);
- auto options = std::vector<std::string>();
const auto build_status = program.Build(device_, options);
// Checks for compiler crashes/errors/warnings