1#ifndef HALIDE_RUNTIME_VULKAN_CONTEXT_H
2#define HALIDE_RUNTIME_VULKAN_CONTEXT_H
52 : user_context(user_context) {
84 debug(user_context) <<
" vk_find_compute_capability (user_context: " << user_context <<
")\n";
106 debug(user_context) <<
" no valid vulkan loader library was found ...\n";
119 debug(user_context) <<
" no valid vulkan runtime was found ...\n";
127 debug(user_context) <<
" no valid vulkan runtime was found ...\n";
135 debug(user_context) <<
" no valid vulkan device was found ...\n";
141 debug(user_context) <<
" querying for device properties ...\n";
145 debug(user_context) <<
" found device compute capability v" << *
major <<
"." << *
minor <<
" ...\n";
153 debug(user_context) <<
" vk_create_instance (user_context: " << user_context <<
")\n";
198 debug(user_context) <<
"Vulkan: vkCreateInstance failed with return code: " <<
vk_get_error_name(result) <<
"\n";
206 debug(user_context) <<
" vk_destroy_instance (user_context: " << user_context <<
")\n";
219 debug(user_context) <<
"Vulkan: vkEnumeratePhysicalDevices failed with return code: " <<
vk_get_error_name(result) <<
"\n";
223 debug(user_context) <<
"Vulkan: No devices found.\n";
236 debug(user_context) <<
"Vulkan: Out of system memory!\n";
241 debug(user_context) <<
"Vulkan: vkEnumeratePhysicalDevices failed with return code: " <<
vk_get_error_name(result) <<
"\n";
253 debug(user_context) <<
"Vulkan: Checking device #" <<
i <<
"='" << properties.
deviceName <<
"'\n";
298 debug(user_context) <<
"Vulkan: Found matching compute device '" << properties.
deviceName <<
"'\n";
309 debug(user_context) <<
"Vulkan: Defaulting to first compute device '" << properties.
deviceName <<
"'\n";
319 debug(user_context) <<
" vk_create_device (user_context=" << user_context <<
")\n";
321 debug(user_context) <<
" checking for required device extensions ...\n";
325 debug(user_context) <<
" checking for optional device extensions ...\n";
329 debug(user_context) <<
" validating supported device extensions ...\n";
335 debug(user_context) <<
"Vulkan: Unable to validate required extension support!\n";
365 debug(user_context) <<
" querying for device properties ...\n";
378 debug(user_context) <<
" querying for device features...\n";
380 debug(user_context) <<
" shader float64 support: " << (
device_features.shaderFloat64 ?
"true" :
"false") <<
"...\n";
381 debug(user_context) <<
" shader int64 support: " << (
device_features.shaderInt64 ?
"true" :
"false") <<
"...\n";
382 debug(user_context) <<
" shader int16 support: " << (
device_features.shaderInt16 ?
"true" :
"false") <<
"...\n";
412 debug(user_context) <<
" querying for extended device features...\n";
414 debug(user_context) <<
" shader int8 support: " << (
shader_f16_i8_ext.shaderInt8 ?
"true" :
"false") <<
"...\n";
415 debug(user_context) <<
" shader float16 support: " << (
shader_f16_i8_ext.shaderFloat16 ?
"true" :
"false") <<
"...\n";
417 debug(user_context) <<
" storage buffer 8bit access support: " << (
storage_8bit_ext.storageBuffer8BitAccess ?
"true" :
"false") <<
"...\n";
418 debug(user_context) <<
" storage buffer 16bit access support: " << (
storage_16bit_ext.storageBuffer16BitAccess ?
"true" :
"false") <<
"...\n";
438 debug(user_context) <<
"Vulkan: vkCreateDevice failed with return code: " <<
vk_get_error_name(result) <<
"\n";
451 debug(user_context) <<
" vk_create_context (user_context: " << user_context <<
")\n";
456 error(user_context) <<
"Vulkan: Failed to resolve loader library methods to create instance!\n";
471 error(user_context) <<
"Vulkan: Failed to create instance for context!\n";
478 error(user_context) <<
"Vulkan: Failed to resolve API library methods to create device!\n";
485 error(user_context) <<
"Vulkan: Failed to select device for context!\n";
491 error(user_context) <<
"Vulkan: Failed to create device for context!\n";
496 if (*allocator ==
nullptr) {
497 error(user_context) <<
"Vulkan: Failed to create memory allocator for device!\n";
503 error(user_context) <<
"Vulkan: Failed to create command pool for context!\n";
517 <<
"vk_destroy_context (user_context: " << user_context <<
")\n";
519 if (device !=
nullptr) {
527 if (device !=
nullptr) {
530 if (instance !=
nullptr) {
#define HALIDE_VERSION_MINOR
#define HALIDE_VERSION_PATCH
#define HALIDE_VERSION_MAJOR
int halide_error_no_device_interface(void *user_context)
halide_error_code_t
The error codes that may be returned by a Halide pipeline.
@ halide_error_code_symbol_not_found
A runtime symbol could not be loaded.
@ halide_error_code_device_interface_no_device
Buffer has a non-null device_interface but device is 0, which violates a Halide invariant.
@ halide_error_code_generic_error
An uncategorized error occurred.
@ halide_error_code_success
There was no error.
@ halide_error_code_out_of_memory
A call to halide_malloc returned NULL.
#define HALIDE_ALWAYS_INLINE
const struct VkAllocationCallbacks * halide_vulkan_get_allocation_callbacks(void *user_context)
int halide_vulkan_acquire_context(void *user_context, struct halide_vulkan_memory_allocator **allocator, struct VkInstance_T **instance, struct VkDevice_T **device, struct VkPhysicalDevice_T **physical_device, uint64_t *command_pool, struct VkQueue_T **queue, uint32_t *queue_family_index, bool create=true)
const char * halide_vulkan_get_device_type(void *user_context)
int halide_vulkan_release_context(void *user_context, struct VkInstance_T *instance, struct VkDevice_T *device, struct VkQueue_T *queue)
VulkanMemoryAllocator * allocator
uint32_t queue_family_index
HALIDE_ALWAYS_INLINE VulkanContext(void *user_context)
HALIDE_ALWAYS_INLINE const VkAllocationCallbacks * allocation_callbacks()
VkCommandPool command_pool
VkPhysicalDevice physical_device
HALIDE_ALWAYS_INLINE ~VulkanContext()
halide_error_code_t error
Vulkan Memory Allocator class interface for managing large memory requests stored as contiguous block...
#define VK_API_VERSION_1_3
VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
void(VKAPI_PTR * PFN_vkGetPhysicalDeviceFeatures2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR *pFeatures)
VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)
#define VK_MAKE_API_VERSION(variant, major, minor, patch)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
#define VK_API_VERSION_MINOR(version)
@ VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR
@ VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU
@ VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
@ VK_PHYSICAL_DEVICE_TYPE_CPU
@ VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
#define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties)
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR *pFeatures)
VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
#define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR
#define VK_API_VERSION_MAJOR(version)
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
@ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO
@ VK_STRUCTURE_TYPE_APPLICATION_INFO
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR
@ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
@ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO
@ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR
WEAK void * halide_vulkan_get_symbol(void *user_context, const char *name)
volatile ScopedSpinLock::AtomicFlag WEAK thread_lock
VkQueue WEAK cached_queue
void WEAK vk_load_vulkan_loader_functions(void *user_context)
void WEAK vk_load_vulkan_functions(void *user_context, VkInstance instance)
VkInstance WEAK cached_instance
VkCommandPool WEAK cached_command_pool
uint32_t WEAK cached_queue_family_index
VkPhysicalDevice WEAK cached_physical_device
halide_vulkan_memory_allocator *WEAK cached_allocator
VkDevice WEAK cached_device
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
#define halide_debug_assert(user_context, cond)
halide_debug_assert() is like halide_assert(), but only expands into a check when DEBUG_RUNTIME is de...
unsigned __INT32_TYPE__ uint32_t
#define halide_abort_if_false(user_context, cond)
const char * strstr(const char *, const char *)
bool contains(int32_t x) const
Test if the interval contains a particular value.
VkPhysicalDeviceType deviceType
char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]