diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2016-09-21 21:22:16 +0200 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2016-09-21 21:22:16 +0200 |
commit | b1929d8ce7022cacbd1812d62098ebd0681bc1ef (patch) | |
tree | 8c98a5f73835a1943519784112d48d31757ac8f6 /src/routine.cpp | |
parent | 63003a1429d22309345bffd9fecded59db5698c2 (diff) |
It is now possible to set the OpenCL compiler options through an environmental variable
Diffstat (limited to 'src/routine.cpp')
-rw-r--r-- | src/routine.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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 |