From e4c187a4be46682a989165c38bc6a8d8324554b9 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 7 Jan 2019 13:25:18 +0100 Subject: [PATCH] [WIP] into async re-work: complete GOMP_OFFLOAD_openacc_async_synchronize, GOMP_OFFLOAD_openacc_async_serialize interface changes --- libgomp/libgomp-plugin.h | 4 ++-- libgomp/plugin/plugin-nvptx.c | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libgomp/libgomp-plugin.h b/libgomp/libgomp-plugin.h index e3c031a282a1..ce3ae125e208 100644 --- a/libgomp/libgomp-plugin.h +++ b/libgomp/libgomp-plugin.h @@ -115,8 +115,8 @@ extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *); extern struct goacc_asyncqueue *GOMP_OFFLOAD_openacc_async_construct (void); extern bool GOMP_OFFLOAD_openacc_async_destruct (struct goacc_asyncqueue *); extern int GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *); -extern void GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *); -extern void GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *, +extern bool GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *); +extern bool GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *, struct goacc_asyncqueue *); extern void GOMP_OFFLOAD_openacc_async_queue_callback (struct goacc_asyncqueue *, void (*)(void *), void *); diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index f42cbf488a79..12f87ba7be4d 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -1395,22 +1395,35 @@ GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *aq) return -1; } -void +bool GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *aq) { - //TODO Is this safe to call, or might this cause deadlock if something's locked? - CUDA_CALL_ASSERT (cuStreamSynchronize, aq->cuda_stream); + CUresult r = CUDA_CALL_NOCHECK (cuStreamSynchronize, aq->cuda_stream); + return r == CUDA_SUCCESS; } -void +bool GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *aq1, struct goacc_asyncqueue *aq2) { + CUresult r; CUevent e; - //TODO Are these safe to call, or might this cause deadlock if something's locked? - CUDA_CALL_ASSERT (cuEventCreate, &e, CU_EVENT_DISABLE_TIMING); - CUDA_CALL_ASSERT (cuEventRecord, e, aq1->cuda_stream); - CUDA_CALL_ASSERT (cuStreamWaitEvent, aq2->cuda_stream, e, 0); + r = CUDA_CALL_NOCHECK (cuEventCreate, &e, CU_EVENT_DISABLE_TIMING); + if (r != CUDA_SUCCESS) + return false; + r = CUDA_CALL_NOCHECK (cuEventRecord, e, aq1->cuda_stream); + if (r != CUDA_SUCCESS) + { + //TODO "cuEventDestroy"? + return false; + } + r = CUDA_CALL_NOCHECK (cuStreamWaitEvent, aq2->cuda_stream, e, 0); + if (r != CUDA_SUCCESS) + { + //TODO "cuEventDestroy"? + return false; + } + return true; } static void -- 2.17.1