Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vulkan] Reduce descriptor sets, use official headers, improve allocator, remove module destructor #8452

Merged
merged 65 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
7803cd8
Reduce resource usage for large pipelines by compiling one entry poin…
Oct 30, 2024
bf11f0f
Create a new emitter from scratch inside the add_kernel() method.
Oct 31, 2024
fde4019
Clang format pass
Oct 31, 2024
eb17d68
Fix ambiguous conversion from path to std::string
Oct 31, 2024
8afb1c0
Use explicit string method rather than constructor for path conversion.
Oct 31, 2024
2b3aaa9
Fix file path stem to string conversion.
Oct 31, 2024
4a8ff4c
Re-enable performance wrap test for Vulkan.
Oct 31, 2024
8cc1c32
Trigger CI for testing
Nov 5, 2024
a7586f1
Mark transfer buffers with SRC & DST usage bits to allow re-use witho…
Nov 6, 2024
3ba8b67
Change interal_error to user_assert for un-implemented features.
Nov 6, 2024
53e81ca
Add note to Vulkan.md describing validation layer usage and deb packa…
Nov 6, 2024
aae923a
Merge branch 'main' into dg/reduce-vulkan-desc-sets
Nov 6, 2024
61e59b7
Clang format
Nov 6, 2024
2a2bf38
Switch to halide_mutex for locking Vulkan context (to match other GPU…
Nov 6, 2024
0951099
Trigger CI for testing
Nov 7, 2024
9774414
Merge branch 'main' into dg/reduce-vulkan-desc-sets
Nov 8, 2024
afb8cc6
Reduce memory pressure by reducing default minimum block size to 4KB …
Nov 8, 2024
5671953
Clang format pass
Nov 8, 2024
cc0b5e2
Modify Vulkan allocation routine to fallback to any valid memory type…
Nov 16, 2024
7bdbafe
Re-enable Vulkan for entire GPU allocation test.
Nov 16, 2024
104a8e0
Fix debug messages to iterate across dimensions
Nov 20, 2024
8593273
Merge branch 'main' of github.com:halide/Halide
Nov 20, 2024
d302f71
Merge branch 'main' into dg/reduce-vulkan-desc-sets
Nov 20, 2024
0c937fc
Merge branch 'main' of github.com:halide/Halide
Nov 20, 2024
b308e36
Merge branch 'main' into dg/reduce-vulkan-desc-sets
Nov 20, 2024
a2df3cb
Avoid calling Vulkan API methods in module destructor, since some dri…
Nov 21, 2024
5721404
Update object lifetime and leak tests to manually invoke the Vulkan d…
Nov 21, 2024
e4f4896
Refactor compilation cache destruction to use C-ABI methods rather th…
Nov 22, 2024
b081a45
Don't return an error if the instance pointer is invalid, since it in…
Nov 22, 2024
a1031b9
Clang tidy pass
Nov 22, 2024
56560ad
Fix CodeGen for small signed integers (need to be sign extended and p…
Nov 22, 2024
a94d535
Remove stale mini_vulkan.h and use official Vulkan headers (setup the…
Nov 26, 2024
2273def
Ignore dependencies/vulkan for clang format
Nov 26, 2024
b354b55
Use -Isystem path for Vulkan Headers
Nov 26, 2024
ca967cc
Clang tidy cleanup pass
Nov 26, 2024
dbc5f81
Fix formatting
Nov 26, 2024
36ff6f5
Fix makefile build (add missing runtime include path for vulkan heade…
Nov 26, 2024
b37116f
Use spaces not tabs
Nov 26, 2024
a59948c
Use cmake's find_package to locate the Vulkan Headers, defaulting to …
Nov 26, 2024
74b6eed
Add "vulkan-headers" to vcpkg.json. Update builtin-baseline to d567b…
Nov 26, 2024
43470cb
Split Vulkan API function pointers into three groups ... loader, inst…
Nov 26, 2024
5bd7b41
Clang format pass
Nov 26, 2024
bf0bdda
Remove manual destruction in object lifetime tests for Vulkan
Nov 26, 2024
f528e64
Remove trailing comment in array
Nov 26, 2024
54d9450
Remove leftover print
Nov 26, 2024
75897c6
Merge branch 'main' of github.com:halide/Halide
Nov 27, 2024
3f6a6ba
Merge branch 'main' into dg/reduce-vulkan-desc-sets
Nov 27, 2024
92241df
Add optional custom dtor to JITModuleContents to allow JIT-only destr…
Nov 28, 2024
2b4d2d9
Trigger build to test latest drivers
Dec 2, 2024
4660552
Safeguard Vulkan destructor against being called if runtime wasn't in…
Dec 3, 2024
e040eeb
Formatting pass.
Dec 3, 2024
58148a9
Disable custom JIT destructor to see if segfaults still occur outside…
Dec 4, 2024
4d317d9
Test module destructor with latest driver.
Dec 4, 2024
c77b25d
Formatting pass
Dec 4, 2024
33dc2ff
Only disable CUDA and OpenCL
Dec 4, 2024
d1b4b7c
Revert CMakeLists ... disabling targets prematurely fails the buildbo…
Dec 4, 2024
2e2d837
Add VK_EXT_DEBUG_UTILS_EXTENSION_NAME to optional instance extensions.
Dec 4, 2024
115d7e4
Make clang tidy happy
Dec 5, 2024
06d0d35
Format & Tidy
Dec 5, 2024
6c1ed30
Revert changes to JITModule which added a custom dtor. Use standard
Dec 9, 2024
6ad058b
Revert changes to HalideRuntimeVulkan that added a custom dtor.
Dec 9, 2024
f956f40
Re-enable GPU object lifetime management tests and leak device tests for
Dec 9, 2024
d180921
Formatting
Dec 9, 2024
ee3c3d9
Merge branch 'main' into dg/reduce-vulkan-desc-sets
Dec 9, 2024
12c3a49
trigger buildbots
steven-johnson Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ Halide_feature(WITH_TESTS "Halide's unit test suite" TOP_LEVEL)
Halide_feature(WITH_TUTORIALS "Halide's tutorial code" TOP_LEVEL)
Halide_feature(WITH_UTILS "Optional utility programs for Halide, including HalideTraceViz" TOP_LEVEL)

##
# FIXME: Disable other GPU backends
if (Halide_TARGET MATCHES "vulkan")
message(WARNING "Building Vulkan runtime support!")
else ()
message(FATAL_ERROR "Target disabled for testing ...")
endif()


##
# Add source directories

Expand Down
21 changes: 13 additions & 8 deletions src/runtime/vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ WEAK int halide_vulkan_device_sync(void *user_context, halide_buffer_t *) {
uint64_t t_before = halide_current_time_ns(user_context);
#endif

vkQueueWaitIdle(ctx.queue);
VkResult result = vkQueueWaitIdle(ctx.queue);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkQueueWaitIdle returned " << vk_get_error_name(result) << "\n";
return halide_error_code_generic_error;
}

#ifdef DEBUG_RUNTIME
uint64_t t_after = halide_current_time_ns(user_context);
Expand Down Expand Up @@ -1383,13 +1387,7 @@ WEAK int halide_vulkan_release_unused_device_allocations(void *user_context) {
}

WEAK void halide_vulkan_release_all() {
// Disable custom JIT destructor until we resolve driver issues for segfaults on cleanup
#if 0
debug(nullptr) << "halide_vulkan_release_all()\n";
if (halide_vulkan_is_initialized()) {
halide_vulkan_device_release(nullptr);
}
#endif
// Disable custom JIT destructor until we resolve driver issues for segfaults on cleanup
}

namespace {
Expand Down Expand Up @@ -1418,6 +1416,13 @@ WEAK __attribute__((destructor)) void halide_vulkan_cleanup() {
// For JIT, we register a custom destructor in JITModule.cpp that
// calls halide_vulkan_release_all() when the module refcount
// reaches zero and the module is destroyed.
//

// WIP: Attempt cleanup to see if driver issues are still present.
debug(nullptr) << "halide_vulkan_cleanup()\n";
if (halide_vulkan_is_initialized()) {
halide_vulkan_device_release(nullptr);
}
}

// --------------------------------------------------------------------------
Expand Down
27 changes: 14 additions & 13 deletions src/runtime/vulkan_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,30 +514,31 @@ int vk_destroy_context(void *user_context, VulkanMemoryAllocator *allocator,
return halide_error_code_success;
}

if (device != nullptr) {
vk_load_vulkan_device_functions(user_context, device);
if (vkAllocateMemory == nullptr) {
debug(user_context) << "Vulkan: Lost device interface ... \n";
vk_unload_vulkan_device_functions(user_context);
vk_unload_vulkan_instance_functions(user_context);
return halide_error_code_device_interface_no_device;
if (queue != VK_NULL_HANDLE) {
VkResult result = vkQueueWaitIdle(queue);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkQueueWaitIdle returned " << vk_get_error_name(result) << "\n";
return halide_error_code_generic_error;
}
}

if (device != nullptr) {
vkDeviceWaitIdle(device);
if (device != VK_NULL_HANDLE) {
VkResult result = vkDeviceWaitIdle(device);
if (result != VK_SUCCESS) {
error(user_context) << "Vulkan: vkDeviceWaitIdle returned " << vk_get_error_name(result) << "\n";
return halide_error_code_generic_error;
}
}

if (allocator != nullptr) {
vk_destroy_shader_modules(user_context, allocator);
vk_destroy_memory_allocator(user_context, allocator);
}

const VkAllocationCallbacks *alloc_callbacks = halide_vulkan_get_allocation_callbacks(user_context);
if (device != nullptr) {
if (device != VK_NULL_HANDLE) {
vk_destroy_device(user_context, device, alloc_callbacks);
}
if (instance != nullptr) {
if (instance != VK_NULL_HANDLE) {
vk_destroy_instance(user_context, instance, alloc_callbacks);
}
return halide_error_code_success;
Expand Down
Loading