Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nullptr in module gpu #3011

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace pcl

T* data;

__PCL_GPU_HOST_DEVICE__ DevPtr() : data(0) {}
__PCL_GPU_HOST_DEVICE__ DevPtr() : data(nullptr) {}
__PCL_GPU_HOST_DEVICE__ DevPtr(T* data_arg) : data(data_arg) {}

__PCL_GPU_HOST_DEVICE__ size_t elemSize() const { return elem_size; }
Expand Down
20 changes: 10 additions & 10 deletions gpu/containers/src/device_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ bool pcl::gpu::DeviceMemory2D::empty() const { throw_nogpu(); }

//////////////////////// DeviceArray /////////////////////////////

pcl::gpu::DeviceMemory::DeviceMemory() : data_(0), sizeBytes_(0), refcount_(0) {}
pcl::gpu::DeviceMemory::DeviceMemory(void *ptr_arg, size_t sizeBytes_arg) : data_(ptr_arg), sizeBytes_(sizeBytes_arg), refcount_(0){}
pcl::gpu::DeviceMemory::DeviceMemory(size_t sizeBtes_arg) : data_(0), sizeBytes_(0), refcount_(0) { create(sizeBtes_arg); }
pcl::gpu::DeviceMemory::DeviceMemory() : data_(nullptr), sizeBytes_(0), refcount_(nullptr) {}
pcl::gpu::DeviceMemory::DeviceMemory(void *ptr_arg, size_t sizeBytes_arg) : data_(ptr_arg), sizeBytes_(sizeBytes_arg), refcount_(nullptr){}
pcl::gpu::DeviceMemory::DeviceMemory(size_t sizeBtes_arg) : data_(nullptr), sizeBytes_(0), refcount_(nullptr) { create(sizeBtes_arg); }
pcl::gpu::DeviceMemory::~DeviceMemory() { release(); }

pcl::gpu::DeviceMemory::DeviceMemory(const DeviceMemory& other_arg)
Expand Down Expand Up @@ -162,9 +162,9 @@ void pcl::gpu::DeviceMemory::release()
delete refcount_;
cudaSafeCall( cudaFree(data_) );
}
data_ = 0;
data_ = nullptr;
sizeBytes_ = 0;
refcount_ = 0;
refcount_ = nullptr;
}

void pcl::gpu::DeviceMemory::upload(const void *host_ptr_arg, size_t sizeBytes_arg)
Expand Down Expand Up @@ -193,16 +193,16 @@ size_t pcl::gpu::DeviceMemory::sizeBytes() const { return sizeBytes_; }

//////////////////////// DeviceArray2D /////////////////////////////

pcl::gpu::DeviceMemory2D::DeviceMemory2D() : data_(0), step_(0), colsBytes_(0), rows_(0), refcount_(0) {}
pcl::gpu::DeviceMemory2D::DeviceMemory2D() : data_(nullptr), step_(0), colsBytes_(0), rows_(0), refcount_(nullptr) {}

pcl::gpu::DeviceMemory2D::DeviceMemory2D(int rows_arg, int colsBytes_arg)
: data_(0), step_(0), colsBytes_(0), rows_(0), refcount_(0)
: data_(nullptr), step_(0), colsBytes_(0), rows_(0), refcount_(nullptr)
{
create(rows_arg, colsBytes_arg);
}

pcl::gpu::DeviceMemory2D::DeviceMemory2D(int rows_arg, int colsBytes_arg, void *data_arg, size_t step_arg)
: data_(data_arg), step_(step_arg), colsBytes_(colsBytes_arg), rows_(rows_arg), refcount_(0) {}
: data_(data_arg), step_(step_arg), colsBytes_(colsBytes_arg), rows_(rows_arg), refcount_(nullptr) {}

pcl::gpu::DeviceMemory2D::~DeviceMemory2D() { release(); }

Expand Down Expand Up @@ -264,9 +264,9 @@ void pcl::gpu::DeviceMemory2D::release()

colsBytes_ = 0;
rows_ = 0;
data_ = 0;
data_ = nullptr;
step_ = 0;
refcount_ = 0;
refcount_ = nullptr;
}

void pcl::gpu::DeviceMemory2D::copyTo(DeviceMemory2D& other) const
Expand Down
2 changes: 1 addition & 1 deletion gpu/containers/src/initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void pcl::gpu::printCudaDeviceInfo(int device)
"Prohibited (no host thread can use ::cudaSetDevice() with this device)",
"Exclusive Process (many threads in one process is able to use ::cudaSetDevice() with this device)",
"Unknown",
NULL
nullptr
};

for(int dev = beg; dev < end; ++dev)
Expand Down
2 changes: 1 addition & 1 deletion gpu/kinfu/include/pcl/gpu/kinfu/kinfu.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace pcl
* \param hint
* \return true if can render 3D view.
*/
bool operator() (const DepthMap& depth, Eigen::Affine3f* hint=NULL);
bool operator() (const DepthMap& depth, Eigen::Affine3f* hint=nullptr);

/** \brief Processes next frame (both depth and color integration). Please call initColorIntegration before invpoking this.
* \param[in] depth next depth frame with values in millimeters
Expand Down
4 changes: 2 additions & 2 deletions gpu/kinfu/tools/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pcl::gpu::CaptureOpenNI::open (int device)
}

xn::NodeInfoList devicesList;
rc = impl_->context.EnumerateProductionTrees ( XN_NODE_TYPE_DEVICE, NULL, devicesList, 0 );
rc = impl_->context.EnumerateProductionTrees ( XN_NODE_TYPE_DEVICE, nullptr, devicesList, nullptr );
if (rc != XN_STATUS_OK)
{
sprintf (impl_->strError, "Init failed: %s\n", xnGetStatusString (rc));
Expand Down Expand Up @@ -276,7 +276,7 @@ pcl::gpu::CaptureOpenNI::grab (PtrStepSz<const unsigned short>& depth, PtrStepSz
else
{
printf ("no image\n");
rgb24.data = 0;
rgb24.data = nullptr;
rgb24.cols = rgb24.rows = rgb24.step = 0;
}

Expand Down
6 changes: 3 additions & 3 deletions gpu/kinfu/tools/kinfu_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ struct ImageView
}

void
showScene (KinfuTracker& kinfu, const PtrStepSz<const KinfuTracker::PixelRGB>& rgb24, bool registration, Eigen::Affine3f* pose_ptr = 0)
showScene (KinfuTracker& kinfu, const PtrStepSz<const KinfuTracker::PixelRGB>& rgb24, bool registration, Eigen::Affine3f* pose_ptr = nullptr)
{
if (pose_ptr)
{
Expand Down Expand Up @@ -818,7 +818,7 @@ struct KinFuApp
if (viz_ && has_image)
{
Eigen::Affine3f viewer_pose = getViewerPose(*scene_cloud_view_.cloud_viewer_);
image_view_.showScene (kinfu_, rgb24, registration_, independent_camera_ ? &viewer_pose : 0);
image_view_.showScene (kinfu_, rgb24, registration_, independent_camera_ ? &viewer_pose : nullptr);
}

if (current_frame_cloud_view_)
Expand Down Expand Up @@ -967,7 +967,7 @@ struct KinFuApp
boost::function<void (const ImagePtr&, const DepthImagePtr&, float constant)> func1_oni = boost::bind (&KinFuApp::source_cb2_oni, this, _1, _2, _3);
boost::function<void (const DepthImagePtr&)> func2_oni = boost::bind (&KinFuApp::source_cb1_oni, this, _1);

bool is_oni = dynamic_cast<pcl::ONIGrabber*>(&capture_) != 0;
bool is_oni = dynamic_cast<pcl::ONIGrabber*>(&capture_) != nullptr;
boost::function<void (const ImagePtr&, const DepthImagePtr&, float constant)> func1 = is_oni ? func1_oni : func1_dev;
boost::function<void (const DepthImagePtr&)> func2 = is_oni ? func2_oni : func2_dev;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pcl::gpu::kinfuLS::StandaloneMarchingCubes<PointT>::getMeshesFromTSDFVector (con
//Get mesh
MeshPtr tmp = getMeshFromTSDFCloud (*tsdf_clouds[i]);

if(tmp != 0)
if(tmp != nullptr)
{
meshes_vector.push_back (tmp);
mesh_counter++;
Expand Down Expand Up @@ -259,7 +259,7 @@ pcl::gpu::kinfuLS::StandaloneMarchingCubes<PointT>::runMarchingCubes ()
//Creating mesh
boost::shared_ptr<pcl::PolygonMesh> mesh_ptr_ = convertTrianglesToMesh (triangles_device);

if(mesh_ptr_ != 0)
if(mesh_ptr_ != nullptr)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_tmp_ptr (new pcl::PointCloud<pcl::PointXYZ>);
fromPCLPointCloud2 ( mesh_ptr_->cloud, *cloud_tmp_ptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace pcl
/** \brief Default constructor*/
tsdf_buffer ()
{
tsdf_memory_start = 0; tsdf_memory_end = 0; tsdf_rolling_buff_origin = 0;
tsdf_memory_start = nullptr; tsdf_memory_end = nullptr; tsdf_rolling_buff_origin = nullptr;
origin_GRID.x = 0; origin_GRID.y = 0; origin_GRID.z = 0;
origin_GRID_global.x = 0.f; origin_GRID_global.y = 0.f; origin_GRID_global.z = 0.f;
origin_metric.x = 0.f; origin_metric.y = 0.f; origin_metric.z = 0.f;
Expand Down
4 changes: 2 additions & 2 deletions gpu/kinfu_large_scale/tools/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pcl::gpu::kinfuLS::CaptureOpenNI::open (int device)
}

xn::NodeInfoList devicesList;
rc = impl_->context.EnumerateProductionTrees ( XN_NODE_TYPE_DEVICE, NULL, devicesList, 0 );
rc = impl_->context.EnumerateProductionTrees ( XN_NODE_TYPE_DEVICE, nullptr, devicesList, nullptr );
if (rc != XN_STATUS_OK)
{
sprintf (impl_->strError, "Init failed: %s\n", xnGetStatusString (rc));
Expand Down Expand Up @@ -276,7 +276,7 @@ pcl::gpu::kinfuLS::CaptureOpenNI::grab (PtrStepSz<const unsigned short>& depth,
else
{
printf ("no image\n");
rgb24.data = 0;
rgb24.data = nullptr;
rgb24.cols = rgb24.rows = rgb24.step = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions gpu/kinfu_large_scale/tools/kinfuLS_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct ImageView
}

void
showScene (KinfuTracker& kinfu, const PtrStepSz<const pcl::gpu::kinfuLS::PixelRGB>& rgb24, bool registration, Eigen::Affine3f* pose_ptr = 0)
showScene (KinfuTracker& kinfu, const PtrStepSz<const pcl::gpu::kinfuLS::PixelRGB>& rgb24, bool registration, Eigen::Affine3f* pose_ptr = nullptr)
{
if (pose_ptr)
{
Expand Down Expand Up @@ -860,7 +860,7 @@ struct KinFuLSApp
if (has_image)
{
Eigen::Affine3f viewer_pose = getViewerPose(scene_cloud_view_.cloud_viewer_);
image_view_.showScene (*kinfu_, rgb24, registration_, independent_camera_ ? &viewer_pose : 0);
image_view_.showScene (*kinfu_, rgb24, registration_, independent_camera_ ? &viewer_pose : nullptr);
}

if (current_frame_cloud_view_)
Expand Down
2 changes: 1 addition & 1 deletion gpu/octree/src/internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace pcl

int *parent;

OctreeGlobal() : nodes(0), codes(0), begs(0), ends(0), nodes_num(0), parent(0) {}
OctreeGlobal() : nodes(nullptr), codes(nullptr), begs(nullptr), ends(nullptr), nodes_num(nullptr), parent(nullptr) {}
};

struct OctreeGlobalWithBox : public OctreeGlobal
Expand Down
2 changes: 1 addition & 1 deletion gpu/octree/src/octree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using namespace std;
//////////////////////////////////////////////////////////////////////////////////////
//////////////// Octree Host Interface implementation ////////////////////////////////

pcl::gpu::Octree::Octree() : cloud_(0), impl(0)
pcl::gpu::Octree::Octree() : cloud_(nullptr), impl(nullptr)
{
Static<sizeof(PointType) == sizeof(OctreeImpl::PointType)>::check();

Expand Down
18 changes: 9 additions & 9 deletions gpu/people/src/cuda/nvidia/NCV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class NCV_EXPORTS NCVMemStackAllocator : public INCVMemAllocator
public:

explicit NCVMemStackAllocator(Ncv32u alignment);
NCVMemStackAllocator(NCVMemoryType memT, size_t capacity, Ncv32u alignment, void *reusePtr=NULL);
NCVMemStackAllocator(NCVMemoryType memT, size_t capacity, Ncv32u alignment, void *reusePtr=nullptr);
virtual ~NCVMemStackAllocator();

virtual NCVStatus alloc(NCVMemSegment &seg, size_t size);
Expand Down Expand Up @@ -535,7 +535,7 @@ class NCVVector

void clear()
{
_ptr = NULL;
_ptr = nullptr;
_length = 0;
_memtype = NCVMemoryTypeNone;
}
Expand All @@ -553,8 +553,8 @@ class NCVVector
this->_length * sizeof(T) >= howMuch &&
howMuch > 0, NCV_MEM_COPY_ERROR);
}
ncvAssertReturn((this->_ptr != NULL || this->_memtype == NCVMemoryTypeNone) &&
(dst._ptr != NULL || dst._memtype == NCVMemoryTypeNone), NCV_NULL_PTR);
ncvAssertReturn((this->_ptr != nullptr || this->_memtype == NCVMemoryTypeNone) &&
(dst._ptr != nullptr || dst._memtype == NCVMemoryTypeNone), NCV_NULL_PTR);

NCVStatus ncvStat = NCV_SUCCESS;
if (this->_memtype != NCVMemoryTypeNone)
Expand Down Expand Up @@ -620,7 +620,7 @@ class NCVVectorAlloc : public NCVVector<T>

NcvBool isMemAllocated() const
{
return (this->allocatedMem.begin.ptr != NULL) || (this->allocator.isCounting());
return (this->allocatedMem.begin.ptr != nullptr) || (this->allocator.isCounting());
}

Ncv32u getAllocatorsAlignment() const
Expand Down Expand Up @@ -707,7 +707,7 @@ class NCVMatrix

void clear()
{
_ptr = NULL;
_ptr = nullptr;
_pitch = 0;
_width = 0;
_height = 0;
Expand All @@ -734,8 +734,8 @@ class NCVMatrix
this->_pitch * this->_height >= howMuch &&
howMuch > 0, NCV_MEM_COPY_ERROR);
}
ncvAssertReturn((this->_ptr != NULL || this->_memtype == NCVMemoryTypeNone) &&
(dst._ptr != NULL || dst._memtype == NCVMemoryTypeNone), NCV_NULL_PTR);
ncvAssertReturn((this->_ptr != nullptr || this->_memtype == NCVMemoryTypeNone) &&
(dst._ptr != nullptr || dst._memtype == NCVMemoryTypeNone), NCV_NULL_PTR);

NCVStatus ncvStat = NCV_SUCCESS;
if (this->_memtype != NCVMemoryTypeNone)
Expand Down Expand Up @@ -849,7 +849,7 @@ class NCVMatrixAlloc : public NCVMatrix<T>

NcvBool isMemAllocated() const
{
return (this->allocatedMem.begin.ptr != NULL) || (this->allocator.isCounting());
return (this->allocatedMem.begin.ptr != nullptr) || (this->allocator.isCounting());
}

Ncv32u getAllocatorsAlignment() const
Expand Down
22 changes: 11 additions & 11 deletions gpu/people/src/face_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ pcl::gpu::people::FaceDetector::loadFromNVBIN(const std::string &filename,
{
size_t readCount;
FILE *fp = fopen(filename.c_str(), "rb");
ncvAssertReturn(fp != NULL, NCV_FILE_ERROR);
ncvAssertReturn(fp != nullptr, NCV_FILE_ERROR);
Ncv32u fileVersion;
readCount = fread(&fileVersion, sizeof(Ncv32u), 1, fp);
PCL_ASSERT_ERROR_PRINT_RETURN(1 == readCount, "return NCV_FILE_ERROR", NCV_FILE_ERROR);
Expand Down Expand Up @@ -502,7 +502,7 @@ pcl::gpu::people::FaceDetector::ncvHaarGetClassifierSize(const std::string &file
if (fext == "nvbin")
{
FILE *fp = fopen(filename.c_str(), "rb");
PCL_ASSERT_ERROR_PRINT_RETURN(fp != NULL, "Return NCV_FILE_ERROR", NCV_FILE_ERROR);
PCL_ASSERT_ERROR_PRINT_RETURN(fp != nullptr, "Return NCV_FILE_ERROR", NCV_FILE_ERROR);
Ncv32u fileVersion;
size_t readCount = fread(&fileVersion, sizeof(Ncv32u), 1, fp);
PCL_ASSERT_ERROR_PRINT_RETURN(1 == readCount, "Return NCV_FILE_ERROR", NCV_FILE_ERROR);
Expand Down Expand Up @@ -588,9 +588,9 @@ pcl::gpu::people::FaceDetector::NCVprocess(pcl::PointCloud<pcl::RGB>&
memcpy(h_src.ptr(), &point.intensity, sizeof(point.intensity));
}

ncv_return_status = h_src.copySolid(d_src, 0);
ncv_return_status = h_src.copySolid(d_src, nullptr);
PCL_ASSERT_NCVSTAT(ncv_return_status);
PCL_ASSERT_CUDA_RETURN(cudaStreamSynchronize(0), NCV_CUDA_ERROR);
PCL_ASSERT_CUDA_RETURN(cudaStreamSynchronize(nullptr), NCV_CUDA_ERROR);

NCV_SKIP_COND_END

Expand All @@ -616,16 +616,16 @@ pcl::gpu::people::FaceDetector::NCVprocess(pcl::PointCloud<pcl::RGB>&
gpu_allocator,
cpu_allocator,
device_properties,
0);
nullptr);

PCL_ASSERT_NCVSTAT(ncv_return_status);
PCL_ASSERT_CUDA_RETURN(cudaStreamSynchronize(0), NCV_CUDA_ERROR);
PCL_ASSERT_CUDA_RETURN(cudaStreamSynchronize(nullptr), NCV_CUDA_ERROR);

NCV_SKIP_COND_BEGIN

ncv_return_status = d_src.copySolid(h_src, 0);
ncv_return_status = d_src.copySolid(h_src, nullptr);
PCL_ASSERT_NCVSTAT(ncv_return_status);
PCL_ASSERT_CUDA_RETURN(cudaStreamSynchronize(0), NCV_CUDA_ERROR);
PCL_ASSERT_CUDA_RETURN(cudaStreamSynchronize(nullptr), NCV_CUDA_ERROR);

// Copy result back into output cloud
for(auto &point : cloud_out.points)
Expand Down Expand Up @@ -680,11 +680,11 @@ pcl::gpu::people::FaceDetector::configure(std::string cascade_file_name)
haar_features_dev_ = new NCVVectorAlloc<HaarFeature64>(*gpu_allocator_, haarNumFeatures);
PCL_ASSERT_ERROR_PRINT_RETURN(haar_features_dev_->isMemAllocated(), "[pcl::gpu::people::FaceDetector::FaceDetector] : Error in cascade GPU allocator", -1);

ncv_return_status = haar_stages_host_->copySolid(*haar_stages_dev_, 0);
ncv_return_status = haar_stages_host_->copySolid(*haar_stages_dev_, nullptr);
PCL_ASSERT_ERROR_PRINT_RETURN(ncv_return_status == NCV_SUCCESS, "[pcl::gpu::people::FaceDetector::FaceDetector] : Error copying cascade to GPU", -1);
ncv_return_status = haar_nodes_host_->copySolid(*haar_nodes_dev_, 0);
ncv_return_status = haar_nodes_host_->copySolid(*haar_nodes_dev_, nullptr);
PCL_ASSERT_ERROR_PRINT_RETURN(ncv_return_status == NCV_SUCCESS, "[pcl::gpu::people::FaceDetector::FaceDetector] : Error copying cascade to GPU", -1);
ncv_return_status = haar_features_host_->copySolid(*haar_features_dev_, 0);
ncv_return_status = haar_features_host_->copySolid(*haar_features_dev_, nullptr);
PCL_ASSERT_ERROR_PRINT_RETURN(ncv_return_status == NCV_SUCCESS, "[pcl::gpu::people::FaceDetector::FaceDetector] : Error copying cascade to GPU", -1);

// Calculate memory requirements and create real allocators
Expand Down
4 changes: 2 additions & 2 deletions gpu/utils/include/pcl/gpu/utils/timers_cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ namespace pcl
cudaEventDestroy(stop_);
}

void start() { cudaEventRecord(start_, 0); }
Timer& stop() { cudaEventRecord(stop_, 0); cudaEventSynchronize(stop_); return *this; }
void start() { cudaEventRecord(start_, nullptr); }
SunBlack marked this conversation as resolved.
Show resolved Hide resolved
Timer& stop() { cudaEventRecord(stop_, nullptr); cudaEventSynchronize(stop_); return *this; }

float time()
{
Expand Down