Click here to Skip to main content
15,883,855 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a small piece of code that should run on multilple processes, which is :

XML
#include <stdio.h>
 #include <mpi.h>

   main(int argc, char **argv)
   {
      int ierr, num_procs, my_id;

      ierr = MPI_Init(&argc, &argv);

      /* find out MY process ID, and how many processes were started. */

      ierr = MPI_Comm_rank(MPI_COMM_WORLD, &my_id);
      ierr = MPI_Comm_size(MPI_COMM_WORLD, &num_procs);

      printf("Hello world! I'm process %i out of %i processes\n",
         my_id, num_procs);

      ierr = MPI_Finalize();
   }


the output is :Hello world! I'm process 0 out of 1 processes.
although it should run on more than one process


We edited the run configurations arguments to "-np 2" so it would run on 2 processes but it always gives us 1 process no matter what the value is.

The used environment is:
Eclipse Juno on Ubuntu 12.04


Source of code: http://condor.cc.ku.edu/~grobe/docs/intro-MPI-C.shtml[^]
Posted
Updated 23-Mar-14 5:12am
v2
Comments
nv3 23-Mar-14 7:07am    
How did you start your process? Please show us the exact command line with wich you ran the application.
Afnan_ 23-Mar-14 11:07am    
I don't use commands to run the application, I just run it from the run button on Eclipse

As far as I can see you do not ever create any threads. The documentation for MPI_Init[^] does not mention creating threads.
 
Share this answer
 
Comments
Afnan_ 23-Mar-14 11:09am    
I am not using threads.
Richard MacCutchan 23-Mar-14 11:15am    
So how do you expect to run multiple processes?
Afnan_ 23-Mar-14 11:21am    
I was following this example: http://condor.cc.ku.edu/~grobe/docs/intro-MPI-C.shtml
Richard MacCutchan 23-Mar-14 12:12pm    
Did you start the program with the mpirun command, as shown in the sample?
Afnan_ 23-Mar-14 12:16pm    
No, I run my code using the run button on eclipse. Although I have a problem with configuring the run configuration for a MPI project.
You seem to be under the impression that the MPI_Init function will launch multiple processes for you. This is not the case. You have to run your program via the mpirun command, for example:
C++
$ mpirun -np 4 a.out

and mpirun will interpret the "-np 4" for you and launch the four processes. As you started your process manually (from the IDE) you will only have that single processes running.
 
Share this answer
 
Comments
Afnan_ 24-Mar-14 7:42am    
I did try it and this is what I get an error:

main@C4C:~/Junoworkspace/testmillion$ mpirun -np 4 testmillion [proxy:0:0@C4C] HYDU_create_process (./utils/launch/launch.c:69): execvp error on file testmillion (No such file or directory) [proxy:0:0@C4C] HYDU_create_process (./utils/launch/launch.c:69): execvp error on file testmillion (No such file or directory) [proxy:0:0@C4C] HYDU_create_process (./utils/launch/launch.c:69): execvp error on file testmillion (No such file or directory) [proxy:0:0@C4C] HYDU_create_process (./utils/launch/launch.c:69): execvp error on file testmillion (No such file or directory)
nv3 24-Mar-14 7:59am    
Read the error message: ... testmillion (No such file or directory)
I guess you have to specify the file extension of your testmillion program; the mpirun program tried to run your program testmillion, but could not find it.
Afnan_ 24-Mar-14 16:17pm    
Thank you but I already read the error message and the file does exist and the extension is provided. If you have noticed I'm running the command within the directory itself "main@C4C:~/Junoworkspace/testmillion$ mpirun -np 4 testmillion", so it's pointing to the directory.
nv3 24-Mar-14 16:31pm    
I would trust the error message in so far that execvp could not find your file testmillion, for whatever reason. If the file is in the directoy, I can't see any other reason than that you did not specify the correct file extension. And I did not see a file extension on the command line that you posted.
Afnan_ 25-Mar-14 2:08am    
Okay, I'll look in to that.

Thank you for all your comments.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900