Hello World program in MPI

7 views
Skip to first unread message

Pradnyesh Gudadhe

unread,
Oct 4, 2007, 11:48:03 PM10/4/07
to ASU:CSE520 FALL 07 Advanced Computer Architecture
I am trying to run Hello World program using MPI on my Ocotillo
account.
I am referring this from HPC Website:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" hello.c

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

int main(int argc, char **argv) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello, world. I am %d of %d.\n", rank, size);
MPI_Finalize();
return 0; }

hello.sh

#!/bin/bash
#PBS -l nodes=4
#PBS -q devel
#PBS -j oe
#PBS -o hello_output
cd $PBS_O_WORKDIR
mpiexec /home/user/a.out

Now that you have the correct files, we can compile and run your new
program. To compile the program run mpicc hello.c. This will create
the executable a.out. As it is an MPI program it cannot be run by
itself, but not to worry! Running it is as easy as qsub hello.sh!

Now that you have submitted it to the queue, you must wait for it to
get back. To see the status of this "HelloWorld" job, run qsat -a. "

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
But, while I try to run qsub hello.sh, I am getting following error.

[pgudadhe@ocotillo pgudadhe]$ qsub hello.sh
-bash: qsub: command not found
[pgudadhe@ocotillo pgudadhe]$

Is there anyone getting the same error? I guess I am missing some
environment variable to be set. Could you please tell me where qsub is
located in the server? Also, I am getting the same error for qsat.

Thanks.

Regards,
Pradnyesh

Guofeng

unread,
Oct 5, 2007, 1:37:33 PM10/5/07
to ASU:CSE520 FALL 07 Advanced Computer Architecture
It's not actually necessary to submit to a batch system on Ocotillo.
Students may run their programs interactively.

To run, type:

mpirun -np x ./a.out

Where x is the number of processors you'd like to use.

Find out more about mpirun command in page 60 at
http://www.public.asu.edu/~dstanzoi/mpi-1.pdf

PS. to make the board efficient to read, please do not create new
threads without permission. Instead, reply to appropriate topics.

Regards,
Guofeng

Pradnyesh Gudadhe

unread,
Oct 5, 2007, 1:42:56 PM10/5/07
to ASU:CSE520 FALL 07 Advanced Computer Architecture
Sure. Thanks for the mpirun command.
Sorry for creating this new thread.
Thanks.

Regards,
Pradnyesh


On Oct 5, 10:37 am, Guofeng <guofeng.d...@gmail.com> wrote:
> It's not actually necessary to submit to a batch system on Ocotillo.
> Students may run their programs interactively.
>
> To run, type:
>
> mpirun -np x ./a.out
>
> Where x is the number of processors you'd like to use.
>

> Find out more about mpirun command in page 60 athttp://www.public.asu.edu/~dstanzoi/mpi-1.pdf

Reply all
Reply to author
Forward
0 new messages