Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion backends/vulkan/runtime/vk_api/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

#include <executorch/backends/vulkan/runtime/vk_api/Exception.h>

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstring>

namespace vkcompute {
Expand Down Expand Up @@ -40,7 +42,9 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
has_unified_memory(false),
has_timestamps(false),
timestamp_period(0),
min_ubo_alignment(0) {
min_ubo_alignment(0),
device_name{},
device_type{DeviceType::UNKNOWN} {
// Extract physical device properties
vkGetPhysicalDeviceProperties(handle, &properties);

Expand Down Expand Up @@ -107,6 +111,24 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
num_compute_queues += p.queueCount;
}
}

// Obtain device identity metadata
device_name = std::string(properties.deviceName);
std::transform(
device_name.begin(),
device_name.end(),
device_name.begin(),
[](unsigned char c) { return std::tolower(c); });

if (device_name.find("adreno") != std::string::npos) {
device_type = DeviceType::ADRENO;
} else if (device_name.find("swiftshader") != std::string::npos) {
device_type = DeviceType::SWIFTSHADER;
} else if (device_name.find("nvidia") != std::string::npos) {
device_type = DeviceType::NVIDIA;
} else if (device_name.find("mali") != std::string::npos) {
device_type = DeviceType::MALI;
}
}

//
Expand Down
12 changes: 12 additions & 0 deletions backends/vulkan/runtime/vk_api/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
namespace vkcompute {
namespace vkapi {

enum class DeviceType : uint32_t {
UNKNOWN,
NVIDIA,
MALI,
ADRENO,
SWIFTSHADER,
};

struct PhysicalDevice final {
// Handle
VkPhysicalDevice handle;
Expand Down Expand Up @@ -48,6 +56,10 @@ struct PhysicalDevice final {
float timestamp_period;
size_t min_ubo_alignment;

// Device identity
std::string device_name;
DeviceType device_type;

explicit PhysicalDevice(VkPhysicalDevice);
};

Expand Down
Loading