1#ifndef GPU_OBJECT_LIFETIME_H
2#define GPU_OBJECT_LIFETIME_H
13 const char *
const created;
14 const char *
const destroyed;
19 ObjectType(
const char *created,
const char *destroyed,
bool is_global =
false)
20 : created(created), destroyed(destroyed),
21 is_global(is_global), total_created(0), live_count(0) {
25 std::array<ObjectType, 22> object_types = {{
26 {
"Caching compiled kernel:",
"Releasing cached compilation:"},
29 {
"clCreateContext",
"clReleaseContext",
true},
30 {
"clCreateCommandQueue",
"clReleaseCommandQueue",
true},
33 {
"clCreateBuffer",
"clReleaseMemObject"},
34 {
"clCreateKernel",
"clReleaseKernel"},
37 {
"cuCtxCreate",
"cuCtxDestroy",
true},
38 {
"cuMemAlloc",
"cuMemFree"},
41 {
"Allocating: MTLCreateSystemDefaultDevice",
"Releasing: MTLCreateSystemDefaultDevice",
true},
42 {
"Allocating: new_command_queue",
"Releasing: new_command_queue"},
45 {
"halide_remote_load_library",
"halide_remote_release_library"},
46 {
"ion_alloc",
"ion_free"},
49 {
"vk_create_context",
"vk_destroy_context",
true},
50 {
"vk_create_command_pool",
"vk_destroy_command_pool"},
51 {
"vk_create_command_buffer",
"vk_destroy_command_buffer"},
52 {
"vk_create_pipeline_layout",
"vk_destroy_pipeline_layout"},
53 {
"vk_create_compute_pipeline",
"vk_destroy_compute_pipeline"},
54 {
"vk_create_descriptor_pool",
"vk_destroy_descriptor_pool"},
55 {
"Vulkan: Allocated memory for device region",
"Vulkan: Deallocated memory for device region"},
56 {
"Vulkan: Created buffer",
"Vulkan: Destroyed buffer"},
59 {
"wgpuCreateInstance",
"wgpuInstanceRelease",
true},
60 {
"wgpuDeviceCreateBuffer",
"wgpuBufferRelease"},
61 {
"wgpuDeviceCreateComputePipeline",
"wgpuComputePipelineRelease"},
67 for (
auto &
o : object_types) {
71 }
else if (
strstr(str,
o.destroyed)) {
80 for (
auto &
o : object_types) {
81 if (
o.live_count != 0 &&
83 printf(
"Error! %d objects created by %s still live\n",
84 o.live_count,
o.created);
88 printf(
"Error! %d global objects created by %s, max is %d\n",
96 printf(
"Error! No objects created. Ensure gpu_debug is set, ");
97 printf(
"and record_gpu_debug is called from halide_print.\n");
int validate_gpu_object_lifetime(bool allow_globals, bool allow_none, int max_globals)
void record_gpu_debug(const char *str)
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.
const char * strstr(const char *, const char *)