diff --git a/include/boost/compute/program.hpp b/include/boost/compute/program.hpp index 0daf5e2ab..61f3594c0 100644 --- a/include/boost/compute/program.hpp +++ b/include/boost/compute/program.hpp @@ -505,19 +505,24 @@ class program { #ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE // Get hash string for the kernel. - std::string hash; - { - device d(context.get_device()); - platform p = d.platform(); - - std::ostringstream src; - src << "// " << p.name() << " v" << p.version() << "\n" - << "// " << context.get_device().name() << "\n" - << "// " << options << "\n\n" - << source; - - hash = detail::sha1(src.str()); - } + // std::string hash; + // { + // device d(context.get_device()); + // platform p = d.platform(); + + // std::ostringstream src; + // src << "// " << p.name() << " v" << p.version() << "\n" + // << "// " << context.get_device().name() << "\n" + // << "// " << options << "\n\n" + // << source; + // } + + boost::detail::sha1 hash; + hash(p.name()); + hash(p.version()); + hash(context.get_device().name()); + hash(options); + hash(source); // Try to get cached program binaries: try { diff --git a/include/boost/compute/utility/program_cache.hpp b/include/boost/compute/utility/program_cache.hpp index ce29f1fa2..b9a2be54a 100644 --- a/include/boost/compute/utility/program_cache.hpp +++ b/include/boost/compute/utility/program_cache.hpp @@ -82,6 +82,35 @@ class program_cache : boost::noncopyable m_cache.clear(); } + /// Clears persistent cache by deleting the boost_compute folder + static void clear_persistent_cache() + { +#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE + // Path delimiter symbol for the current OS. + static const std::string delim = boost::filesystem::path("/").make_preferred().string(); + + // Path to appdata folder. +#ifdef WIN32 + static const std::string appdata = detail::getenv("APPDATA") + + delim + "boost_compute"; +#else + static const std::string appdata = detail::getenv("HOME") + + delim + ".boost_compute"; +#endif + try + { + if(boost::filesystem::exists(appdata)) + { + boost::filesystem::remove_all(appdata); + } + } + catch(boost::filesystem::filesystem_error const & err) + { + std::cout< get(const std::string &key)