[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Condor-users] Question for MPI gurus

I have the following simple programs

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

/* problem parameters */

#define f(x) ((x) * (x))
#define numberRects 50
#define lowerLimit 2.0
#define upperLimit 5.0

int main( int argc, char * argv[ ] )


/* MPI variables */
int dest, noProcesses, processId, src, tag;
MPI_Status status;

/* problem variables */
int i;
double area, at, height, lower, width, total, range;

/* MPI setup */
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &noProcesses);
MPI_Comm_rank(MPI_COMM_WORLD, &processId);

/* adjust problem size for subproblem*/
range = (upperLimit - lowerLimit) / noProcesses;
width = range / numberRects;
lower = lowerLimit + range * processId;

! /* calculate area for subproblem */
area = 0.0;
for (i = 0; i < numberRects; i++)
{ at = lower + i * width + width / 2.0;
height = f(at);
area = area + width * height;

/* collect information and print results */
tag = 0;
if (processId = = 0) /* if rank is 0, collect results */

{ total = area;
for (src="" src < noProcesses; src++)
{ MPI_Recv(&area, 1, MPI_DOUBLE, src, tag, MPI_COMM_WORLD, &status);
total = total + area;

fprintf(stderr, "The area from %f to %f is: %f\n",
lowerLimit, upperLimit, total );


else /* all other processes only send */

{ dest = 0;
MPI_Send(&area, 1, MPI_DOUBLE, dest, tag, MPI_COMM_WORLD);

/* finish */
MPI_Finalize( );
return 0;

Now this is a s!
 imple MPI
 program which calculates the 
area between a given set of numbers.

the program when run under MPI is uploaded to each node
that is going to execute it and then the results
are returned back.

Is it possible that i write two different programs. upload
them with a single mpi command. they run simultaneously
on different nodes and yet they compute the same problem that
is calculating the area of a given region.

what i am emphasising is that two different programs working
on the same problem and combining their results.

in the example above the program is the same but different
nodes execute different pieces of the same code using conditional

so in reality the job distribution is being done by the programmer
himself. while MPI is just uploading the copy of the executable
to different nodes.

the question once again: Is it possible to run two different
pieces of code/two different ! programs using MPI and yet those
two programs work on the same problem.

I would appreciate an example.



Junaid N. Sahibzada
Cell # (+61) 404 998 494 
284/9 Crystal St. Waterloo, 2017, NSW, Australia
International Student MSc Internetworking, UTS, Australia
Bachelor of Information Technology, NUST, Pakistan

Brings words and photos together (easily) with
PhotoMail - it's free and works with Yahoo! Mail.