Good day. I can not understand how to set the number of processes. If I run the program in the first way: mpiexec -l -n 5 ./test , then it will run 5 processes.

But I need to start the program through passing the arguments: ./test 5 - and in this case 1 process will work. What for this should I change? If you simply specify the procs_count parameter during internalization, it does not work.

 #include <stdio.h> #include "mpi.h" int main(int argc, char* argv[]) { int procs_rank, procs_count; MPI_Init(&argc, &argv); // инициализация MPI-Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ MPI_Comm_size(MPI_COMM_WORLD, &procs_count); // опрСдСляСм количСство процСссов MPI_Comm_rank(MPI_COMM_WORLD, &procs_rank); // ΡƒΠ·Π½Π°Π΅ΠΌ Ρ€Π°Π½Π³ процСсса printf ("\n Hello, World from process %3d of %3d\n", procs_rank, procs_count); MPI_Finalize(); // Π·Π°ΠΊΡ€Ρ‹Π²Π°Π΅ΠΌ MPI-Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ return 0; } 

    1 answer 1

    To pass parameters (command line arguments), simply write them after all the other mpiexec arguments. For example: $ mpiexec -n 5 ./a.out 123

    Unlike mpiexec, ./ will create a single process.