summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-02-07 11:59:30 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2016-02-07 11:59:30 +0100
commit00be6f7530a16eb17f367b45d498e1e483b61b8d (patch)
tree47da8a24c723a0c1a583400af95d657d5b7ada59
parentc76f1d9dbb77746012c688a8d60ed45559ad0a4a (diff)
Added dictionary with short and long OpenCL vendor names to fix issues with Intel having multiple names
-rw-r--r--include/internal/database.h11
-rw-r--r--scripts/database/database.py28
-rw-r--r--src/database.cc14
3 files changed, 46 insertions, 7 deletions
diff --git a/include/internal/database.h b/include/internal/database.h
index 9107f978..08e449fa 100644
--- a/include/internal/database.h
+++ b/include/internal/database.h
@@ -57,6 +57,17 @@ class Database {
// The OpenCL device vendors
static constexpr auto kDeviceVendorAll = "default";
+ static constexpr auto kDeviceVendorIntel = "Intel";
+ static constexpr auto kDeviceVendorAMD = "AMD";
+ static constexpr auto kDeviceVendorNVIDIA = "NVIDIA";
+
+ // Alternative names for the above vendors
+ const std::unordered_map<std::string,std::string> kVendorNames {
+ {"Intel(R) Corporation", kDeviceVendorIntel},
+ {"GenuineIntel", kDeviceVendorIntel},
+ {"Advanced Micro Devices, Inc.", kDeviceVendorAMD},
+ {"NVIDIA Corporation", kDeviceVendorNVIDIA},
+ };
// The database consists of separate database entries, stored together in a vector
static const DatabaseEntry XaxpySingle, XaxpyDouble, XaxpyComplexSingle, XaxpyComplexDouble;
diff --git a/scripts/database/database.py b/scripts/database/database.py
index 758fdbab..89fe8286 100644
--- a/scripts/database/database.py
+++ b/scripts/database/database.py
@@ -38,6 +38,14 @@ KERNEL_ATTRIBUTES = ["precision", "kernel_family",
"arg_m", "arg_n", "arg_k", "arg_alpha", "arg_beta"]
ATTRIBUTES = DEVICE_ATTRIBUTES + DEVICETYPE_ATTRIBUTES + KERNEL_ATTRIBUTES
+# OpenCL vendor names and their short name
+VENDOR_NAMES = { "device_vendor": {
+ "GenuineIntel": "Intel",
+ "Intel(R) Corporation": "Intel",
+ "Advanced Micro Devices, Inc.": "AMD",
+ "NVIDIA Corporation": "NVIDIA",
+}}
+
# Pandas options
pd.set_option('display.width', 1000)
@@ -91,6 +99,11 @@ def RemoveEntriesByDevice(df, devicename):
def GetEntriesByField(df, field, value):
return df[df[field] == value]
+# Fixes the problem that some vendors use multiple different names
+def SanitizeVendorNames(df):
+ df = df.replace(VENDOR_NAMES)
+ return df
+
# Retrieves the results with the lowest execution times
def GetBestResults(df):
dfbest = pd.DataFrame()
@@ -175,7 +188,7 @@ def GetPrecision(family, precision):
def GetDeviceVendor(vendor, devtype):
if vendor == VENDOR_DEFAULT and devtype == DEVICETYPE_DEFAULT:
return(" { // Default\n kDeviceType%s, \"%s\", {\n" % (devtype, vendor))
- return(" { // %s %ss\n kDeviceType%s, \"%s\", {\n" % (vendor, devtype, devtype, vendor))
+ return(" { // %s %ss\n kDeviceType%s, \"%s\", {\n" % (vendor, devtype, devtype[0].upper() + devtype[1:], vendor))
# Prints the data to a C++ database
def PrintData(df, outputdir):
@@ -243,6 +256,7 @@ if not db_exists:
DownloadDatabase(file_db)
# Loads the database from disk
+print("## Loading the database from disk...")
database = LoadDatabase(file_db)
# Loops over all JSON files in the supplied folder
@@ -259,10 +273,14 @@ for file_json in glob.glob(glob_json):
new_size = len(database.index)
print("with "+str(new_size-old_size)+" new items")
-# Stores the new database back to disk
-SaveDatabase(database, file_db)
+ database = SanitizeVendorNames(database)
+
+ # Stores the modified database back to disk
+ print("## Storing the database to disk...")
+ SaveDatabase(database, file_db)
# Retrieves the best performing results
+print("## Calculting the best results per device/kernel...")
bests = GetBestResults(database)
# Determines the defaults for other vendors and per vendor
@@ -271,7 +289,9 @@ bests = ConcatenateData(bests, defaults)
# Outputs the data as a C++ database
path_cpp_database = os.path.join(path_clblast, "include", "internal", "database")
-print("## Producing a C++ database in '"+path_cpp_database+"'")
+print("## Producing a C++ database in '"+path_cpp_database+"'...")
PrintData(bests, path_cpp_database)
+print("## All done")
+
# ==================================================================================================
diff --git a/src/database.cc b/src/database.cc
index 7f5ac6eb..ba0a56d9 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -77,15 +77,23 @@ Database::Parameters Database::Search(const std::string &this_kernel,
const std::string &this_vendor,
const std::string &this_device,
const Precision this_precision) const {
- for (auto &db: database) {
+ // Set the short vendor name
+ auto this_short_vendor = this_vendor;
+ for (auto &combination : kVendorNames) {
+ if (this_vendor == combination.first) {
+ this_short_vendor = combination.second;
+ }
+ }
+ // Selects the right kernel
+ for (auto &db: database) {
if (db.kernel == this_kernel && db.precision == this_precision) {
// Searches for the right vendor and device type, or selects the default if unavailable. This
// assumes that the default vendor / device type is last in the database.
for (auto &vendor: db.vendors) {
- if ((vendor.name == this_vendor || vendor.name == kDeviceVendorAll) &&
- (vendor.type == this_type || vendor.type == kDeviceTypeAll)) {
+ if ((vendor.name == this_short_vendor || vendor.name == kDeviceVendorAll) &&
+ (vendor.type == this_type || vendor.type == kDeviceTypeAll)) {
// Searches for the right device. If the current device is unavailable, selects the vendor
// default parameters. This assumes the default is last in the database.