yum-mirror/VkFFT
git clone https://git.yummers.dev/yum-mirror/VkFFT
3fa0c21
v1.3.3
1#ifndef VKFFT_UTILS_H 2#define VKFFT_UTILS_H 3#include "vkFFT.h" 4#include <vector> 5typedef struct { 6#if(VKFFT_BACKEND==0) 7 VkInstance instance;//a connection between the application and the Vulkan library 8 VkPhysicalDevice physicalDevice;//a handle for the graphics card used in the application 9 VkPhysicalDeviceProperties physicalDeviceProperties;//bastic device properties 10 VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProperties;//bastic memory properties of the device 11 VkDevice device;//a logical device, interacting with physical device 12 VkDebugUtilsMessengerEXT debugMessenger;//extension for debugging 13 uint64_t queueFamilyIndex;//if multiple queues are available, specify the used one 14 VkQueue queue;//a place, where all operations are submitted 15 VkCommandPool commandPool;//an opaque objects that command buffer memory is allocated from 16 VkFence fence;//a vkGPU->fence used to synchronize dispatches 17 std::vector<const char*> enabledDeviceExtensions; 18 uint64_t enableValidationLayers; 19 20 VkBuffer* stagingBuffer;//optional pointer to the user defined staging buffer 21 VkDeviceMemory* stagingBufferMemory;//optional pointer to the user defined staging buffer memory, associated with the stagingBuffer 22#elif(VKFFT_BACKEND==1) 23 CUdevice device; 24 CUcontext context; 25#elif(VKFFT_BACKEND==2) 26 hipDevice_t device; 27 hipCtx_t context; 28#elif(VKFFT_BACKEND==3) 29 cl_platform_id platform; 30 cl_device_id device; 31 cl_context context; 32 cl_command_queue commandQueue; 33#elif(VKFFT_BACKEND==4) 34 ze_driver_handle_t driver; 35 ze_device_handle_t device; 36 ze_context_handle_t context; 37 ze_command_queue_handle_t commandQueue; 38 uint32_t commandQueueID; 39#elif(VKFFT_BACKEND==5) 40 MTL::Device* device; 41 MTL::CommandQueue* queue; 42#endif 43 uint64_t device_id;//an id of a device, reported by Vulkan device list 44} VkGPU;//an example structure containing Vulkan primitives 45 46typedef struct { 47 uint64_t X; 48 uint64_t Y; 49 uint64_t Z; 50 uint64_t P; 51 uint64_t B; 52 uint64_t N; 53 uint64_t R2C; 54 uint64_t DCT; 55 uint64_t saveApplicationToString; 56 uint64_t loadApplicationFromString; 57} VkFFTUserSystemParameters;//an example structure used to pass user-defined system for benchmarking 58 59#if(VKFFT_BACKEND==0) 60VkResult CreateDebugUtilsMessengerEXT(VkGPU* vkGPU, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger); 61void DestroyDebugUtilsMessengerEXT(VkGPU* vkGPU, const VkAllocationCallbacks* pAllocator); 62static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData); 63VkResult setupDebugMessenger(VkGPU* vkGPU); 64VkResult checkValidationLayerSupport(); 65std::vector<const char*> getRequiredExtensions(VkGPU* vkGPU, uint64_t sample_id); 66VkResult createInstance(VkGPU* vkGPU, uint64_t sample_id); 67VkResult findPhysicalDevice(VkGPU* vkGPU); 68VkResult getComputeQueueFamilyIndex(VkGPU* vkGPU); 69VkResult createDevice(VkGPU* vkGPU, uint64_t sample_id); 70VkResult createFence(VkGPU* vkGPU); 71VkResult createCommandPool(VkGPU* vkGPU); 72VkFFTResult findMemoryType(VkGPU* vkGPU, uint64_t memoryTypeBits, uint64_t memorySize, VkMemoryPropertyFlags properties, uint32_t* memoryTypeIndex); 73VkFFTResult allocateBuffer(VkGPU* vkGPU, VkBuffer* buffer, VkDeviceMemory* deviceMemory, VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags propertyFlags, uint64_t size); 74#endif 75VkFFTResult transferDataToCPU(VkGPU* vkGPU, void* cpu_arr, void* output_buffer, uint64_t bufferSize); 76VkFFTResult transferDataFromCPU(VkGPU* vkGPU, void* cpu_arr, void* input_buffer, uint64_t bufferSize); 77VkFFTResult devices_list(); 78VkFFTResult performVulkanFFT(VkGPU* vkGPU, VkFFTApplication* app, VkFFTLaunchParams* launchParams, int inverse, uint64_t num_iter); 79VkFFTResult performVulkanFFTiFFT(VkGPU* vkGPU, VkFFTApplication* app, VkFFTLaunchParams* launchParams, uint64_t num_iter, double* time_result); 80#endif