add information about found GPU's
This commit is contained in:
39
src/main.cpp
39
src/main.cpp
@@ -5,8 +5,8 @@
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
/// TODO: Print available GPU's
|
||||
/// TODO: Run benchmark on all GPU's
|
||||
/// TODO: Pinned memory
|
||||
/// TODO: Plot by buffer size
|
||||
@@ -21,6 +21,24 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
const char *getGpuTypeName(VkPhysicalDeviceType type) {
|
||||
switch (type) {
|
||||
case VK_PHYSICAL_DEVICE_TYPE_OTHER:
|
||||
return "Other";
|
||||
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
||||
return "Integrated GPU";
|
||||
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
||||
return "Discrete GPU";
|
||||
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
|
||||
return "Virtual GPU";
|
||||
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
||||
return "CPU";
|
||||
default:
|
||||
return "Invalid Type";
|
||||
}
|
||||
return "Invalid Type";
|
||||
}
|
||||
|
||||
uint32_t findMemory(VkPhysicalDevice phy, uint32_t typeBits,
|
||||
VkMemoryPropertyFlags props) {
|
||||
VkPhysicalDeviceMemoryProperties mem;
|
||||
@@ -93,9 +111,8 @@ double benchCopy(VkDevice dev, VkCommandPool pool, VkQueue queue, VkBuffer src,
|
||||
return std::chrono::duration<double, std::milli>(t1 - t0).count();
|
||||
}
|
||||
|
||||
// ---------- main ----------
|
||||
int main() {
|
||||
// ---- instance ----
|
||||
|
||||
VkApplicationInfo app{};
|
||||
app.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
app.pApplicationName = "VulkanTransferBench";
|
||||
@@ -108,6 +125,8 @@ int main() {
|
||||
VkInstance inst;
|
||||
vkCreateInstance(&ici, nullptr, &inst);
|
||||
|
||||
std::cout << "Starting benchmark..." << std::endl;
|
||||
|
||||
// ---- physical device ----
|
||||
uint32_t n = 0;
|
||||
vkEnumeratePhysicalDevices(inst, &n, nullptr);
|
||||
@@ -115,6 +134,20 @@ int main() {
|
||||
vkEnumeratePhysicalDevices(inst, &n, gpus.data());
|
||||
VkPhysicalDevice phy = gpus[0];
|
||||
|
||||
std::cout << "Found " << gpus.size() << " gpus." << std::endl;
|
||||
|
||||
{
|
||||
std::vector<VkPhysicalDeviceProperties> gpu_properties(n);
|
||||
// Print info
|
||||
for (uint32_t i = 0; i < gpus.size(); i++) {
|
||||
VkPhysicalDeviceProperties *prop = &gpu_properties[i];
|
||||
vkGetPhysicalDeviceProperties(gpus[i], prop);
|
||||
|
||||
std::cout << "GPU: [" << i << "] " << prop->deviceName << " ("
|
||||
<< getGpuTypeName(prop->deviceType) << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- logical device ----
|
||||
float prio = 1.0f;
|
||||
VkDeviceQueueCreateInfo qi{};
|
||||
|
||||
Reference in New Issue
Block a user