summaryrefslogtreecommitdiff
path: root/src/utilities
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-09-10 16:34:54 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2017-09-10 16:34:54 +0200
commit76382ff6c1c882063bab761382438a24af4a87b5 (patch)
treea6c1feaf32c73eea91611b4564db61276cf2dd0d /src/utilities
parent91ea7fcde2ac274db50b35fbbdb7deb89fb65b51 (diff)
Added the new vendor-architecture-name hierarchy to the tuners as well
Diffstat (limited to 'src/utilities')
-rw-r--r--src/utilities/device_mapping.hpp51
-rw-r--r--src/utilities/utilities.cpp54
-rw-r--r--src/utilities/utilities.hpp8
3 files changed, 111 insertions, 2 deletions
diff --git a/src/utilities/device_mapping.hpp b/src/utilities/device_mapping.hpp
new file mode 100644
index 00000000..7fdc04a0
--- /dev/null
+++ b/src/utilities/device_mapping.hpp
@@ -0,0 +1,51 @@
+
+// =================================================================================================
+// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
+// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
+// width of 100 characters per line.
+//
+// Author(s):
+// Cedric Nugteren <www.cedricnugteren.nl>
+//
+// This file describes the mappings of extracted names from OpenCL (device, board, vendor, etc.) to
+// more commonly used names to match devices from different vendors and platforms properly.
+//
+// =================================================================================================
+
+#ifndef CLBLAST_UTILITIES_DEVICE_MAPPING_H_
+#define CLBLAST_UTILITIES_DEVICE_MAPPING_H_
+
+#include <string>
+#include <unordered_map>
+
+namespace clblast {
+// A special namespace to hold all the global constant variables
+namespace device_mapping {
+
+// =================================================================================================
+
+// Alternative names for some vendor names (top-level)
+const std::unordered_map<std::string, std::string> kVendorNames {
+ { "Intel(R) Corporation", "Intel" },
+ { "GenuineIntel", "Intel" },
+ { "Advanced Micro Devices, Inc.", "AMD" },
+ { "NVIDIA Corporation", "NVIDIA" },
+};
+
+// Alternative names for some architectures (mid-level)
+const std::unordered_map<std::string, std::string> kArchitectureNames {
+ {"gfx803", "Fiji"},
+ {"gfx900", "Vega"},
+};
+
+// Alternative names for some devices (low-level)
+const std::unordered_map<std::string, std::string> kDeviceNames {
+ // Empty
+};
+
+// =================================================================================================
+} // namespace device_mapping
+} // namespace clblast
+
+// CLBLAST_UTILITIES_DEVICE_MAPPING_H_
+#endif
diff --git a/src/utilities/utilities.cpp b/src/utilities/utilities.cpp
index 4ff419a5..4b8d5a09 100644
--- a/src/utilities/utilities.cpp
+++ b/src/utilities/utilities.cpp
@@ -11,8 +11,6 @@
//
// =================================================================================================
-#include "utilities/utilities.hpp"
-
#include <string>
#include <vector>
#include <chrono>
@@ -20,6 +18,10 @@
#include <iomanip>
#include <cmath>
+#include "utilities/utilities.hpp"
+
+#include "utilities/device_mapping.hpp"
+
namespace clblast {
// =================================================================================================
@@ -401,4 +403,52 @@ template <> bool PrecisionSupported<half>(const Device &device) {
}
// =================================================================================================
+
+// High-level info
+std::string GetDeviceType(const Device& device) {
+ return device.Type();
+}
+std::string GetDeviceVendor(const Device& device) {
+ auto device_vendor = device.Vendor();
+
+ for (auto &find_and_replace : device_mapping::kVendorNames) { // replacing to common names
+ if (device_vendor == find_and_replace.first) { device_vendor = find_and_replace.second; }
+ }
+ return device_vendor;
+}
+
+// Mid-level info
+std::string GetDeviceArchitecture(const Device& device) {
+ auto device_architecture = std::string{""};
+ if (device.HasExtension(kKhronosAttributesNVIDIA)) {
+ device_architecture = device.NVIDIAComputeCapability();
+ }
+ else if (device.HasExtension(kKhronosAttributesAMD)) {
+ device_architecture = device.Name(); // Name is architecture for AMD APP and AMD ROCm
+ }
+ // Note: no else - 'device_architecture' might be the empty string
+
+ for (auto &find_and_replace : device_mapping::kArchitectureNames) { // replacing to common names
+ if (device_architecture == find_and_replace.first) { device_architecture = find_and_replace.second; }
+ }
+ return device_architecture;
+}
+
+// Lowest-level
+std::string GetDeviceName(const Device& device) {
+ auto device_name = std::string{""};
+ if (device.HasExtension(kKhronosAttributesAMD)) {
+ device_name = device.AMDBoardName();
+ }
+ else {
+ device_name = device.Name();
+ }
+
+ for (auto &find_and_replace : device_mapping::kDeviceNames) { // replacing to common names
+ if (device_name == find_and_replace.first) { device_name = find_and_replace.second; }
+ }
+ return device_name;
+}
+
+// =================================================================================================
} // namespace clblast
diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp
index 3ffb3be5..d912a377 100644
--- a/src/utilities/utilities.hpp
+++ b/src/utilities/utilities.hpp
@@ -308,6 +308,14 @@ template <typename T>
bool PrecisionSupported(const Device &device);
// =================================================================================================
+
+// Device information in a specific CLBlast form
+std::string GetDeviceType(const Device& device);
+std::string GetDeviceVendor(const Device& device);
+std::string GetDeviceArchitecture(const Device& device);
+std::string GetDeviceName(const Device& device);
+
+// =================================================================================================
} // namespace clblast
// CLBLAST_UTILITIES_H_