Skip to content

Commit 63832a3

Browse files
author
ssjia
committed
[ET-VK][testing] Add GPU device name override for on-device model tests
Add the ability to override the Vulkan device name at runtime so that device-adaptive code paths (e.g. memory layout selection) can be tested on hardware that doesn't match the overridden device type. PhysicalDevice::override_device_name() and Adapter::override_device_name() are added behind VULKAN_DEBUG. The device type detection logic is refactored into a reusable determine_device_type() helper to avoid duplication between the constructor and the override function. All test binaries in fb/test/models/ (classification, greenscreen, scenex, skin_seg) now accept --gpu_name to invoke the override before loading the model. The Skycastle CI workflows are updated to re-run classification and greenscreen tests with --gpu_name Mali-G715 in addition to the default run. Differential Revision: [D94949136](https://our.internmc.facebook.com/intern/diff/D94949136/) [ghstack-poisoned]
1 parent 31f1d0b commit 63832a3

4 files changed

Lines changed: 40 additions & 11 deletions

File tree

backends/vulkan/runtime/vk_api/Adapter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ void Adapter::submit_cmd(
375375
VK_CHECK(vkQueueSubmit(device_queue.handle, 1u, &submit_info, fence));
376376
}
377377

378+
void Adapter::override_device_name(const std::string& new_name) {
379+
physical_device_.override_device_name(new_name);
380+
}
381+
378382
std::string Adapter::stringize() const {
379383
std::stringstream ss;
380384

backends/vulkan/runtime/vk_api/Adapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ class Adapter final {
306306
VkSemaphore wait_semaphore = VK_NULL_HANDLE,
307307
VkSemaphore signal_semaphore = VK_NULL_HANDLE);
308308

309+
void override_device_name(const std::string& new_name);
310+
309311
std::string stringize() const;
310312
friend std::ostream& operator<<(std::ostream&, const Adapter&);
311313
};

backends/vulkan/runtime/vk_api/Device.cpp

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@
2121
namespace vkcompute {
2222
namespace vkapi {
2323

24+
namespace {
25+
26+
DeviceType determine_device_type(const std::string& device_name) {
27+
if (device_name.find("adreno") != std::string::npos) {
28+
return DeviceType::ADRENO;
29+
} else if (device_name.find("swiftshader") != std::string::npos) {
30+
return DeviceType::SWIFTSHADER;
31+
} else if (device_name.find("nvidia") != std::string::npos) {
32+
return DeviceType::NVIDIA;
33+
} else if (
34+
device_name.find("mali") != std::string::npos ||
35+
device_name.find("immortalis") != std::string::npos) {
36+
return DeviceType::MALI;
37+
}
38+
return DeviceType::UNKNOWN;
39+
}
40+
41+
} // namespace
42+
2443
PhysicalDevice::PhysicalDevice(
2544
VkInstance instance_handle,
2645
VkPhysicalDevice physical_device_handle)
@@ -126,17 +145,7 @@ PhysicalDevice::PhysicalDevice(
126145
device_name.begin(),
127146
[](unsigned char c) { return std::tolower(c); });
128147

129-
if (device_name.find("adreno") != std::string::npos) {
130-
device_type = DeviceType::ADRENO;
131-
} else if (device_name.find("swiftshader") != std::string::npos) {
132-
device_type = DeviceType::SWIFTSHADER;
133-
} else if (device_name.find("nvidia") != std::string::npos) {
134-
device_type = DeviceType::NVIDIA;
135-
} else if (
136-
device_name.find("mali") != std::string::npos ||
137-
device_name.find("immortalis") != std::string::npos) {
138-
device_type = DeviceType::MALI;
139-
}
148+
device_type = determine_device_type(device_name);
140149
}
141150

142151
void PhysicalDevice::query_extensions_vk_1_0() {
@@ -292,6 +301,17 @@ void PhysicalDevice::query_extensions_vk_1_1() {
292301
vkGetPhysicalDeviceProperties2(handle, &properties2);
293302
}
294303

304+
void PhysicalDevice::override_device_name(const std::string& new_name) {
305+
device_name = new_name;
306+
std::transform(
307+
device_name.begin(),
308+
device_name.end(),
309+
device_name.begin(),
310+
[](unsigned char c) { return std::tolower(c); });
311+
312+
device_type = determine_device_type(device_name);
313+
}
314+
295315
//
296316
// DeviceHandle
297317
//

backends/vulkan/runtime/vk_api/Device.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ struct PhysicalDevice final {
8484
private:
8585
void query_extensions_vk_1_0();
8686
void query_extensions_vk_1_1();
87+
88+
public:
89+
void override_device_name(const std::string& new_name);
8790
};
8891

8992
struct DeviceHandle final {

0 commit comments

Comments
 (0)