From c2468131ad57de7c9cf0a10fd7a2b9b51cfbfa52 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 25 Jun 2024 13:58:30 +0100 Subject: [PATCH] Disable generating loader release calls + reword release tag docs --- scripts/YaML.md | 2 +- scripts/templates/ldrddi.cpp.mako | 12 +-- source/loader/ur_ldrddi.cpp | 133 ------------------------------ 3 files changed, 8 insertions(+), 139 deletions(-) diff --git a/scripts/YaML.md b/scripts/YaML.md index a995b5858c..089115cb1b 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -625,7 +625,7 @@ class ur_name_t(Structure): - `range` is used for params that are array pointers to specify the valid range that the is valid to read + `start` and `end` must be an ISO-C standard identifier or literal + `start` is inclusive and `end` is exclusive - - `release` is used for params that are handles or pointers to handles where the function will destroy any backing memory associated with the handle(s) + - `release` is used for params that are handles or pointers to handles where the function will decrement the handle's reference count, potentially leaving it in an invalid state if the reference count reaches zero. - `typename` is used to denote the type enum for params that are opaque pointers to values of tagged data types. - `bounds` is used for params that are memory objects or USM allocations. It specifies the range within the memory allocation represented by the param that will be accessed by the operation. + `offset` and `size` must be an ISO-C standard identifier or literal diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 4da75d1f91..b93330049b 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -271,15 +271,17 @@ namespace ur_loader del add_local %> %for i, item in enumerate(epilogue): - %if 0 == i: + %if 0 == i and not item['release']: if( ${X}_RESULT_SUCCESS != result ) return result; %endif - %if item['release']: - // release loader handle - ${item['factory']}.release( ${item['name']} ); - %elif not '_native_object_' in item['obj']: + ## Before we can re-enable the releases we will need ref-counted object_t. + ## See unified-runtime github issue #1784 + ##%if item['release']: + ##// release loader handle + ##${item['factory']}.release( ${item['name']} ); + %if not item['release'] and not '_native_object_' in item['obj'] or th.make_func_name(n, tags, obj) == 'urPlatformCreateWithNativeHandle': try { %if 'typename' in item: diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index c0e9a3fc5e..d064254461 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -101,13 +101,6 @@ __urdlllocal ur_result_t UR_APICALL urAdapterRelease( // forward to device-platform result = pfnAdapterRelease(hAdapter); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_adapter_factory.release(hAdapter); - return result; } @@ -636,13 +629,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceRelease( // forward to device-platform result = pfnRelease(hDevice); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_device_factory.release(hDevice); - return result; } @@ -920,13 +906,6 @@ __urdlllocal ur_result_t UR_APICALL urContextRelease( // forward to device-platform result = pfnRelease(hContext); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_context_factory.release(hContext); - return result; } @@ -1232,13 +1211,6 @@ __urdlllocal ur_result_t UR_APICALL urMemRelease( // forward to device-platform result = pfnRelease(hMem); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_mem_factory.release(hMem); - return result; } @@ -1597,13 +1569,6 @@ __urdlllocal ur_result_t UR_APICALL urSamplerRelease( // forward to device-platform result = pfnRelease(hSampler); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_sampler_factory.release(hSampler); - return result; } @@ -2038,13 +2003,6 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolRelease( // forward to device-platform result = pfnPoolRelease(pPool); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_usm_pool_factory.release(pPool); - return result; } @@ -2435,13 +2393,6 @@ __urdlllocal ur_result_t UR_APICALL urPhysicalMemRelease( // forward to device-platform result = pfnRelease(hPhysicalMem); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_physical_mem_factory.release(hPhysicalMem); - return result; } @@ -2686,13 +2637,6 @@ __urdlllocal ur_result_t UR_APICALL urProgramRelease( // forward to device-platform result = pfnRelease(hProgram); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_program_factory.release(hProgram); - return result; } @@ -3283,13 +3227,6 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease( // forward to device-platform result = pfnRelease(hKernel); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_kernel_factory.release(hKernel); - return result; } @@ -3736,13 +3673,6 @@ __urdlllocal ur_result_t UR_APICALL urQueueRelease( // forward to device-platform result = pfnRelease(hQueue); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_queue_factory.release(hQueue); - return result; } @@ -4050,13 +3980,6 @@ __urdlllocal ur_result_t UR_APICALL urEventRelease( // forward to device-platform result = pfnRelease(hEvent); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_event_factory.release(hEvent); - return result; } @@ -5919,13 +5842,6 @@ urBindlessImagesUnsampledImageHandleDestroyExp( // forward to device-platform result = pfnUnsampledImageHandleDestroyExp(hContext, hDevice, hImage); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_image_factory.release(hImage); - return result; } @@ -5960,13 +5876,6 @@ urBindlessImagesSampledImageHandleDestroyExp( // forward to device-platform result = pfnSampledImageHandleDestroyExp(hContext, hDevice, hImage); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_image_factory.release(hImage); - return result; } @@ -6046,13 +5955,6 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageFreeExp( // forward to device-platform result = pfnImageFreeExp(hContext, hDevice, hImageMem); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_image_mem_factory.release(hImageMem); - return result; } @@ -6349,13 +6251,6 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesMipmapFreeExp( // forward to device-platform result = pfnMipmapFreeExp(hContext, hDevice, hMem); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_image_mem_factory.release(hMem); - return result; } @@ -6490,13 +6385,6 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesReleaseInteropExp( // forward to device-platform result = pfnReleaseInteropExp(hContext, hDevice, hInteropMem); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_interop_mem_factory.release(hInteropMem); - return result; } @@ -6583,13 +6471,6 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesDestroyExternalSemaphoreExp( result = pfnDestroyExternalSemaphoreExp(hContext, hDevice, hInteropSemaphore); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_interop_semaphore_factory.release(hInteropSemaphore); - return result; } @@ -6833,13 +6714,6 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( // forward to device-platform result = pfnReleaseExp(hCommandBuffer); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_command_buffer_factory.release(hCommandBuffer); - return result; } @@ -7586,13 +7460,6 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseCommandExp( // forward to device-platform result = pfnReleaseCommandExp(hCommand); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - // release loader handle - ur_exp_command_buffer_command_factory.release(hCommand); - return result; }