summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/database/database.cpp9
-rw-r--r--src/database/database.hpp3
-rw-r--r--src/routine.cpp17
3 files changed, 23 insertions, 6 deletions
diff --git a/src/database/database.cpp b/src/database/database.cpp
index 64306c7b..836c8803 100644
--- a/src/database/database.cpp
+++ b/src/database/database.cpp
@@ -124,6 +124,15 @@ std::string Database::GetDefines() const {
return defines;
}
+// ... or just the values as string
+std::string Database::GetValuesString() const {
+ std::string defines{};
+ for (auto &parameter: *parameters_) {
+ defines += "_"+ToString(parameter.second);
+ }
+ return defines;
+}
+
// Retrieves the names of all the parameters
std::vector<std::string> Database::GetParameterNames() const {
auto parameter_names = std::vector<std::string>();
diff --git a/src/database/database.hpp b/src/database/database.hpp
index 4cb0bf6a..04e9f095 100644
--- a/src/database/database.hpp
+++ b/src/database/database.hpp
@@ -53,7 +53,8 @@ class Database {
// Obtain a list of OpenCL pre-processor defines based on the parameters
std::string GetDefines() const;
- // Retrieves the names of all the parameters
+ // Retrieves the values or names of all the parameters
+ std::string GetValuesString() const;
std::vector<std::string> GetParameterNames() const;
private:
diff --git a/src/routine.cpp b/src/routine.cpp
index c305feb8..4f0dd4d1 100644
--- a/src/routine.cpp
+++ b/src/routine.cpp
@@ -85,9 +85,16 @@ void Routine::InitDatabase(const std::vector<database::DatabaseEntry> &userDatab
void Routine::InitProgram(std::initializer_list<const char *> source) {
+ // Determines the identifier for this particular routine call
+ auto routine_info = routine_name_;
+ for (const auto &kernel_name : kernel_names_) {
+ routine_info += "_" + kernel_name + db_(kernel_name).GetValuesString();
+ }
+ log_debug(routine_info);
+
// Queries the cache to see whether or not the program (context-specific) is already there
bool has_program;
- program_ = ProgramCache::Instance().Get(ProgramKeyRef{ context_(), device_(), precision_, routine_name_ },
+ program_ = ProgramCache::Instance().Get(ProgramKeyRef{ context_(), device_(), precision_, routine_info },
&has_program);
if (has_program) { return; }
@@ -102,12 +109,12 @@ void Routine::InitProgram(std::initializer_list<const char *> source) {
// is, a program is created and stored in the cache
const auto device_name = GetDeviceName(device_);
bool has_binary;
- auto binary = BinaryCache::Instance().Get(BinaryKeyRef{ precision_, routine_name_, device_name },
+ auto binary = BinaryCache::Instance().Get(BinaryKeyRef{ precision_, routine_info, device_name },
&has_binary);
if (has_binary) {
program_ = Program(device_, context_, binary);
program_.Build(device_, options);
- ProgramCache::Instance().Store(ProgramKey{ context_(), device_(), precision_, routine_name_ },
+ ProgramCache::Instance().Store(ProgramKey{ context_(), device_(), precision_, routine_info },
Program{ program_ });
return;
}
@@ -189,10 +196,10 @@ void Routine::InitProgram(std::initializer_list<const char *> source) {
}
// Store the compiled binary and program in the cache
- BinaryCache::Instance().Store(BinaryKey{ precision_, routine_name_, device_name },
+ BinaryCache::Instance().Store(BinaryKey{precision_, routine_info, device_name},
program_.GetIR());
- ProgramCache::Instance().Store(ProgramKey{ context_(), device_(), precision_, routine_name_ },
+ ProgramCache::Instance().Store(ProgramKey{context_(), device_(), precision_, routine_info},
Program{ program_ });
// Prints the elapsed compilation time in case of debugging in verbose mode