[Contents] [Index] [Top] [Bottom] [Prev] [Next]


2. Getting Started

The purpose of this chapter is to quickly introduce the concepts needed to start using the LSF Parallel system. They are: compiling, linking, and submitting parallel applications. The example used in this chapter is a distributed version of the Hello World program named myjob; written in C.

This chapter discusses the following topics:

Writing a Distributed Application 10

Compiling and Linking the Application 11

Running the Application 12

Note

If the commands cannot be executed or the man pages cannot be viewed, the appropriate directories may need to added to the systems path; check with the system administrator.

Writing a Distributed Application

This example program, written in C, is a distributed version of the Hello World program named myjob. Use an editor to enter the code for this application. After the code is entered, save it in a file named myjob.c

   /* 
* File: myjob.c
*/
#include <stdio.h>
#include "mpi.h" /* MPI header file */

int
  
main(int argc, char **argv)
{
int myrank; /* Rank of this process */
int n_processes; /* Number of Processes */
int srcrank; /* Rank of the Sender */
int destrank; /* Rank of the receiver */
char mbuf[512]; /* Message buffer */
MPI_Status mstat; /* Return Status of an MPI operation */

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
MPI_Comm_size(MPI_COMM_WORLD, &n_processes);

if (myrank != 0) {
sprintf(mbuf, "Hello, from process %d!", myrank);
destrank = 0;
MPI_Send(mbuf, strlen(mbuf)+1, MPI_CHAR,
destrank, 90,MPI_COMM_WORLD);
} else {
for (srcrank = 1; srcrank < n_processes; srcrank++) {
MPI_Recv(mbuf, 512, MPI_CHAR,
srcrank, 90, MPI_COMM_WORLD,&mstat);
printf("From process %d: %s\n", srcrank, mbuf);
}
}
MPI_Finalize();
}

Compiling and Linking the Application

After the example program is entered and saved as myjob.c, use the mpicc script to compile and link the application. The mpicc script is used in a similar manner to other UNIX-based C compilers. This script provides the options and special libraries needed to compile and link a parallel application for the LSF Parallel environment.

Compile and Link

To compile and link the source code in the myjob.c file in one step, enter the following command:

   % mpicc myjob.c -o myjob 

The binary created is called myjob.

Running the Application

Submit to the LSF Batch System

To submit the parallel application myjob to the LSF Batch system, requesting three processors, enter the following command:

% bsub -n 3 pam myjob
Job <1288> is submitted to default queue <normal>.

This command creates three processes and each runs an instance of myjob. The bsub command has a number of command line options, which are discussed in more detail in Submitting Batch Jobs on page 26. To view the status of the parallel batch job, enter the following command:

% bjobs
JOBID USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
1288 user1 PEND normal hopper host1 myjob Apr 16 14:43
host2
host3

The bjobs command has a number of command line options, which are discussed in more detail in Monitoring Job Status on page 30.

Execute Interactively

To interactively execute the parallel application myjob on three processors, enter the following command:

% pam -n 3 myjob
Server PAM contact address is klee:2801
From process 1: Hello, world from process 1!
From process 2: Hello, world from process 2!
From process 3: Hello, world from process 3!

TID  HOST_NAME    COMMAND_LINE             STATUS         TERMINATION_TIME
===  =========    ============  ========================  ==================
1    host1        myjob         Completed                 04/16/98 15:05:56
2    host2        myjob         Completed                 04/16/98 15:05:56
3    host3        myjob         Completed                 04/16/98 15:05:56

The pam command has a number of command line options, which are discussed in more detail in The pam Command on page 35.



[Contents] [Index] [Top] [Bottom] [Prev] [Next]


doc@platform.com

Copyright © 1994-1998 Platform Computing Corporation.
All rights reserved.