From b7ddcc0807967750e3c884326ed4c53c05cde81f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 12 Jan 2023 14:39:46 +0100 Subject: [PATCH] nvptx: Avoid deadlock in 'cuStreamAddCallback' callback, error case When we invoke 'GOMP_PLUGIN_fatal', this attempts to shut down the device (..., which may deadlock); that's generally problematic: per "'cuStreamAddCallback' [...] Callbacks must not make any CUDA API calls". Given that eventually we must reach a host/device synchronization point (latest when the device is shut down at program termination), and the non-'CUDA_SUCCESS' will be upheld until then, it does seem safe to replace this 'GOMP_PLUGIN_fatal' with 'GOMP_PLUGIN_error'. libgomp/ * plugin/plugin-nvptx.c (cuda_callback_wrapper): Invoke 'GOMP_PLUGIN_error' instead of 'GOMP_PLUGIN_fatal'. --- libgomp/plugin/plugin-nvptx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 395639537e83..cdb3d435bdc8 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -1927,7 +1927,7 @@ static void cuda_callback_wrapper (CUstream stream, CUresult res, void *ptr) { if (res != CUDA_SUCCESS) - GOMP_PLUGIN_fatal ("%s error: %s", __FUNCTION__, cuda_error (res)); + GOMP_PLUGIN_error ("%s error: %s", __FUNCTION__, cuda_error (res)); struct nvptx_callback *cb = (struct nvptx_callback *) ptr; cb->fn (cb->ptr); free (ptr); -- 2.39.0