@@ -45,7 +45,7 @@ namespace miopen {
4545
4646MIOPEN_DECLARE_ENV_VAR (MIOPEN_DISABLE_CACHE )
4747
48- boost::filesystem::path ComputeSysCachePath ()
48+ static boost::filesystem::path ComputeSysCachePath ()
4949{
5050 std::string cache_dir = GetSystemDbPath ();
5151 auto p = boost::filesystem::path{miopen::ExpandUser (cache_dir)};
@@ -55,7 +55,7 @@ boost::filesystem::path ComputeSysCachePath()
5555 return p;
5656}
5757
58- boost::filesystem::path ComputeUserCachePath ()
58+ static boost::filesystem::path ComputeUserCachePath ()
5959{
6060#ifdef MIOPEN_CACHE_DIR
6161 std::string cache_dir = MIOPEN_CACHE_DIR ;
@@ -73,6 +73,7 @@ boost::filesystem::path ComputeUserCachePath()
7373#endif
7474}
7575
76+ #if !MIOPEN_ENABLE_SQLITE_KERN_CACHE
7677boost::filesystem::path GetCachePath (bool is_system)
7778{
7879 static const boost::filesystem::path user_path = ComputeUserCachePath ();
@@ -82,8 +83,9 @@ boost::filesystem::path GetCachePath(bool is_system)
8283 else
8384 return user_path;
8485}
86+ #endif // !MIOPEN_ENABLE_SQLITE_KERN_CACHE
8587
86- bool IsCacheDisabled ()
88+ static bool IsCacheDisabled ()
8789{
8890#ifdef MIOPEN_CACHE_DIR
8991 return miopen::IsEnabled (MIOPEN_DISABLE_CACHE {});
@@ -106,6 +108,8 @@ KDb GetDb(const std::string& device, size_t num_cu)
106108 sys_path = boost::filesystem::path{};
107109 return {sys_path.string (), user_path.string (), device, num_cu};
108110}
111+
112+ #if !MIOPEN_ENABLE_SQLITE_KERN_CACHE
109113boost::filesystem::path GetCacheFile (const std::string& device,
110114 const std::string& name,
111115 const std::string& args,
@@ -114,7 +118,9 @@ boost::filesystem::path GetCacheFile(const std::string& device,
114118 std::string filename = (is_kernel_str ? miopen::md5 (name) : name) + " .o" ;
115119 return GetCachePath (false ) / miopen::md5 (device + " :" + args) / filename;
116120}
121+ #endif
117122
123+ #if MIOPEN_ENABLE_SQLITE_KERN_CACHE
118124std::string LoadBinary (const std::string& device,
119125 const size_t num_cu,
120126 const std::string& name,
@@ -124,7 +130,6 @@ std::string LoadBinary(const std::string& device,
124130 if (miopen::IsCacheDisabled ())
125131 return {};
126132
127- #if MIOPEN_ENABLE_SQLITE_KERN_CACHE
128133 auto db = GetDb (device, num_cu);
129134 std::string filename = (is_kernel_str ? miopen::md5 (name) : name) + " .o" ;
130135 KernelConfig cfg{filename, args, " " };
@@ -134,20 +139,8 @@ std::string LoadBinary(const std::string& device,
134139 return record.get ();
135140 else
136141 return {};
137- #else
138- (void )num_cu;
139- auto f = GetCacheFile (device, name, args, is_kernel_str);
140- if (boost::filesystem::exists (f))
141- {
142- return f.string ();
143- }
144- else
145- {
146- return {};
147- }
148- #endif
149142}
150- # if MIOPEN_ENABLE_SQLITE_KERN_CACHE
143+
151144void SaveBinary (const std::string& hsaco,
152145 const std::string& device,
153146 const std::size_t num_cu,
@@ -166,6 +159,27 @@ void SaveBinary(const std::string& hsaco,
166159 db.StoreRecord (cfg);
167160}
168161#else
162+ boost::filesystem::path LoadBinary (const std::string& device,
163+ const size_t num_cu,
164+ const std::string& name,
165+ const std::string& args,
166+ bool is_kernel_str)
167+ {
168+ if (miopen::IsCacheDisabled ())
169+ return {};
170+
171+ (void )num_cu;
172+ auto f = GetCacheFile (device, name, args, is_kernel_str);
173+ if (boost::filesystem::exists (f))
174+ {
175+ return f.string ();
176+ }
177+ else
178+ {
179+ return {};
180+ }
181+ }
182+
169183void SaveBinary (const boost::filesystem::path& binary_path,
170184 const std::string& device,
171185 const std::string& name,
0 commit comments