Skip to content

Commit

Permalink
avoids clang -Wparentheses warning: using the result of an assignment…
Browse files Browse the repository at this point in the history
… as a condition, resolves NVIDIA#219
  • Loading branch information
ahehn-nv authored and andrewcorrigan committed Oct 19, 2020
1 parent a39e385 commit a1c46bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions cub/util_allocator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion cub/util_device.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ public:

// We don't use `CubDebug` here because we let the user code
// decide whether or not errors are hard errors.
if (payload.error = std::forward<Invocable>(f)(payload.attribute))
payload.error = std::forward<Invocable>(f)(payload.attribute);
if (payload.error)
// Clear the global CUDA error state which may have been
// set by the last call. Otherwise, errors may "leak" to
// unrelated kernel launches.
Expand Down

0 comments on commit a1c46bf

Please sign in to comment.