0

At the moment I am using something like this to run a c++ program:

mpirun -np 4 ./test

This works fine, but the problem is that I am wrapping the c++ program with Python. So I want to set the number of processors in Python and deliver it to the c++ program.

Is it possible to set the number of used processors e.g. as fixed value in the c++ code without using the command line? How does a simple example look like?

dolby
  • 643
  • 1
  • 8
  • 10
  • I found out that you can't set the number of processors in the c++ program, as mpirun spawns various copies of the program rather than the program spawning them itself. But you could do it if you were using OpenMP and spawning threads. Another possibility would be Pythons subprocess module. – dolby Mar 06 '13 at 07:05

1 Answers1

0

by -np N , you set number of process, not the number of processors.Processors are further assigned to each process depending upon the flags you are providing during execution or the rank file , if you are using. And if you are focusing on the Python & C++ interaction , i think there should be a way to call cmd functions something like exec().You can easily call whatever you want to be executed on the system command line !

Ankur Gautam
  • 1,412
  • 5
  • 15
  • 27