 |
|
A quick example about how to submit MPI C job to Windows cluster RCWINCLU
Intro: Please read "Access windows cluster rcwinclu" and How to submit a job in Windows cluster before proceed.
1> Please download the MPI c source code and re-compile it it with MS Visual Studio 2008. and recompile it with MS Visual Studio 2008. If you are inside PHS network, you can go to \\rcwinclu\public\HPCSamples\SplitSearching to download the source. If you do not have Visual Studio 2008, please download the trial or expression version from Microsoft website.
a> This is a mpich1.2 compatible MPI C code and you can compile it in MS Visual Studio 2008 with some minor warnings.
b> If you want to compile it in your own environment instead of in HPCWIN, You need to download MS HPC 2008 SDK and then make reference to the Microsoft MPI Library (import msmpi.lib). More docs please visit \\rcwinclu\public\windowsHPC_doc
Here are the source code.
#include "stdafx.h"
#include < math.h >
#include "mpi.h"
float integral(float a, int i, float h, int n)
{
int j;
float h2, aij, integ;
integ = 0.0; /* initialize integral */
h2 = h/2.;
/* sum over integrals in partition i*/
for (j=0; j < n; j++)
{
aij = a + (i*n + j)*h; /* lower limit of integration of j*/
integ += cos(aij+h2)*h; /* contribution due to j */
}
return integ;
}
int main(int argc,char *argv[])
{
int n, p, i, myid, source, master, tag;
float h, result, a, b, pi, my_int, integral_sum;
MPI_Status status; /* MPI data type */
MPI_Init(&argc,&argv); /* start MPI processess */
MPI_Comm_size(MPI_COMM_WORLD,&p); /* # of processes */
MPI_Comm_rank(MPI_COMM_WORLD,&myid); /* current proc. id */
pi = acos(-1.0); /* = 3.14159... */
a = 0.; /* lower limit of integration */
b = pi/2.; /* upper limit of integration */
n = 500; /* number of increment within each process */
master = 0; /* define the process that computes the final result */
tag = 123; /* set the tag to identify this particular job */
h = (b-a)/n/p; /* length of increment */
my_int = integral(a,myid,h,n); /* local sum due process myid */
printf("Process %d has the partial integral of %f\n", myid,my_int);
if(myid == master)
{
integral_sum = my_int;
for (source=1;source < p;source++)
{
MPI_Recv(&my_int, 1, MPI_FLOAT, source, tag,
MPI_COMM_WORLD, &status); /* safe */
integral_sum += my_int;
}
fprintf(stdout,"The Integral =%f\n", integral_sum);
}
else
{
MPI_Send(&my_int, 1, MPI_FLOAT, master, tag,
MPI_COMM_WORLD); /* send my_int to ?master? */
}
MPI_Finalize(); /* let MPI finish up ... */
return 0;
}
2> Compile this program into 64bit mode, upload the executable file mpiintegral.exe into \\rcwinclu\PARTNERSID
3> Start your "HPC Job Manager" from your client.
4> Leave the Job Detail as default, and configure the Task Detail as following.
here is the GUI for "Task Detail"
5> Fill in the following fields:
a. TaskName --> MyTestMPIC
b. CommandLine --> "mpiexec -n 32 mpiintegral.exe " (Note: "mpiexec" is the MPI job launcher ( and you need to use it for all MPI C application , "-n 32" means you will allocate 32 computing coreS, "mpiintegral" is the example application).
c. Working Directory --> "\\rcwinlu\$PARTNERSID (Note: here we use "testy" as example, you need to change it).
d. Standard Output --> "testmpic.out"
e. Standard Error --> "testmpic.err"
f. Minimum and Maximum number of cores are same as in command line.
6> Submit the job. When job finishes, check the results at testmpic.out .
|