next up previous contents
Next: âÉÂÌÉÏÔÅÞÎÙÊ ÐÒÉÍÅÒ 1 Up: ðÒÉÍÅÒÙ Previous: ðÒÉÍÅÒ 3   Contents

ðÒÉÍÅÒ 4

óÌÅÄÕÀÝÉÊ ÐÒÉÍÅÒ ÉÌÌÀÓÔÒÉÒÕÅÔ ``ÂÅÚÏÐÁÓÎÏÅ'' ×ÙÐÏÌÎÅÎÉÅ ÐÁÒÎÏÇÏ É ËÏÌÌÅËÔÉ×ÎÏÇÏ ÏÂÍÅÎÏ× × ÅÄÉÎÓÔ×ÅÎÎÏÍ ËÏÍÍÕÎÉËÁÔÏÒÅ.

#define TAG_ARBITRARY 12345 #define SOME_COUNT 50 main(int argc, char **argv) { int me; MPI_Request request[2]; MPI_Status status[2]; MPI_Group MPI_GROUP_WORLD, subgroup; int ranks[] = {2, 4, 6, 8}; MPI_Comm the_comm; ... MPI_Init(&argc, &argv); MPI_Comm_group(MPI_COMM_WORLD, &MPI_GROUP_WORLD); MPI_Group_incl(MPI_GROUP_WORLD,4,ranks, &subgroup);/*ÌÏËÁÌØÎÏ */ MPI_Group_rank(subgroup, &me); /* ÌÏËÁÌØÎÏ */ MPI_Comm_create(MPI_COMM_WORLD, subgroup, &the_comm); if(me != MPI_UNDEFINED) { MPI_Irecv(buff1, count, MPI_DOUBLE, MPI_ANY_SOURCE, TAG_ARBITRARY, the_comm, request); MPI_Isend(buff2, count, MPI_DOUBLE, (me+1)%4, TAG_ARBITRARY, the_comm, request+1); } for(i = 0; i < SOME_COUNT, i++) MPI_Reduce(..., the_comm); MPI_Waitall(2, request, status); MPI_Comm_free(&the_comm); MPI_Group_free(&MPI_GROUP_WORLD); MPI_Group_free(&subgroup); MPI_Finalize(); }



Alex Otwagin 2002-12-10