diff --git a/include/ur_api.h b/include/ur_api.h index 3f1100b51a..1705515d76 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -8314,7 +8314,7 @@ urCommandBufferRetainExp( /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferReleaseExp( - ur_exp_command_buffer_handle_t hCommandBuffer ///< [in][release] Handle of the command-buffer object. + ur_exp_command_buffer_handle_t &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ); /////////////////////////////////////////////////////////////////////////////// diff --git a/include/ur_ddi.h b/include/ur_ddi.h index b90895871d..083f8d6761 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1904,7 +1904,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferRetainExp_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urCommandBufferReleaseExp typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferReleaseExp_t)( - ur_exp_command_buffer_handle_t); + ur_exp_command_buffer_handle_t&); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urCommandBufferFinalizeExp diff --git a/source/adapters/cuda/command_buffer.cpp b/source/adapters/cuda/command_buffer.cpp index 8d21a93c75..b739d6419c 100644 --- a/source/adapters/cuda/command_buffer.cpp +++ b/source/adapters/cuda/command_buffer.cpp @@ -21,12 +21,13 @@ namespace { ur_result_t -commandBufferReleaseInternal(ur_exp_command_buffer_handle_t CommandBuffer) { +commandBufferReleaseInternal(ur_exp_command_buffer_handle_t &CommandBuffer) { if (CommandBuffer->decrementInternalReferenceCount() != 0) { return UR_RESULT_SUCCESS; } delete CommandBuffer; + CommandBuffer = nullptr; return UR_RESULT_SUCCESS; } @@ -320,7 +321,7 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) { } UR_APIEXPORT ur_result_t UR_APICALL -urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) { +urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t &hCommandBuffer) { if (hCommandBuffer->decrementExternalReferenceCount() == 0) { // External ref count has reached zero, internal release of created // commands. diff --git a/source/adapters/hip/command_buffer.cpp b/source/adapters/hip/command_buffer.cpp index d9438eeb9c..14659060df 100644 --- a/source/adapters/hip/command_buffer.cpp +++ b/source/adapters/hip/command_buffer.cpp @@ -23,12 +23,13 @@ namespace { ur_result_t -commandBufferReleaseInternal(ur_exp_command_buffer_handle_t CommandBuffer) { +commandBufferReleaseInternal(ur_exp_command_buffer_handle_t &CommandBuffer) { if (CommandBuffer->decrementInternalReferenceCount() != 0) { return UR_RESULT_SUCCESS; } delete CommandBuffer; + CommandBuffer = nullptr; return UR_RESULT_SUCCESS; } @@ -303,7 +304,7 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) { } UR_APIEXPORT ur_result_t UR_APICALL -urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) { +urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t &hCommandBuffer) { if (hCommandBuffer->decrementExternalReferenceCount() == 0) { // External ref count has reached zero, internal release of created // commands. diff --git a/source/adapters/level_zero/command_buffer.cpp b/source/adapters/level_zero/command_buffer.cpp index d9dba22970..73795c9ccd 100644 --- a/source/adapters/level_zero/command_buffer.cpp +++ b/source/adapters/level_zero/command_buffer.cpp @@ -699,11 +699,12 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t CommandBuffer) { } UR_APIEXPORT ur_result_t UR_APICALL -urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t CommandBuffer) { +urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t &CommandBuffer) { if (!CommandBuffer->RefCount.decrementAndTest()) return UR_RESULT_SUCCESS; delete CommandBuffer; + CommandBuffer = nullptr; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/mock/ur_mockddi.cpp b/source/adapters/mock/ur_mockddi.cpp index 775ea9ef37..bd919768b5 100644 --- a/source/adapters/mock/ur_mockddi.cpp +++ b/source/adapters/mock/ur_mockddi.cpp @@ -8198,7 +8198,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( /// @brief Intercept function for urCommandBufferReleaseExp __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t - hCommandBuffer ///< [in][release] Handle of the command-buffer object. + &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) try { ur_result_t result = UR_RESULT_SUCCESS; diff --git a/source/adapters/native_cpu/command_buffer.cpp b/source/adapters/native_cpu/command_buffer.cpp index fde6c03b86..7db3ce15f0 100644 --- a/source/adapters/native_cpu/command_buffer.cpp +++ b/source/adapters/native_cpu/command_buffer.cpp @@ -33,7 +33,7 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t) { } UR_APIEXPORT ur_result_t UR_APICALL -urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t) { +urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t &) { detail::ur::die("Experimental Command-buffer feature is not " "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; diff --git a/source/adapters/opencl/command_buffer.cpp b/source/adapters/opencl/command_buffer.cpp index 5698f36928..6a46eb7b84 100644 --- a/source/adapters/opencl/command_buffer.cpp +++ b/source/adapters/opencl/command_buffer.cpp @@ -13,12 +13,13 @@ namespace { ur_result_t -commandBufferReleaseInternal(ur_exp_command_buffer_handle_t CommandBuffer) { +commandBufferReleaseInternal(ur_exp_command_buffer_handle_t &CommandBuffer) { if (CommandBuffer->decrementInternalReferenceCount() != 0) { return UR_RESULT_SUCCESS; } delete CommandBuffer; + CommandBuffer = nullptr; return UR_RESULT_SUCCESS; } @@ -109,7 +110,7 @@ urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) { } UR_APIEXPORT ur_result_t UR_APICALL -urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) { +urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t &hCommandBuffer) { if (hCommandBuffer->decrementExternalReferenceCount() == 0) { // External ref count has reached zero, internal release of created // commands. diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index ff0491e1d1..c7c9fddb55 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -6367,7 +6367,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( /// @brief Intercept function for urCommandBufferReleaseExp __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t - hCommandBuffer ///< [in][release] Handle of the command-buffer object. + &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) { auto pfnReleaseExp = getContext()->urDdiTable.CommandBufferExp.pfnReleaseExp; diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 09c038edcc..f7c29a04fa 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -7892,7 +7892,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( /// @brief Intercept function for urCommandBufferReleaseExp __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t - hCommandBuffer ///< [in][release] Handle of the command-buffer object. + &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) { auto pfnReleaseExp = getContext()->urDdiTable.CommandBufferExp.pfnReleaseExp; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 274072431f..a71cb63e48 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -6996,7 +6996,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferRetainExp( /// @brief Intercept function for urCommandBufferReleaseExp __urdlllocal ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t - hCommandBuffer ///< [in][release] Handle of the command-buffer object. + &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) { ur_result_t result = UR_RESULT_SUCCESS; diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 50c52f252a..ec528aca90 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -7418,7 +7418,7 @@ ur_result_t UR_APICALL urCommandBufferRetainExp( /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t - hCommandBuffer ///< [in][release] Handle of the command-buffer object. + &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) try { auto pfnReleaseExp = ur_lib::getContext()->urDdiTable.CommandBufferExp.pfnReleaseExp; diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 2831123d96..05ad9eb988 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -6299,7 +6299,7 @@ ur_result_t UR_APICALL urCommandBufferRetainExp( /// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY ur_result_t UR_APICALL urCommandBufferReleaseExp( ur_exp_command_buffer_handle_t - hCommandBuffer ///< [in][release] Handle of the command-buffer object. + &hCommandBuffer ///< [in][release] Handle of the command-buffer object. ) { ur_result_t result = UR_RESULT_SUCCESS; return result;