diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2018-01-11 20:32:06 +0100 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2018-01-11 20:32:06 +0100 |
commit | a500f537d8281ad32e2eb07016b9de78c946ec50 (patch) | |
tree | dc5a06480fe1b6c3f4b9c65b8dd69e87ea65520a /src/api_common.cpp | |
parent | 389919faec965e81a0196bb8260c7a77926b4edc (diff) |
Added a RetrieveParameters function to inspect tuning parameters
Diffstat (limited to 'src/api_common.cpp')
-rw-r--r-- | src/api_common.cpp | 28 |
1 files changed, 28 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> ¶meters) { + 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 ¶meter: 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, |