libs/vulkan-compute/test_init.c
1/* test_init.c - Test Vulkan compute library initialization
2 *
3 * Verifies that the library can initialize Vulkan and detect the GPU.
4 */
5
6#include "include/vk_compute.h"
7#include <stdio.h>
8
9int main(void) {
10 printf("=== Vulkan Compute Library Test ===\n\n");
11
12 /* Test initialization with validation layers */
13 printf("Initializing Vulkan (with validation)...\n");
14 VkComputeContext* ctx = vkc_init(false); /* Disable validation for now */
15
16 if (!ctx) {
17 fprintf(stderr, "ERROR: Failed to initialize Vulkan context\n");
18 return 1;
19 }
20
21 printf("\n[SUCCESS] Vulkan initialized\n\n");
22
23 /* Query device information */
24 const char* device_name = vkc_get_device_name(ctx);
25 uint32_t max_workgroup = vkc_get_max_workgroup_size(ctx);
26 uint64_t device_memory = vkc_get_device_memory(ctx);
27
28 printf("Device Information:\n");
29 printf(" Name: %s\n", device_name);
30 printf(" Max workgroup size: %u\n", max_workgroup);
31 printf(" Device memory: %.2f GB\n", device_memory / (1024.0 * 1024.0 * 1024.0));
32
33 /* Cleanup */
34 printf("\nCleaning up...\n");
35 vkc_destroy(ctx);
36
37 printf("\n[SUCCESS] All tests passed\n");
38 return 0;
39}
40