File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
backends/vulkan/runtime/vk_api Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1212
1313#include < executorch/backends/vulkan/runtime/vk_api/Exception.h>
1414
15+ #include < algorithm>
1516#include < bitset>
17+ #include < cctype>
1618#include < cstring>
1719
1820namespace vkcompute {
@@ -40,7 +42,9 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
4042 has_unified_memory (false ),
4143 has_timestamps (false ),
4244 timestamp_period (0 ),
43- min_ubo_alignment (0 ) {
45+ min_ubo_alignment (0 ),
46+ device_name{},
47+ device_type{DeviceType::UNKNOWN} {
4448 // Extract physical device properties
4549 vkGetPhysicalDeviceProperties (handle, &properties);
4650
@@ -107,6 +111,24 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
107111 num_compute_queues += p.queueCount ;
108112 }
109113 }
114+
115+ // Obtain device identity metadata
116+ device_name = std::string (properties.deviceName );
117+ std::transform (
118+ device_name.begin (),
119+ device_name.end (),
120+ device_name.begin (),
121+ [](unsigned char c) { return std::tolower (c); });
122+
123+ if (device_name.find (" adreno" ) != std::string::npos) {
124+ device_type = DeviceType::ADRENO;
125+ } else if (device_name.find (" swiftshader" ) != std::string::npos) {
126+ device_type = DeviceType::SWIFTSHADER;
127+ } else if (device_name.find (" nvidia" ) != std::string::npos) {
128+ device_type = DeviceType::NVIDIA;
129+ } else if (device_name.find (" mali" ) != std::string::npos) {
130+ device_type = DeviceType::MALI;
131+ }
110132}
111133
112134//
Original file line number Diff line number Diff line change 1818namespace vkcompute {
1919namespace vkapi {
2020
21+ enum class DeviceType : uint32_t {
22+ UNKNOWN,
23+ NVIDIA,
24+ MALI,
25+ ADRENO,
26+ SWIFTSHADER,
27+ };
28+
2129struct PhysicalDevice final {
2230 // Handle
2331 VkPhysicalDevice handle;
@@ -48,6 +56,10 @@ struct PhysicalDevice final {
4856 float timestamp_period;
4957 size_t min_ubo_alignment;
5058
59+ // Device identity
60+ std::string device_name;
61+ DeviceType device_type;
62+
5163 explicit PhysicalDevice (VkPhysicalDevice);
5264};
5365
You can’t perform that action at this time.
0 commit comments