AABBTree very slow performance when using openmp multithreading

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

AABBTree very slow performance when using openmp multithreading

Rash
It looks like that AABBTree is locked when an other thread is using it.
When you are using a single tree per thread you get the full speed. I am
using the CGAL::Simple_cartesian<double> Kernel.

Runtime 16 secs, independ of #pragma omp parallel for, only one core is
used in system manager (ubuntu):

         #pragma omp parallel for
         for(size_t y = 0; y < number_of_ray_y; y++)
         {
             for(size_t x = 0; x < number_of_ray_x; x++)
             {
                 Ray_intersection hit =
tree.first_intersection(rays[this->transformCoordinates(y,x)]);
            }
        }

Runtime 4 secs 4 cores are used:

#pragma omp parallel
{
        Tree localtree(faces(mesh).first, faces(mesh).second, mesh);
        std::cout << "Start: " << omp_get_wtime() << std::endl;

         size_t tid = omp_get_thread_num();
         size_t number_of_threads = omp_get_num_procs();
         for(size_t y = tid; y < number_of_ray_y; y=y+number_of_threads)
         {
          if(y >= number_of_ray_y)
                 {
                  break;
                }

                 for(size_t x = 0; x < number_of_ray_x; x++)
                 {
Ray_intersection hit =
localtree.first_intersection(rays[this->transformCoordinates(y,x)]);
                }
        }
}


This is very troubling, an acceleration structure can have a pretty huge
memory footprint.  Am I using something wrong?

     typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
     typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
     typedef CGAL::AABB_tree<Traits> Tree;

Kind regards
Rashid

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: AABBTree very slow performance when using openmp multithreading

Rash
Please ignore this mail, the problem was the scene, where only one 1/4
contains geometrie. The better stepping y=y+number_of_threads was
responsible for the speedup. Sorry for wasting your time.

Am 04.07.2018 um 20:32 schrieb Rash:

> It looks like that AABBTree is locked when an other thread is using it.
> When you are using a single tree per thread you get the full speed. I am
> using the CGAL::Simple_cartesian<double> Kernel.
>
> Runtime 16 secs, independ of #pragma omp parallel for, only one core is
> used in system manager (ubuntu):
>
>          #pragma omp parallel for
>          for(size_t y = 0; y < number_of_ray_y; y++)
>          {
>              for(size_t x = 0; x < number_of_ray_x; x++)
>              {
>                  Ray_intersection hit =
> tree.first_intersection(rays[this->transformCoordinates(y,x)]);
>          }
>      }
>
> Runtime 4 secs 4 cores are used:
>
> #pragma omp parallel
> {
>      Tree localtree(faces(mesh).first, faces(mesh).second, mesh);
>      std::cout << "Start: " << omp_get_wtime() << std::endl;
>
>          size_t tid = omp_get_thread_num();
>          size_t number_of_threads = omp_get_num_procs();
>          for(size_t y = tid; y < number_of_ray_y; y=y+number_of_threads)
>          {
>              if(y >= number_of_ray_y)
>                  {
>                      break;
>          }
>
>                  for(size_t x = 0; x < number_of_ray_x; x++)
>                  {
> Ray_intersection hit =
> localtree.first_intersection(rays[this->transformCoordinates(y,x)]);
>          }
>      }
> }
>
>
> This is very troubling, an acceleration structure can have a pretty huge
> memory footprint.  Am I using something wrong?
>
>      typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron>
> Primitive;
>      typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
>      typedef CGAL::AABB_tree<Traits> Tree;
>
> Kind regards
> Rashid
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss