Generic Parallel Test Job
From UGP-Wiki
parallel.c is a generic parallel MPI program that can be used to test parallel jobs. It looks like this:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int nprocs, myrank, merror;
merror = MPI_Init(&argc,&argv);
if (merror != 0) {
printf ("Error initializing MPI program. Terminating.\n");
MPI_Abort(MPI_COMM_WORLD,merror);
}
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
printf ("Number of processors or tasks = %d My rank= %d\n",
nprocs,myrank);
/******* Add your work here *******/
MPI_Finalize();
}
To test using this job:
- Use the Data Manager to copy it to the cluster on which you will run it.
- To compile parallel.c:
- Select "Grid Development Environment" under the "Advanced" tab.
- Select the target cluster from the cluster drop-down menu.
- From the File menu select New/New Project.
- In the "Create New Project" dialog box that opens select "MPI C for GigE (mpicc)", enter a name for your project and click "OK".
- From the File menu select Import Files...
- In the "Import Files" dialog box that open select parallel.c and click "OK".
- From the Build menu select Configuration and in the dialog box that opens change a.out in the box labeled Executable Name to parallel.
- From the File menu select Save Project.
- From the Build menu select Build.
- To run it, select "Generic Jobs" under the "Job Services" tab.
- Fill in the Generic Job Submission form as follows:
- Select the cluster name from the drop down menu labeled "Submit to:".
- Job Name is optional.
- Either:
- Click the File Folder symbol to the right of the text input field labeled "Executable:" and use the file selector which opens to select the executable, or
- Type in the filename of the executable in the text input field. Either provide a full path or a path which is relative to your home directory ($HOME).
- The excutable is in the ucla_workspace directory under the name you gave your project and is named a.out.
- Leave the text input field labeled "Arguments:" blank.
- Leave the text input field labeled "Directory:" blank.
- For "JobType" select MPI Parallel.
- Enter 2 or more for the number of processors.
- Click the "Submit Job" button.

