diff --git a/src/main.cpp b/src/main.cpp index 5027360..4e65ec3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,8 +5,8 @@ #include #include #include +#include -/// 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(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 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{};