Skip to content

Commit

Permalink
Apply code checks reported in cms-sw#25647 (cms-sw#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard authored Jan 14, 2019
1 parent 854b139 commit e0169a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
33 changes: 16 additions & 17 deletions HeterogeneousCore/CUDAServices/src/CachingDeviceAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
* thread-safe and capable of managing device allocations on multiple devices.
******************************************************************************/

#include <cub/util_debug.cuh>

#include <set>
#include <cmath>
#include <map>
#include <set>

#include <cub/util_debug.cuh>
#include <cub/host/mutex.cuh>
#include <math.h>

/// CUB namespace
namespace notcub {
Expand Down Expand Up @@ -139,18 +138,18 @@ struct CachingDeviceAllocator
bytes(0),
bin(INVALID_BIN),
device(device),
associated_stream(0),
ready_event(0)
associated_stream(nullptr),
ready_event(nullptr)
{}

// Constructor (suitable for searching maps for a range of suitable blocks, given a device)
BlockDescriptor(int device) :
d_ptr(NULL),
d_ptr(nullptr),
bytes(0),
bin(INVALID_BIN),
device(device),
associated_stream(0),
ready_event(0)
associated_stream(nullptr),
ready_event(nullptr)
{}

// Comparison functor for comparing device pointers
Expand Down Expand Up @@ -356,12 +355,12 @@ struct CachingDeviceAllocator
* streams when all prior work submitted to \p active_stream has completed.
*/
cudaError_t DeviceAllocate(
int device, ///< [in] Device on which to place the allocation
void **d_ptr, ///< [out] Reference to pointer to the allocation
size_t bytes, ///< [in] Minimum number of bytes for the allocation
cudaStream_t active_stream = 0) ///< [in] The stream to be associated with this allocation
int device, ///< [in] Device on which to place the allocation
void **d_ptr, ///< [out] Reference to pointer to the allocation
size_t bytes, ///< [in] Minimum number of bytes for the allocation
cudaStream_t active_stream = nullptr) ///< [in] The stream to be associated with this allocation
{
*d_ptr = NULL;
*d_ptr = nullptr;
int entrypoint_device = INVALID_DEVICE_ORDINAL;
cudaError_t error = cudaSuccess;

Expand Down Expand Up @@ -529,9 +528,9 @@ struct CachingDeviceAllocator
* streams when all prior work submitted to \p active_stream has completed.
*/
cudaError_t DeviceAllocate(
void **d_ptr, ///< [out] Reference to pointer to the allocation
size_t bytes, ///< [in] Minimum number of bytes for the allocation
cudaStream_t active_stream = 0) ///< [in] The stream to be associated with this allocation
void **d_ptr, ///< [out] Reference to pointer to the allocation
size_t bytes, ///< [in] Minimum number of bytes for the allocation
cudaStream_t active_stream = nullptr) ///< [in] The stream to be associated with this allocation
{
return DeviceAllocate(INVALID_DEVICE_ORDINAL, d_ptr, bytes, active_stream);
}
Expand Down
10 changes: 5 additions & 5 deletions HeterogeneousCore/CUDAServices/src/CachingHostAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
* thread-safe.
******************************************************************************/

#include <set>
#include <map>
#include <cmath>
#include <map>
#include <set>

#include <cub/util_debug.cuh>
#include <cub/host/mutex.cuh>
Expand Down Expand Up @@ -343,9 +343,9 @@ struct CachingHostAllocator
* Once freed, the allocation becomes available immediately for reuse.
*/
cudaError_t HostAllocate(
void **d_ptr, ///< [out] Reference to pointer to the allocation
size_t bytes, ///< [in] Minimum number of bytes for the allocation
cudaStream_t active_stream = nullptr) ///< [in] The stream to be associated with this allocation
void **d_ptr, ///< [out] Reference to pointer to the allocation
size_t bytes, ///< [in] Minimum number of bytes for the allocation
cudaStream_t active_stream = nullptr) ///< [in] The stream to be associated with this allocation
{
*d_ptr = nullptr;
int device = INVALID_DEVICE_ORDINAL;
Expand Down

0 comments on commit e0169a3

Please sign in to comment.