OpenMP uses only 1 core as soon as numpy is loaded

  • Thread starter Wout Megchelenbrink
  • Start date
W

Wout Megchelenbrink

I use openMp in a C-extension that has an interface with Python.

In its simplest form I do this:

== code ==
#pragma omp parallel
{

#pragma omp for
for(int i=0; i<10; i++)
{
// multiply some matrices in C
}
}

== end of code ==


This all works fine, and it uses the number of cores I have. But if I import numpy in my python session BEFORE I run the code, then it uses only 1 core (and omp_num_procs also returns 1 core, instead of the maximum of 8 cores).

So how does numpy affect openMp, and does it have anything to do with the GIL or something? I don't use any Python object in my parallel region.

Any help would be appreciated!
Wout
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top