From 58b6eaf4edb578c368572df8aa430e13e03f6990 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Thu, 20 Dec 2018 18:35:37 +0100 Subject: [PATCH] Need to keep the lock until CUDA event is recorded --- .../CUDAServices/src/CachingHostAllocator.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/HeterogeneousCore/CUDAServices/src/CachingHostAllocator.h b/HeterogeneousCore/CUDAServices/src/CachingHostAllocator.h index 05e8e551404fb..d22d7d960c3d9 100644 --- a/HeterogeneousCore/CUDAServices/src/CachingHostAllocator.h +++ b/HeterogeneousCore/CUDAServices/src/CachingHostAllocator.h @@ -538,9 +538,6 @@ struct CachingHostAllocator } } - // Unlock - mutex.Unlock(); - if (CubDebug(error = cudaGetDevice(&entrypoint_device))) return error; if (entrypoint_device != search_key.device) { if (CubDebug(error = cudaSetDevice(search_key.device))) return error; @@ -550,7 +547,11 @@ struct CachingHostAllocator // Insert the ready event in the associated stream (must have current device set properly) if (CubDebug(error = cudaEventRecord(search_key.ready_event, search_key.associated_stream))) return error; } - else + + // Unlock + mutex.Unlock(); + + if (!recached) { // Free the allocation from the runtime and cleanup the event. if (CubDebug(error = cudaFreeHost(d_ptr))) return error;