Skip to content

[ET-VK][ez] Store physical device identity metadata #10353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025
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