summaryrefslogtreecommitdiff
path: root/src/cache.cpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-09-13 21:14:51 +0200
committerGitHub <noreply@github.com>2016-09-13 21:14:51 +0200
commitf07ac22f5b57d22756d779d2e53620f988d786ee (patch)
treee8bcbc331683ca6fd807f5a5b83bb05c6e6fed69 /src/cache.cpp
parent7c13bacf129291e3e295ecb6e833788477085fa0 (diff)
parent4b94afda941a86f363064ff02f97e21eb9618794 (diff)
Merge pull request #99 from CNugteren/development
Update to version 0.9.0
Diffstat (limited to 'src/cache.cpp')
-rw-r--r--src/cache.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/cache.cpp b/src/cache.cpp
index cd9055d0..6080f082 100644
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -23,6 +23,9 @@ namespace clblast {
// Stores the compiled binary or IR in the cache
void StoreBinaryToCache(const std::string &binary, const std::string &device_name,
const Precision &precision, const std::string &routine_name) {
+ #ifdef VERBOSE
+ printf("[DEBUG] Storing binary in cache\n");
+ #endif
binary_cache_mutex_.lock();
binary_cache_.push_back(BinaryCache{binary, device_name, precision, routine_name});
binary_cache_mutex_.unlock();
@@ -31,8 +34,11 @@ void StoreBinaryToCache(const std::string &binary, const std::string &device_nam
// Stores the compiled program in the cache
void StoreProgramToCache(const Program &program, const Context &context,
const Precision &precision, const std::string &routine_name) {
+ #ifdef VERBOSE
+ printf("[DEBUG] Storing program in cache\n");
+ #endif
program_cache_mutex_.lock();
- program_cache_.push_back(ProgramCache{program, context.pointer(), precision, routine_name});
+ program_cache_.push_back(ProgramCache{program, context(), precision, routine_name});
program_cache_mutex_.unlock();
}
@@ -40,6 +46,9 @@ void StoreProgramToCache(const Program &program, const Context &context,
// otherwise.
const std::string& GetBinaryFromCache(const std::string &device_name, const Precision &precision,
const std::string &routine_name) {
+ #ifdef VERBOSE
+ printf("[DEBUG] Retrieving binary from cache\n");
+ #endif
binary_cache_mutex_.lock();
for (auto &cached_binary: binary_cache_) {
if (cached_binary.MatchInCache(device_name, precision, routine_name)) {
@@ -55,9 +64,12 @@ const std::string& GetBinaryFromCache(const std::string &device_name, const Prec
// otherwise.
const Program& GetProgramFromCache(const Context &context, const Precision &precision,
const std::string &routine_name) {
+ #ifdef VERBOSE
+ printf("[DEBUG] Retrieving program from cache\n");
+ #endif
program_cache_mutex_.lock();
for (auto &cached_program: program_cache_) {
- if (cached_program.MatchInCache(context.pointer(), precision, routine_name)) {
+ if (cached_program.MatchInCache(context(), precision, routine_name)) {
program_cache_mutex_.unlock();
return cached_program.program;
}
@@ -85,7 +97,7 @@ bool ProgramIsInCache(const Context &context, const Precision &precision,
const std::string &routine_name) {
program_cache_mutex_.lock();
for (auto &cached_program: program_cache_) {
- if (cached_program.MatchInCache(context.pointer(), precision, routine_name)) {
+ if (cached_program.MatchInCache(context(), precision, routine_name)) {
program_cache_mutex_.unlock();
return true;
}