[PCL] Fix namespace and VS2022 error C3052 (#23273)

* Fix namespace clashing between cub and thrust::cub.

Fix VS2022 error C3052: 'k': variable doesn't appear in a data-sharing clause under a default(none) clause

* update version
This commit is contained in:
Frank 2022-03-01 05:54:28 +08:00 committed by GitHub
parent 8a7ff6452e
commit b9bd699e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 159 additions and 2 deletions

View File

@ -0,0 +1,20 @@
diff --git a/common/src/fft/kiss_fft.c b/common/src/fft/kiss_fft.c
index a996887..37232bd 100644
--- a/common/src/fft/kiss_fft.c
+++ b/common/src/fft/kiss_fft.c
@@ -260,11 +260,13 @@ void kf_work(
#if (defined _OPENMP && (_OPENMP <= 201307)) || (defined __GNUC__ && (__GNUC__ >= 6 && __GNUC__ < 9))
#pragma omp parallel for \
default(none) \
- shared(f, factors, Fout, in_stride)
+ shared(f, factors, Fout, in_stride) \
+ private(k)
#else
#pragma omp parallel for \
default(none) \
- shared(f, factors, Fout, fstride, in_stride, m, p, st)
+ shared(f, factors, Fout, fstride, in_stride, m, p, st) \
+ private(k)
#endif
for (k=0;k<p;++k)
kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st);

View File

@ -0,0 +1,130 @@
diff --git a/gpu/features/src/centroid.cu b/gpu/features/src/centroid.cu
index 045fe6f..3e9ef8b 100644
--- a/gpu/features/src/centroid.cu
+++ b/gpu/features/src/centroid.cu
@@ -44,7 +44,6 @@
#include "pcl/gpu/utils/device/vector_math.hpp"
-using namespace thrust;
namespace pcl
{
@@ -124,9 +123,10 @@ float3 pcl::device::getMaxDistance(const DeviceArray<PointT>& cloud, const float
thrust::counting_iterator<int> ce = cf + cloud.size();
thrust::tuple<float, int> init(0.f, 0);
- thrust::maximum< tuple<float, int> > op;
+ thrust::maximum<thrust::tuple<float, int>> op;
- tuple<float, int> res = transform_reduce(
+ thrust::tuple<float, int> res =
+ transform_reduce(
make_zip_iterator(make_tuple( src_beg, cf )),
make_zip_iterator(make_tuple( src_beg, ce )),
TupleDistCvt(pivot), init, op);
@@ -151,9 +151,9 @@ float3 pcl::device::getMaxDistance(const DeviceArray<PointT>& cloud, const Indic
thrust::counting_iterator<int> ce = cf + indices.size();
thrust::tuple<float, int> init(0.f, 0);
- thrust::maximum< tuple<float, int> > op;
+ thrust::maximum<thrust::tuple<float, int>> op;
- tuple<float, int> res = transform_reduce(
+ thrust::tuple<float, int> res = transform_reduce(
make_zip_iterator(make_tuple( make_permutation_iterator(src_beg, map_beg), cf )),
make_zip_iterator(make_tuple( make_permutation_iterator(src_beg, map_end), ce )),
TupleDistCvt(pivot), init, op);
diff --git a/gpu/octree/src/cuda/bfrs.cu b/gpu/octree/src/cuda/bfrs.cu
index d392f67..0635e1e 100644
--- a/gpu/octree/src/cuda/bfrs.cu
+++ b/gpu/octree/src/cuda/bfrs.cu
@@ -43,7 +43,6 @@
#include "cuda.h"
-using namespace thrust;
namespace pcl
{
@@ -80,11 +79,11 @@ void pcl::device::bruteForceRadiusSearch(const OctreeImpl::PointCloud& cloud, co
InSphere cond(query.x, query.y, query.z, radius);
- device_ptr<const PointType> cloud_ptr((const PointType*)cloud.ptr());
- device_ptr<int> res_ptr(buffer.ptr());
+ thrust::device_ptr<const PointType> cloud_ptr((const PointType*)cloud.ptr());
+ thrust::device_ptr<int> res_ptr(buffer.ptr());
- counting_iterator<int> first(0);
- counting_iterator<int> last = first + cloud.size();
+ thrust::counting_iterator<int> first(0);
+ thrust::counting_iterator<int> last = first + cloud.size();
//main bottle neck is a kernel call overhead/allocs
//work time for 871k points ~0.8ms
diff --git a/gpu/octree/src/cuda/octree_builder.cu b/gpu/octree/src/cuda/octree_builder.cu
index dfd2093..faad764 100644
--- a/gpu/octree/src/cuda/octree_builder.cu
+++ b/gpu/octree/src/cuda/octree_builder.cu
@@ -51,7 +51,6 @@
#include <thrust/device_ptr.h>
using namespace pcl::gpu;
-using namespace thrust;
namespace pcl
{
@@ -316,7 +315,7 @@ void pcl::device::OctreeImpl::build()
// 3 * sizeof(int) => +1 row
const int transaction_size = 128 / sizeof(int);
- int cols = max<int>(points_num, transaction_size * 4);
+ int cols = std::max<int>(points_num, transaction_size * 4);
int rows = 10 + 1; // = 13
storage.create(rows, cols);
@@ -338,8 +337,8 @@ void pcl::device::OctreeImpl::build()
{
//ScopeTimer timer("reduce-morton-sort-permutations");
- device_ptr<PointType> beg(points.ptr());
- device_ptr<PointType> end = beg + points.size();
+ thrust::device_ptr<PointType> beg(points.ptr());
+ thrust::device_ptr<PointType> end = beg + points.size();
{
PointType atmax, atmin;
@@ -355,15 +354,15 @@ void pcl::device::OctreeImpl::build()
octreeGlobal.maxp = make_float3(maxp.x, maxp.y, maxp.z);
}
- device_ptr<int> codes_beg(codes.ptr());
- device_ptr<int> codes_end = codes_beg + codes.size();
+ thrust::device_ptr<int> codes_beg(codes.ptr());
+ thrust::device_ptr<int> codes_end = codes_beg + codes.size();
{
//ScopeTimer timer("morton");
thrust::transform(beg, end, codes_beg, CalcMorton(octreeGlobal.minp, octreeGlobal.maxp));
}
- device_ptr<int> indices_beg(indices.ptr());
- device_ptr<int> indices_end = indices_beg + indices.size();
+ thrust::device_ptr<int> indices_beg(indices.ptr());
+ thrust::device_ptr<int> indices_end = indices_beg + indices.size();
{
//ScopeTimer timer("sort");
thrust::sequence(indices_beg, indices_end);
@@ -378,9 +377,9 @@ void pcl::device::OctreeImpl::build()
}
{
- device_ptr<float> xs(points_sorted.ptr(0));
- device_ptr<float> ys(points_sorted.ptr(1));
- device_ptr<float> zs(points_sorted.ptr(2));
+ thrust::device_ptr<float> xs(points_sorted.ptr(0));
+ thrust::device_ptr<float> ys(points_sorted.ptr(1));
+ thrust::device_ptr<float> zs(points_sorted.ptr(2));
//ScopeTimer timer("perm2");
thrust::transform(make_permutation_iterator(beg, indices_beg),
make_permutation_iterator(end, indices_end),

View File

@ -14,6 +14,8 @@ vcpkg_from_github(
remove-broken-targets.patch
fix-cmake_find_library_suffixes.patch
fix-pkgconfig.patch # Remove this patch in the next update
fix-namespace-cub.patch # Remove this patch in the next update
fix-error-C3052.patch # Remove this patch in the next update
fix-find-libusb.patch
install-examples.patch
no-absolute.patch

View File

@ -1,7 +1,7 @@
{
"name": "pcl",
"version": "1.12.0",
"port-version": 4,
"port-version": 5,
"description": "Point Cloud Library (PCL) is open source library for 2D/3D image and point cloud processing.",
"homepage": "https://github.com/PointCloudLibrary/pcl",
"license": "BSD-3-Clause",

View File

@ -5250,7 +5250,7 @@
},
"pcl": {
"baseline": "1.12.0",
"port-version": 4
"port-version": 5
},
"pcre": {
"baseline": "8.45",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "5e5ebb57bf0a08e7eab28fe3571ebaa55c3d4ba8",
"version": "1.12.0",
"port-version": 5
},
{
"git-tree": "7e54ab86574dfc901275996e282f8db5c6c9c3fb",
"version": "1.12.0",