Find the answer to your Linux question:
Results 1 to 4 of 4
I have a simple testing program like this: /*The Parallel Hello World Program*/ #include <stdio.h> #include <mpi.h> main(int argc, char **argv) { int node; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &node); printf("Hello World from ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    10

    Help! How to compile parallel C program with MPI codes?


    I have a simple testing program like this:

    /*The Parallel Hello World Program*/
    #include <stdio.h>
    #include <mpi.h>

    main(int argc, char **argv)
    {
    int node;

    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &node);

    printf("Hello World from Node %d\n",node);

    MPI_Finalize();
    }

    My program is, I can't compile this program using gcc, and I can't find something like pgcc in ubuntu. How should I compile this program? After compiling, what should I do to run this program?

    Can I use something like mpirun to run it? I want to try to use both cores of my computer to run it and make it shows Node 1 also besides Node0.

    Thank you.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,701
    You need to install MPI on your Ubuntu system. Try "sudo apt-get install openmpi-devel".
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    You probably don't have mpi installed.... Here is how I installed it just now....

    I downloaded the mpi source from here:
    MPICH2 : High-performance and Widely Portable MPI

    Extracted it on my centos 6 system and did:
    $ ./configure --disable-fc --disable-fc77 --disable-cxx
    $ make
    # make install

    Now, I put your program into a file called par.c and tried to compile it:

    $ mpicc -o par.out par.c

    hmmm, seems to work.

    $ now let me see if I can run it.

    $ mpirun -np 1 ./par.out
    Hello World from Node 0

    Seems to work.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jun 2011
    Posts
    10
    In my case, it is:
    $ mpirun -np 1 ./try.exe
    mpiexec_ubuntu: cannot connect to local mpd (/tmp/mpd2.console_shsh); possible causes:
    1. no mpd is running on this host
    2. an mpd is running but was started without a "console" (-n option)
    In case 1, you can start an mpd on this host with:
    mpd &
    and you will be able to run jobs just on this host.
    For more details on starting mpds on a set of hosts, see
    the MPICH2 Installation Guide.

    the mpicc can compile but seems still cannot use mpirun

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •