summaryrefslogtreecommitdiff
path: root/src/cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.cc')
-rw-r--r--src/cache.cc56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/cache.cc b/src/cache.cc
index beeb1b35..18731a51 100644
--- a/src/cache.cc
+++ b/src/cache.cc
@@ -21,50 +21,50 @@ namespace clblast {
namespace cache {
// =================================================================================================
-// Stores the compiled program in the cache
-void StoreProgramToCache(const Program& program, const std::string &device_name,
- const Precision &precision, const std::string &routine_name) {
- program_cache_mutex_.lock();
- program_cache_.push_back({program, device_name, precision, routine_name});
- program_cache_mutex_.unlock();
+// 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) {
+ binary_cache_mutex_.lock();
+ binary_cache_.push_back({binary, device_name, precision, routine_name});
+ binary_cache_mutex_.unlock();
}
-// Queries the cache and retrieves a matching program. Assumes that the match is available, throws
+// Queries the cache and retrieves a matching binary. Assumes that the match is available, throws
// otherwise.
-const Program& GetProgramFromCache(const std::string &device_name, const Precision &precision,
- const std::string &routine_name) {
- program_cache_mutex_.lock();
- for (auto &cached_program: program_cache_) {
- if (cached_program.MatchInCache(device_name, precision, routine_name)) {
- program_cache_mutex_.unlock();
- return cached_program.program;
+const std::string& GetBinaryFromCache(const std::string &device_name, const Precision &precision,
+ const std::string &routine_name) {
+ binary_cache_mutex_.lock();
+ for (auto &cached_binary: binary_cache_) {
+ if (cached_binary.MatchInCache(device_name, precision, routine_name)) {
+ binary_cache_mutex_.unlock();
+ return cached_binary.binary;
}
}
- program_cache_mutex_.unlock();
- throw std::runtime_error("Internal CLBlast error: Expected program in cache, but found none.");
+ binary_cache_mutex_.unlock();
+ throw std::runtime_error("Internal CLBlast error: Expected binary in cache, but found none.");
}
// Queries the cache to see whether or not the compiled kernel is already there
-bool ProgramIsInCache(const std::string &device_name, const Precision &precision,
- const std::string &routine_name) {
- program_cache_mutex_.lock();
- for (auto &cached_program: program_cache_) {
- if (cached_program.MatchInCache(device_name, precision, routine_name)) {
- program_cache_mutex_.unlock();
+bool BinaryIsInCache(const std::string &device_name, const Precision &precision,
+ const std::string &routine_name) {
+ binary_cache_mutex_.lock();
+ for (auto &cached_binary: binary_cache_) {
+ if (cached_binary.MatchInCache(device_name, precision, routine_name)) {
+ binary_cache_mutex_.unlock();
return true;
}
}
- program_cache_mutex_.unlock();
+ binary_cache_mutex_.unlock();
return false;
}
// =================================================================================================
-// Clears the cache of stored program binaries
-StatusCode ClearCompiledProgramCache() {
- program_cache_mutex_.lock();
- program_cache_.clear();
- program_cache_mutex_.unlock();
+// Clears the cache of stored binaries
+StatusCode ClearCache() {
+ binary_cache_mutex_.lock();
+ binary_cache_.clear();
+ binary_cache_mutex_.unlock();
return StatusCode::kSuccess;
}