Skip to content

Parallel Surface Reconstuction #2148

Open
@yonkahlon

Description

@yonkahlon

Your Environment

  • Operating System and version: Windows 10
  • Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506
  • PCL Version: 1.8.1

Expected Behavior

Running Poisson surface reconstruction on separate point clouds each in separate threads should works without crashing

Current Behavior

An Access Violation Exceptions is thrown.

Possible Solution

Don't use static memory:

set MEMORY_ALLOCATOR_BLOCK_SIZE to zero in the following files:

#define MEMORY_ALLOCATOR_BLOCK_SIZE 1<<12

&

#define MEMORY_ALLOCATOR_BLOCK_SIZE 1<<12

To test the effect on performance I did a really basic test. Using a single point cloud, default Poisson Recon settings and running on a single thread, I measured how long it takes to perform the reconstruction. The results:

Debug build, static memory, duration: 42 483 037 μs
Debug build, dynamic memory, duration: 40 880 744 μs
Release build, static memory, duration: 4 066 210 μs
Release build, dynamic memory, duration: 4 177 797 μs

At first glace it seems there is minimal performance effect, so what is the rational of using static memory?

Code to Reproduce

#define PCL_NO_PRECOMPILE

#include <thread>
#include <vector>

#include <pcl/point_types.h>
#include <pcl/surface/poisson.h>
#include <pcl/io/ply_io.h>

pcl::PolygonMesh mesh_1;
pcl::PolygonMesh mesh_2;
pcl::PointCloud<pcl::PointNormal>::Ptr cloud_in_1(new pcl::PointCloud<pcl::PointNormal>());
pcl::PointCloud<pcl::PointNormal>::Ptr cloud_in_2(new pcl::PointCloud<pcl::PointNormal>());

void thread1Process()
{
	pcl::Poisson<pcl::PointNormal> surf_con;

	surf_con.setInputCloud(cloud_in_1);
	surf_con.performReconstruction(mesh_1);
}

int main(int argc, char* argv[])
{
	//------------------ LOAD FILES ------------------//
	std::string path_dir = "C:\\Projects\\Snugg\\2.Development\\4.Repo\\temp\\MeasurementFinder\\build\\000Yon\\temp_m_f.ply";

	pcl::PLYReader reader;
	reader.read(path_dir, *cloud_in_1);
	reader.read(path_dir, *cloud_in_2);

	std::thread t1(thread1Process);

	pcl::Poisson<pcl::PointNormal> surf_con;

	surf_con.setInputCloud(cloud_in_2);
	surf_con.performReconstruction(mesh_2);
	
	t1.join();

	pcl::io::savePLYFile("mesh_1.ply", mesh_1);
	pcl::io::savePLYFile("mesh_2.ply", mesh_2);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions