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 12
12
13
13
#include < executorch/backends/vulkan/runtime/vk_api/Exception.h>
14
14
15
+ #include < algorithm>
15
16
#include < bitset>
17
+ #include < cctype>
16
18
#include < cstring>
17
19
18
20
namespace vkcompute {
@@ -40,7 +42,9 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
40
42
has_unified_memory (false ),
41
43
has_timestamps (false ),
42
44
timestamp_period (0 ),
43
- min_ubo_alignment (0 ) {
45
+ min_ubo_alignment (0 ),
46
+ device_name{},
47
+ device_type{DeviceType::UNKNOWN} {
44
48
// Extract physical device properties
45
49
vkGetPhysicalDeviceProperties (handle, &properties);
46
50
@@ -107,6 +111,24 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
107
111
num_compute_queues += p.queueCount ;
108
112
}
109
113
}
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
+ }
110
132
}
111
133
112
134
//
Original file line number Diff line number Diff line change 18
18
namespace vkcompute {
19
19
namespace vkapi {
20
20
21
+ enum class DeviceType : uint32_t {
22
+ UNKNOWN,
23
+ NVIDIA,
24
+ MALI,
25
+ ADRENO,
26
+ SWIFTSHADER,
27
+ };
28
+
21
29
struct PhysicalDevice final {
22
30
// Handle
23
31
VkPhysicalDevice handle;
@@ -48,6 +56,10 @@ struct PhysicalDevice final {
48
56
float timestamp_period;
49
57
size_t min_ubo_alignment;
50
58
59
+ // Device identity
60
+ std::string device_name;
61
+ DeviceType device_type;
62
+
51
63
explicit PhysicalDevice (VkPhysicalDevice);
52
64
};
53
65
You can’t perform that action at this time.
0 commit comments