1#ifndef HALIDE_RUNTIME_VULKAN_CONTEXT_H
2#define HALIDE_RUNTIME_VULKAN_CONTEXT_H
52 : user_context(user_context),
92 debug(user_context) <<
" vk_find_compute_capability (user_context: " << user_context <<
")\n";
105 debug(user_context) <<
" no valid vulkan runtime was found ...\n";
117 debug(user_context) <<
" no valid vulkan device was found ...\n";
124 debug(user_context) <<
" querying for device properties ...\n";
128 debug(user_context) <<
" found device compute capability v" << *
major <<
"." << *
minor <<
" ...\n";
136 debug(user_context) <<
" vk_create_instance (user_context: " << user_context <<
")\n";
181 debug(user_context) <<
"Vulkan: vkCreateInstance failed with return code: " <<
vk_get_error_name(result) <<
"\n";
189 debug(user_context) <<
" vk_destroy_instance (user_context: " << user_context <<
")\n";
202 debug(user_context) <<
"Vulkan: vkEnumeratePhysicalDevices failed with return code: " <<
vk_get_error_name(result) <<
"\n";
206 debug(user_context) <<
"Vulkan: No devices found.\n";
219 debug(user_context) <<
"Vulkan: Out of system memory!\n";
224 debug(user_context) <<
"Vulkan: vkEnumeratePhysicalDevices failed with return code: " <<
vk_get_error_name(result) <<
"\n";
236 debug(user_context) <<
"Vulkan: Checking device #" <<
i <<
"='" << properties.
deviceName <<
"'\n";
281 debug(user_context) <<
"Vulkan: Found matching compute device '" << properties.
deviceName <<
"'\n";
292 debug(user_context) <<
"Vulkan: Defaulting to first compute device '" << properties.
deviceName <<
"'\n";
302 debug(user_context) <<
" vk_create_device (user_context=" << user_context <<
")\n";
304 debug(user_context) <<
" checking for required device extensions ...\n";
308 debug(user_context) <<
" checking for optional device extensions ...\n";
312 debug(user_context) <<
" validating supported device extensions ...\n";
318 debug(user_context) <<
"Vulkan: Unable to validate required extension support!\n";
348 debug(user_context) <<
" querying for device properties ...\n";
361 debug(user_context) <<
" querying for device features...\n";
363 debug(user_context) <<
" shader float64 support: " << (
device_features.shaderFloat64 ?
"true" :
"false") <<
"...\n";
364 debug(user_context) <<
" shader int64 support: " << (
device_features.shaderInt64 ?
"true" :
"false") <<
"...\n";
365 debug(user_context) <<
" shader int16 support: " << (
device_features.shaderInt16 ?
"true" :
"false") <<
"...\n";
395 debug(user_context) <<
" querying for extended device features...\n";
397 debug(user_context) <<
" shader int8 support: " << (
shader_f16_i8_ext.shaderInt8 ?
"true" :
"false") <<
"...\n";
398 debug(user_context) <<
" shader float16 support: " << (
shader_f16_i8_ext.shaderFloat16 ?
"true" :
"false") <<
"...\n";
400 debug(user_context) <<
" storage buffer 8bit access support: " << (
storage_8bit_ext.storageBuffer8BitAccess ?
"true" :
"false") <<
"...\n";
401 debug(user_context) <<
" storage buffer 16bit access support: " << (
storage_16bit_ext.storageBuffer16BitAccess ?
"true" :
"false") <<
"...\n";
421 debug(user_context) <<
"Vulkan: vkCreateDevice failed with return code: " <<
vk_get_error_name(result) <<
"\n";
434 debug(user_context) <<
" vk_create_context (user_context: " << user_context <<
")\n";
446 error(user_context) <<
"Vulkan: Failed to create instance for context!\n";
456 error(user_context) <<
"Vulkan: Failed to select device for context!\n";
462 error(user_context) <<
"Vulkan: Failed to create device for context!\n";
467 if (*allocator ==
nullptr) {
468 error(user_context) <<
"Vulkan: Failed to create memory allocator for device!\n";
474 error(user_context) <<
"Vulkan: Failed to create command pool for context!\n";
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_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 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 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
volatile ScopedSpinLock::AtomicFlag WEAK thread_lock
VkQueue WEAK cached_queue
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
void WEAK vk_load_vulkan_functions(VkInstance instance)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
Expr cast(Expr a)
Cast an expression to the halide type corresponding to the C++ type T.
#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 *)
VkPhysicalDeviceType deviceType
char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]