0

I have a MPI/Pthread program in which each MPI process will be running on a separate computing node. Within each MPI process, certain number of Pthreads (1-8) are launched. However, no matter how many Pthreads are launched within a MPI process, the overall performance is pretty much the same. I suspect all the Pthreads are running on the same CPU core. How can I assign threads to different CPU cores?

Each computing node has 8 cores.(two Quad core Nehalem processors) Open MPI 1.4 Linux x86_64

xhe8
  • 419
  • 1
  • 5
  • 13
  • This seems to cover your question: http://stackoverflow.com/questions/1407786/how-to-set-cpu-affinity-of-a-particular-pthread – Stan Graves Apr 23 '13 at 17:59
  • It sounds like you are running on a cluster - how do you invoke the program (i.e. what arguments are passed to `mpirun`/`mpiexec`)? The default binding options for your system might bind each MPI process to a single core, in which case all threads started by that process will also be bound. See [OpenMPI FAQ on binding options](It sounds like you might be running on a cluster - what arguments are you passing to `mpirun`/`mpiexec`?). – Josh Milthorpe Apr 29 '13 at 06:44

1 Answers1

0

Questions like this are often dependent on the problem at hand. Most likely, you are running into a resource lock issue (where the threads are competing for a lock) -- this would look like only one core was doing any work, because only one thread can (effectively) do any work at any given time.

Setting CPU affinity for a certain thread is not a good solution. You should allow for the OS scheduler to optimally determine the physical core assignment for a given pthread.

Look at your code and try to figure out where you are locking where you shouldn't be, or if you've come up with a correct parallel solution to the problem at hand. You should also test a version of the program using only pthreads (not MPI) and see if scaling is achieved.

Ryan Marcus
  • 966
  • 8
  • 21