Reputation: 25
I want to write a program in C which will have a file as an input and inside this file the matrix of NxM size will be defined. So in my MPI program I would like to have N*M processes for every cell of the matrix.
I will be using makefile and hosts file to run this program
run:
mpirun --hostfile ${HOSTFILE} ./${TARGET}
I have searched internet and stackoverflow, but in vain, so could you please explain me how to achieve it?
Upvotes: 0
Views: 956
Reputation: 6955
In general terms, the MPI implementation will need "a priori" knowledge of the total number of ranks that need to be started BEFORE the ranks are actually started. This requirement precludes the use of rank 0 to read an input file and determine the number of ranks at run-time.
In practical terms, the number of ranks must be known at the time mpirun is invoked (I am leaving aside the spawn and connect/accept paths for now). The specific syntax for starting more than one rank per entry in the hostfile is implementation dependent. Refer to the supplied documentation for more.
The two "obvious" choices are to:
"Spawn" is another possible solution, but will tend to add a LOT of complication to the overall solution. Overall, the simple brute force methods listed above are preferable.
Upvotes: 1
Reputation: 301
You could read the number of rows and columns from the file by writing a small bash script, then use it in your makefile.
Upvotes: 0