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
4 changes: 4 additions & 0 deletions backends/vulkan/runtime/vk_api/Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ void Adapter::submit_cmd(
VK_CHECK(vkQueueSubmit(device_queue.handle, 1u, &submit_info, fence));
}

void Adapter::override_device_name(const std::string& new_name) {
physical_device_.override_device_name(new_name);
}

std::string Adapter::stringize() const {
std::stringstream ss;

Expand Down
2 changes: 2 additions & 0 deletions backends/vulkan/runtime/vk_api/Adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ class Adapter final {
VkSemaphore wait_semaphore = VK_NULL_HANDLE,
VkSemaphore signal_semaphore = VK_NULL_HANDLE);

void override_device_name(const std::string& new_name);

std::string stringize() const;
friend std::ostream& operator<<(std::ostream&, const Adapter&);
};
Expand Down
42 changes: 31 additions & 11 deletions backends/vulkan/runtime/vk_api/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@
namespace vkcompute {
namespace vkapi {

namespace {

DeviceType determine_device_type(const std::string& device_name) {
if (device_name.find("adreno") != std::string::npos) {
return DeviceType::ADRENO;
} else if (device_name.find("swiftshader") != std::string::npos) {
return DeviceType::SWIFTSHADER;
} else if (device_name.find("nvidia") != std::string::npos) {
return DeviceType::NVIDIA;
} else if (
device_name.find("mali") != std::string::npos ||
device_name.find("immortalis") != std::string::npos) {
return DeviceType::MALI;
}
return DeviceType::UNKNOWN;
}

} // namespace

PhysicalDevice::PhysicalDevice(
VkInstance instance_handle,
VkPhysicalDevice physical_device_handle)
Expand Down Expand Up @@ -126,17 +145,7 @@ PhysicalDevice::PhysicalDevice(
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_name.find("immortalis") != std::string::npos) {
device_type = DeviceType::MALI;
}
device_type = determine_device_type(device_name);
}

void PhysicalDevice::query_extensions_vk_1_0() {
Expand Down Expand Up @@ -292,6 +301,17 @@ void PhysicalDevice::query_extensions_vk_1_1() {
vkGetPhysicalDeviceProperties2(handle, &properties2);
}

void PhysicalDevice::override_device_name(const std::string& new_name) {
device_name = new_name;
std::transform(
device_name.begin(),
device_name.end(),
device_name.begin(),
[](unsigned char c) { return std::tolower(c); });

device_type = determine_device_type(device_name);
}

//
// DeviceHandle
//
Expand Down
3 changes: 3 additions & 0 deletions backends/vulkan/runtime/vk_api/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct PhysicalDevice final {
private:
void query_extensions_vk_1_0();
void query_extensions_vk_1_1();

public:
void override_device_name(const std::string& new_name);
};

struct DeviceHandle final {
Expand Down
Loading