summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-10-29 20:01:30 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-10-29 20:01:30 +0100
commitac5a58cfe5d2fad1ef248c619ad68611dcabcfc7 (patch)
tree41bc3ee816dd6cd56c958c52e2dcfb1af889cd1a
parent19c53f6dd06e1fc2b3f71ab738bd97af070fe627 (diff)
Added platform ID to the binary program cache to prevent issues with multi-platform systems
-rw-r--r--src/cache.hpp6
-rw-r--r--src/routine.cpp5
2 files changed, 6 insertions, 5 deletions
diff --git a/src/cache.hpp b/src/cache.hpp
index 1c8c9d4c..228fbccb 100644
--- a/src/cache.hpp
+++ b/src/cache.hpp
@@ -66,10 +66,10 @@ private:
// =================================================================================================
-// The key struct for the cache of compiled OpenCL binaries
+// The key struct for the cache of compiled OpenCL binaries (device name and platform-dependent)
// Order of fields: precision, routine_name, device_name (smaller fields first)
-typedef std::tuple<Precision, std::string, std::string> BinaryKey;
-typedef std::tuple<const Precision &, const std::string &, const std::string &> BinaryKeyRef;
+typedef std::tuple<RawPlatformID, Precision, std::string, std::string> BinaryKey;
+typedef std::tuple<const RawPlatformID &, const Precision &, const std::string &, const std::string &> BinaryKeyRef;
typedef Cache<BinaryKey, std::string> BinaryCache;
diff --git a/src/routine.cpp b/src/routine.cpp
index 0f9fe360..db9bafea 100644
--- a/src/routine.cpp
+++ b/src/routine.cpp
@@ -109,8 +109,9 @@ void Routine::InitProgram(std::initializer_list<const char *> source) {
// 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
const auto device_name = GetDeviceName(device_);
+ const auto platform_id = device_.PlatformID();
bool has_binary;
- auto binary = BinaryCache::Instance().Get(BinaryKeyRef{ precision_, routine_info, device_name },
+ auto binary = BinaryCache::Instance().Get(BinaryKeyRef{platform_id, precision_, routine_info, device_name },
&has_binary);
if (has_binary) {
program_ = Program(device_, context_, binary);
@@ -204,7 +205,7 @@ void Routine::InitProgram(std::initializer_list<const char *> source) {
}
// Store the compiled binary and program in the cache
- BinaryCache::Instance().Store(BinaryKey{precision_, routine_info, device_name},
+ BinaryCache::Instance().Store(BinaryKey{platform_id, precision_, routine_info, device_name},
program_.GetIR());
ProgramCache::Instance().Store(ProgramKey{context_(), device_(), precision_, routine_info},