From 52d58a88904da39c374e44a6a8ae0e4dcca5b71a Mon Sep 17 00:00:00 2001 From: Andreas Hehn Date: Wed, 30 Sep 2020 14:24:09 +0200 Subject: [PATCH] Fixed CubDebug usage in CachingDeviceAllocator::DeviceAllocate --- cub/util_allocator.cuh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cub/util_allocator.cuh b/cub/util_allocator.cuh index fa03996f0b..58c0ceb5e9 100644 --- a/cub/util_allocator.cuh +++ b/cub/util_allocator.cuh @@ -405,8 +405,22 @@ struct CachingDeviceAllocator // To prevent races with reusing blocks returned by the host but still // in use by the device, only consider cached blocks that are // either (from the active stream) or (from an idle stream) - if ((active_stream == block_itr->associated_stream) || - (CubDebug(cudaEventQuery(block_itr->ready_event) != cudaErrorNotReady))) + bool is_reusable = false; + if (active_stream == block_itr->associated_stream) + { + is_reusable = true; + } + else + { + const cudaError_t event_status = cudaEventQuery(block_itr->ready_event); + if(event_status != cudaErrorNotReady) + { + CubDebug(event_status); + is_reusable = true; + } + } + + if(is_reusable) { // Reuse existing cache block. Insert into live blocks. found = true;