int main(int argc, char **argv) { // Initialize MPI ... ... ... ... if ( rank ==
ID: 3645151 • Letter: I
Question
int main(int argc, char **argv) {// Initialize MPI
... ... ... ...
if ( rank == 0 ) { dest = 1; source = 1;
sendTag = recvTag = 100;
}
else if ( rank == 1) {
dest = 0;
source = 0;
sendTag = recvTag = 100;
}
/* =========================
* send and receive messages
* ========================= */
// allocate memory for message1 and message2
.....
MPI_Send ( message1, MSGLEN, MPI_FLOAT, dest, sendTag, MPI_COMM_WORLD );
MPI_Recv ( message2, MSGLEN, MPI_FLOAT, source, recvTag, MPI_COMM_WORLD, &status );
MPI_Finalize();
return 0;
}
Explanation / Answer
You can create a linux cluster or buy Windows Server 2003 and set up a computer cluster. Otherwise, you can't do it. And I suspect if you're asking this question, you don't know clustering at all. You can probably forget it. Setting up a linux cluster isn't necessarily easy. Further, just because you have one doesn't mean you'll get both to work on any given task. Clusters only work with software that was designed to be multithreaded - where a portion of the program you want to make run on two PCs is DESIGNED to be broken up and sent in part to another computer. In short, just like you only one person can drive a car but 4 can build a car, some programs can only utilize one computer while others can utilize more. Many computers nowadays have two or more "cores" which is like having two (or more) CPUs... A quad core has essentially 4 CPUs. But even on multicore CPUs, if the program isn't designed to run on more than one CPU, it's not going to work on multiple computers in a cluster.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.