This forum has been archived. All content is frozen. Please use KDE Discuss instead.

El Capitan, OpenMP, and std::thread

Tags: None
(comma "," separated)
matthewlai
Registered Member
Posts
10
Karma
0

El Capitan, OpenMP, and std::thread

Sun Oct 11, 2015 9:35 am
I have a program that calls Eigen from a std::thread (Eigen is set to single-threaded using Eigen::setNbThreads(1)).

I never had any problem with that setup, on any platform, until now.

I just upgraded to El Capitan, and it looks like my program now crashes inside Eigen, when it calls omp_get_num_threads().

I am able to reproduce it without Eigen, so it's not Eigen's problem. But I'm just wondering if it's possible to make Eigen not call any OpenMP function if set to use 1 thread?

Thanks!

Test program:
Code: Select all
#include <omp.h>

#include <iostream>
#include <thread>

void thread_main()
{
        std::cout << omp_get_num_threads() << std::endl;
}

int main()
{
        std::thread t(thread_main);

        t.join();
}
matthewlai
Registered Member
Posts
10
Karma
0
Looks like that's fixed in GCC 5.2, and calling omp_get_num_threads() from a std::thread is working again.

Would still be nice to have a special case for if num threads is set to 1, though, in case another implementation does this again (interaction between OpenMP and other threading libraries is undefined).
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Good idea, done in the devel branch, changeset https://bitbucket.org/eigen/eigen/commits/b8d476bed76b
matthewlai
Registered Member
Posts
10
Karma
0
Thanks! :)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar