Skip to content

[NormalEstimationOMP] appearantly running with just one thread #5717

@mynickmynick

Description

@mynickmynick

Describe the bug

Apperantly NormalEstimationOMP runs with just one thread on two different PCs I tested it
I guess it's not a bug of PCL and it's my fault somewhere, I cannot figure out where

Context

I was just making a test to benchmark on my PC what speed up would be given by NormalEstimationOMP from NormalEstimation
but it seems no speed up, so I investigated further and by ouputting
int total_td = omp_get_num_threads();
printf("omp_get_num_threads %d \n", total_td);

i get 1

I tried it also on another pc and the same result

I wonder what am i doing wrong, in any case some sort of warning should be given

The compile config. WITH_OPENMP is true

I even added to CMakeLists to debug

if(OpenMP_FOUND)
message(STATUS "----------!!!!! OpenMP IS ACTIVE !!!!! OpenMP_FOUND: ${OpenMP_FOUND}")
message(STATUS "----------!!!!! OpenMP IS ACTIVE !!!!! OpenMP_VERSION: ${OpenMP_VERSION}")
message(STATUS " OpenMP_C_FOUND: ${OpenMP_C_FOUND}")
message(STATUS " OpenMP_CXX_FOUND: ${OpenMP_CXX_FOUND}")
message(STATUS " OpenMP_INCLUDE_DIRS: ${OpenMP_INCLUDE_DIRS}")
message(STATUS " OpenMP_C_INCLUDE_DIRS: ${OpenMP_C_INCLUDE_DIRS}")
message(STATUS " OpenMP_CXX_INCLUDE_DIRS: ${OpenMP_CXX_INCLUDE_DIRS}")
message(STATUS " OPENMP_INCLUDES: ${OPENMP_INCLUDES}")
message(STATUS " OPENMP_LIBRARIES: ${OPENMP_LIBRARIES}")

and I get

1> [CMake] -- ----------!!!!! OpenMP IS ACTIVE !!!!! OpenMP_FOUND: TRUE
1> [CMake] -- ----------!!!!! OpenMP IS ACTIVE !!!!! OpenMP_VERSION:
1> [CMake] -- OpenMP_C_FOUND: TRUE
1> [CMake] -- OpenMP_CXX_FOUND: TRUE
1> [CMake] -- OpenMP_INCLUDE_DIRS:
1> [CMake] -- OpenMP_C_INCLUDE_DIRS:
1> [CMake] -- OpenMP_CXX_INCLUDE_DIRS:
1> [CMake] -- OPENMP_INCLUDES:
1> [CMake] -- OPENMP_LIBRARIES:
1> [CMake] -- Found OpenMP, spec date 200203

I don't know if those empty strings are a bad sign, I guess so but what to do??

I have also tried to add openMP pragmas to another for elsewhere in my code and it does the same (just one thread) so it must be a problem of my environment

Expected behavior

a speed up of the processing and more than one thread used and logged via omp_get_num_threads

I don't understand because I think I used openMP not so long ago, I wonder if it is some wrong setting on my PC (but it's two PCs)

Your Environment (please complete the following information):

  • OS: [Windows 10]
  • Compiler: [MSVC2019]
  • PCL Version [last]

Possible Solution
very generic and not much helpful hint:
give some warnings at some level, either compile or run time

The code using it

    if (globalState.calcNormal.get())
    {
        bool openMP = globalState.openMP.get();
        pcl::NormalEstimation<PointXYZRGB, Normal> n; 
        pcl::NormalEstimationOMP<PointXYZRGB, Normal> nomp(4); // instantiate n threads
        nomp.setNumberOfThreads(4);
        PointCloud<Normal>::Ptr normals(new PointCloud<Normal>());
        auto begin = std::chrono::high_resolution_clock::now();
        if (!openMP)
        {
            n.setInputCloud(filteredCloud);
            n.setKSearch(20);
            n.compute(*normals);
        }
        else
        {
            printf("\n using openMP\n");
            nomp.setInputCloud(filteredCloud);
            nomp.setKSearch(20);
            nomp.compute(*normals);
        }

        auto end = std::chrono::high_resolution_clock::now();
        auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
        printf("\n -----NORMALS TIME: %.3f msec.\n", elapsed.count() * 1e-6);

    }

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