summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api_common.cpp28
-rw-r--r--src/database/database.hpp1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/api_common.cpp b/src/api_common.cpp
index 0d387cd9..4e08f1ef 100644
--- a/src/api_common.cpp
+++ b/src/api_common.cpp
@@ -112,6 +112,34 @@ StatusCode FillCache(const RawDeviceID device) {
// =================================================================================================
+// Retrieves the current tuning parameters for this device-precision-kernel combination
+StatusCode RetrieveParameters(const RawDeviceID device, const std::string &kernel_name,
+ const Precision precision,
+ std::unordered_map<std::string,size_t> &parameters) {
+ try {
+
+ // Retrieves the device name
+ const auto device_cpp = Device(device);
+ const auto platform_id = device_cpp.PlatformID();
+ const auto device_name = GetDeviceName(device_cpp);
+
+ // Retrieves the database values
+ auto in_cache = false;
+ auto database = DatabaseCache::Instance().Get(DatabaseKeyRef{platform_id, device, precision, kernel_name}, &in_cache);
+ if (!in_cache) {
+ log_debug("Searching database for kernel '" + kernel_name + "'");
+ database = Database(device_cpp, kernel_name, precision, {});
+ }
+
+ // Retrieves the parameters
+ for (const auto &parameter: database.GetParameters()) {
+ parameters[parameter.first] = parameter.second;
+ }
+
+ } catch (...) { return DispatchException(); }
+ return StatusCode::kSuccess;
+}
+
// Overrides the tuning parameters for this device-precision-kernel combination
StatusCode OverrideParameters(const RawDeviceID device, const std::string &kernel_name,
const Precision precision,
diff --git a/src/database/database.hpp b/src/database/database.hpp
index 8e53e013..1db2c286 100644
--- a/src/database/database.hpp
+++ b/src/database/database.hpp
@@ -56,6 +56,7 @@ class Database {
// Retrieves the values or names of all the parameters
std::string GetValuesString() const;
std::vector<std::string> GetParameterNames() const;
+ const database::Parameters& GetParameters() const { return *parameters_; }
private:
// Search method functions, returning a set of parameters (possibly empty)