êîììóíèñòè÷åñêèå âû÷èñëåíèÿ ALEK SILVERSTONE Ñïåöâûïóñê: Õàêåð, íîìåð #065, ñòð. 065-070-7 MPI_Pack(@buf.st,10,MPI_CHAR,p,buf_size,@pos,MPI_COMM_WORLD); MPI_Send(p,buf_size,MPI_BYTE,1,111,MPI_COMM_WORLD); FreeMem(p); // âòîðàÿ âåòâü MPI_Probe(0,111,MPI_COMM_WORLD,@Stat); MPI_Get_count(@Stat,MPI_BYTE,@buf_size); GetMem(p,buf_size); MPI_Recv(p,buf_size,MPI_BYTE,0,111,MPI_COMM_WORLD,@Stat); pos:=0; MPI_Unpack(p,buf_size,@pos,@OurStruct.i,1,MPI_INT,MPI_COMM_WORLD); MPI_Unpack(p,buf_size,@pos,@OurStruct.d,1,MPI_DOUBLE,MPI_COMM_WORLD); MPI_Unpack(p,buf_size,@pos,@OurStruct.st,10,MPI_CHAR,MPI_COMM_WORLD); FreeMem(p); Ïðîãðàììêà íà C++ #include <iostream.h> #include <mpi.h> int main(int argc, char *argv[]) { int rank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); cout<<"Hello from process #"<<rank<<endl; cout.flush(); MPI_Barrier(MPI_COMM_WORLD); if(rank==0) { for(int i=1; i<size; i++) { cout<<"Sending message to process #"<<i<<endl; cout.flush(); MPI_Send(&rank, 1, MPI_INT, i, 111, MPI_COMM_WORLD); } for(i=1; i<size; i++) { MPI_Status status; int temp; MPI_Recv(&temp, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); cout<<"Received message from process #"<<status.MPI_SOURCE<<endl; cout.flush(); } } else { int temp; MPI_Status status; MPI_Recv(&temp, 1, MPI_INT, 0, 111, MPI_COMM_WORLD, &status); MPI_Send(&rank, 1, MPI_INT, 0, 222, MPI_COMM_WORLD); } MPI_Finalize(); return 0; } Êóñîê RARcrack for i:= 1 to size-1 do begin count:=FillSendBuf; MPI_Send(@count,1,MPI_INT,i,TAG_Size,MPI_COMM_WORLD); MPI_Send(@buf,sizeof(buf),MPI_BYTE,i,TAG_Data,MPI_COMM_WORLD); end; while true do begin count:=FillSendBuf; if count=0 then break; MPI_Recv(@count,1,MPI_INT,MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,@status); if(status.MPI_TAG=TAG_Found) then break; MPI_Send(@count,1,MPI_INT,status.MPI_SOURCE,TAG_Size,MPI_COMM_WORLD); MPI_Send(@buf,sizeof(buf),MPI_BYTE,status.MPI_SOURCE,TAG_Data,MPI_COMM_WORLD); OutMessage('"'+buf[1]+'" was sent to process #'+IntToStr(status.MPI_SOURCE)); end; for i:=1 to size-1 do begin OutMessage('Waiting for process #'+IntToStr(i)); MPI_Recv(@count,1,MPI_INT,i,MPI_ANY_TAG,MPI_COMM_WORLD,@status); count:=0; MPI_Send(@count,1,MPI_INT,status.MPI_SOURCE,TAG_Size,MPI_COMM_WORLD); end; ÍÀ ÄÈÑÊÅ ËÅÆÀÒ ÁÈÍÀÐÍÈÊÈ È ÈÑÕÎÄÍÈÊÈ MPICH, ÌÎÄÓËÜ ÄËß C++ BUILDER'À, FPC È DELPHI, ÈÑÕÎÄÍÈÊÈ SYSTEST È RARCRACK, ÒÀÊÆÅ ÄÎÊÓÌÅÍÒÀÖÈß WWW PARALLEL.RU WWW.TOP500.ORG WWW.BEOWULF.ORG POLYGON.PARALLEL.RU — ÂÛ×ÈÑËÈÒÅËÜÍÛÉ ÏÎËÈÃÎÍ. WEB-ÈÍÒÅÐÔÅÉÑ ÄËß ÇÀÏÓÑÊÀ ÌÎÄÅËÜÍÛÕ ÏÐÎÃÐÀÌÌ ÍÀ ÊËÀÑÒÅÐÀÕ. WWW.MONEYBEE.NET — ÈÑÏÎËÜÇÎÂÀÍÈÅ ÏÀÐÀËËÅËÜÍÛÕ ÂÛ×ÈÑËÅÍÈÉ È ÍÅÉÐÎÑÅÒÅÉ ÄËß ÏÐÎÃÍÎÇÈÐÎÂÀÍÈß ÁÈÐÆÅÂÛÕ ÊÎÒÈÐÎÂÎÊ È ÈÍÄÅÊÑÎÂ. |