Heap corruption when constructing AABB tree with OPENMP

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Heap corruption when constructing AABB tree with OPENMP

Yifang Zhao

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

Reply | Threaded
Open this post in threaded view
|

Re: Heap corruption when constructing AABB tree with OPENMP

andreas.fabri

What kernel do you use?

On 2/22/2020 9:51 PM, Yifang Zhao wrote:

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

RE: Heap corruption when constructing AABB tree with OPENMP

Yifang Zhao

I am using EPEC Kernel.

 

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: 2020
222 21:54
To: [hidden email]
Subject: Re: [cgal-discuss] Heap corruption when constructing AABB tree with OPENMP

 

What kernel do you use?

On 2/22/2020 9:51 PM, Yifang Zhao wrote:

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

Re: Heap corruption when constructing AABB tree with OPENMP

andreas.fabri

Epec is currently not multi-threading safe.
The AABB Tree does not need exact constructions, so we should think
about a way to use the points/triangles/planes for Epic, together with
the face handles of the Polyhedron parameterized with Epec.

andreas

On 2/22/2020 9:55 PM, Yifang Zhao wrote:

I am using EPEC Kernel.

 

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: 2020
222 21:54
To: [hidden email]
Subject: Re: [cgal-discuss] Heap corruption when constructing AABB tree with OPENMP

 

What kernel do you use?

On 2/22/2020 9:51 PM, Yifang Zhao wrote:

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

Re: Heap corruption when constructing AABB tree with OPENMP

Yifang Zhao
But I need to compute the exact intersections between a plane and the polyhedron. That’s why I am using epec for aabbtree. Is there any solutions to do this? Or it is not possible yet?

Sent from my iPhone

On Feb 22, 2020, at 10:28 PM, Andreas Fabri <[hidden email]> wrote:



Epec is currently not multi-threading safe.
The AABB Tree does not need exact constructions, so we should think
about a way to use the points/triangles/planes for Epic, together with
the face handles of the Polyhedron parameterized with Epec.

andreas

On 2/22/2020 9:55 PM, Yifang Zhao wrote:

I am using EPEC Kernel.

 

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: 2020
222 21:54
To: [hidden email]
Subject: Re: [cgal-discuss] Heap corruption when constructing AABB tree with OPENMP

 

What kernel do you use?

On 2/22/2020 9:51 PM, Yifang Zhao wrote:

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

Re: Heap corruption when constructing AABB tree with OPENMP

andreas.fabri


You could determine what primitives intersect in parallel with Epic and

OutputIterator CGAL::AABB_tree< Tr >::all_intersected_primitives ( const Query &  query,


OutputIterator  out 

)
const

https://doc.cgal.org/latest/AABB_tree/classCGAL_1_1AABB__tree.html#a9f40594599eded5f9a79f74186710697

and then in a sequential pass compute the intersections.


By the way, did you have a look at the slicer:

https://doc.cgal.org/latest/Polygon_mesh_processing/index.html#title52

Best,

Andreas


On 2/22/2020 11:12 PM, Yifang Zhao wrote:
But I need to compute the exact intersections between a plane and the polyhedron. That’s why I am using epec for aabbtree. Is there any solutions to do this? Or it is not possible yet?

Sent from my iPhone

On Feb 22, 2020, at 10:28 PM, Andreas Fabri [hidden email] wrote:



Epec is currently not multi-threading safe.
The AABB Tree does not need exact constructions, so we should think
about a way to use the points/triangles/planes for Epic, together with
the face handles of the Polyhedron parameterized with Epec.

andreas

On 2/22/2020 9:55 PM, Yifang Zhao wrote:

I am using EPEC Kernel.

 

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: 2020
222 21:54
To: [hidden email]
Subject: Re: [cgal-discuss] Heap corruption when constructing AABB tree with OPENMP

 

What kernel do you use?

On 2/22/2020 9:51 PM, Yifang Zhao wrote:

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
Reply | Threaded
Open this post in threaded view
|

Re: Heap corruption when constructing AABB tree with OPENMP

Yifang Zhao
Brilliant! It really helps me a lot! Btw, the Package you recommend is quite related to my work and I will dig into it later! Thanks!

Sent from my iPhone

On Feb 22, 2020, at 11:25 PM, Andreas Fabri <[hidden email]> wrote:




You could determine what primitives intersect in parallel with Epic and

OutputIterator CGAL::AABB_tree< Tr >::all_intersected_primitives ( const Query &  query,


OutputIterator  out 

)
const

https://doc.cgal.org/latest/AABB_tree/classCGAL_1_1AABB__tree.html#a9f40594599eded5f9a79f74186710697

and then in a sequential pass compute the intersections.


By the way, did you have a look at the slicer:

https://doc.cgal.org/latest/Polygon_mesh_processing/index.html#title52

Best,

Andreas


On 2/22/2020 11:12 PM, Yifang Zhao wrote:
But I need to compute the exact intersections between a plane and the polyhedron. That’s why I am using epec for aabbtree. Is there any solutions to do this? Or it is not possible yet?

Sent from my iPhone

On Feb 22, 2020, at 10:28 PM, Andreas Fabri [hidden email] wrote:



Epec is currently not multi-threading safe.
The AABB Tree does not need exact constructions, so we should think
about a way to use the points/triangles/planes for Epic, together with
the face handles of the Polyhedron parameterized with Epec.

andreas

On 2/22/2020 9:55 PM, Yifang Zhao wrote:

I am using EPEC Kernel.

 

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: 2020
222 21:54
To: [hidden email]
Subject: Re: [cgal-discuss] Heap corruption when constructing AABB tree with OPENMP

 

What kernel do you use?

On 2/22/2020 9:51 PM, Yifang Zhao wrote:

I have a for loop containing approximately 1,000,000 iterations of calling AABBTree.all_intersections() method. Thus, I use #pragma omp parallel for to speed up the program. However, I got an error as "A heap has been corrupted". The cpp file is roughly like the following:

Polyhedron polyhedron;
Facet_tree m_facet_tree(faces(m_polyhedron).first, faces(m_polyhedron).second, m_polyhedon);
 
#pragma omp parallel for
for (int i = 0; i<100; ++i){
    Plane plane = Plane(1, 0, 0, 0);
 
    // Compute intersections
    typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
    Intersections intersections;
    m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
}

Finally, The program will break here:

    ~Handle()
    {
    if ( PTR && (--PTR->count == 0))
        delete PTR;
    }

What are the possible reasons that cause this problem? Thanks a lot!

Kind Regards,

Yifang Zhao.

 

Sent from Mail for Windows 10

 

-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri
-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri