summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-07-08 20:57:58 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2016-07-08 20:57:58 +0200
commit9caa7ca5b9c1fdf99473582cd357506dffd51b44 (patch)
tree71dd1f99863f57a4d0a947a925b4e9755eaf4ae5
parent27854070b4f9ba1d58ccd7189032e56325506597 (diff)
Cache now compares cl_context instead of a pointer to a context; added verbose print statements to the cache
-rw-r--r--CHANGELOG1
-rw-r--r--src/cache.cpp12
-rw-r--r--src/cache.hpp2
3 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 15948bbd..248db397 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ Development version (next release)
- Fixed proper MSVC dllimport and dllexport declarations
- Fixed memory leaks related to events not being released
- Fixed a bug with a size_t and cl_ulong mismatch on 32-bit systems
+- Fixed a bug related to the cache and retrieval of programs based on the OpenCL context
- Added an option (-warm_up) to do a warm-up run before timing in the performance clients
- Added tuned parameters for various devices (see README)
diff --git a/src/cache.cpp b/src/cache.cpp
index cd9055d0..2b90eccc 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,6 +34,9 @@ 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_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,6 +64,9 @@ 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)) {
diff --git a/src/cache.hpp b/src/cache.hpp
index 0d74d7bc..8f540891 100644
--- a/src/cache.hpp
+++ b/src/cache.hpp
@@ -55,7 +55,7 @@ struct ProgramCache {
// Finds out whether the properties match
bool MatchInCache(const ContextPointer ref_context, const Precision &ref_precision,
const std::string &ref_routine) {
- return (context_ptr == ref_context &&
+ return (*context_ptr == *ref_context &&
precision == ref_precision &&
routine_name_ == ref_routine);
}