Probleme de transmitere în modul standard. MPI - Message Passing Interface. Comunicarea punct la punct

Σχετικά έγγραφα
MPI: Message Passing Interface

MPI: Message Passing Interface

Τφποι δεδομζνων MPI. Κώςτασ Διαμαντάρασ Τμιμα Πλθροφορικισ ΤΕΙ Θεςςαλονίκθσ

Αρχιτεκτονική κοινής μνήμης

Συστήµατα Παράλληλης Επεξεργασίας. Message Passing Interface (MPI)

Message Passing Interface (MPI)

Message Passing Interface (MPI)

MPI: Message Passing Interface

ύο μηχανισμοί απαιτούνται: 1. Μία μέθοδος για τη δημιουργία διεργασιών

Message Passing Interface (MPI)

Επιστημονικοί Υπολογισμοί - Μέρος ΙΙΙ: Παράλληλοι Υπολογισμοί

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Message Passing Interface (MPI)

EM 361: Παράλληλοι Υπολογισμοί

Non-blocking Επικοινωνίεσ και Buffering. Κώςτασ Διαμαντάρασ ΤΕΙ Θεςςαλονίκθσ 2011


Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Κατανεμημένος και Παράλληλος Προγραμματισμός MPI. MPI Απλές εντολές 03/13/2016. Οδηγίες αποστολής / παραλαβής μηνυμάτων, Υπολογισμός του π (

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Ε-85: Ειδικά Θέµατα Λογισµικού

Επικοινωνία. Message-Passing Interface (MPI) Βασικές Κλήσεις για Sockets. Μοντέλο Μεταβίβασης Μηνυµάτων. Μοντέλα Παράλληλου Υπολογισµού

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Το Message Passing Interface (MPI) και η υποστήριξή του στο EGEE Grid

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Το Message Passing Interface (MPI) και η υποστήριξή του στο EGEE Grid

Υπολογισμοί Μεταβίβασης Μηνυμάτων

Παράλληλος προγραµµατισµός

Εισαγωγή. E-03: Λειτουργικά Συστήµατα ΙΙ 6. Εαρινό Εξάµηνο SUN RPC. Κλήση Αποµακρυσµένων ιαδικασιών (RPC) Σύνδεση: Port Mapper.

Το Message Passing Interface (MPI) και η υποστήριξή του στο EGEE Grid. Vangelis Koukis 01-GRNET and HG EKT admin team

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Προγραµµατισµός µε ανταλλαγή µηνυµάτων Ι. Εισαγωγή στο MPI. Εφαρµογές Ανεξάρτητου Παραλληλισµού.

ΠΤΥΧΙΑΚΗ ΕΡΓΑΣΙΑ. Της φοιτήτριας Αριστέας Χρονοπούλου Αρ. Μητρώου: 01 / Επιβλέπων Καθηγητής Αθανάσιος Μάργαρης

Τοπολογίεσ. Κώςτασ Διαμαντάρασ Τμιμα Πλθροφορικισ ΤΕΙ Θεςςαλονίκθσ

Συστήματα Παράλληλης και Κατανεμημένης Επεξεργασίας

Παράλληλα και Κατανεµηµένα Συστήµατα. Εισαγωγή

Κεφάλαιο VIΙΙ Β. Δημακόπουλος

EM 361: Παξάιιεινη Υπνινγηζκνί

MPI: Βαςικζσ Εντολζσ Επικοινωνίασ. Κώςτασ Διαμαντάρασ Τμιμα Πλθροφορικισ ΤΕΙ Θεςςαλονίκθσ 2011

ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ Μεταβίβαση μηνυμάτων. Κεφάλαιο 5 (νέο βιβλίο) Κεφάλαιο 8 (παλιές σημειώσεις)

3/5/2012 Συστήματα κατανεμημένης μνήμης και ο προγραμματισμός τους (ΙI) Β. Δημακόπουλος

Κατανεμημένος και Παράλληλος Προγραμματισμός MPI. Γρήγορος οδηγός αναφοράς 1/4/2017

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

ΕΚΔΟΣΗ 1.0 ΟΚΤΩΒΡΙΟΣ, 2017 ΕΙΣΑΓΩΓΗ ΣΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΣΥΣΤΗΜΑΤΑ ΕΙΣΑΓΩΓΗ ΣΤO MESSAGE PASSING INTERFACE - MPI ΕΠΙΜΕΛΕΙΑ: Β. ΤΣΑΚΑΝΙΚΑΣ, Β.

Ανταλλαγι Μθνυμάτων. Κϊςτασ Διαμαντάρασ Τμιμα Πλθροφορικισ ΤΕΙ Θεςςαλονίκθσ

Διπλωματική Εργασία του φοιτητή του Τμήματος Ηλεκτρολόγων Μηχανικών και Τεχνολογίας Υπολογιστών της Πολυτεχνικής Σχολής του Πανεπιστημίου Πατρών

Υ07 Παράλληλα Συστήματα /5/2016 Προγραμματισμός με μεταβίβαση μηνυμάτων

ΕΚΔΟΣΗ 1.1 ΑΠΡΙΛΙΟΣ, 2018 ΕΙΣΑΓΩΓΗ ΣΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΣΥΣΤΗΜΑΤΑ ΤΟ ΠΡΩΤΟΚΟΛΛΟ ECHO ΕΠΙΜΕΛΕΙΑ: Β. ΤΣΑΚΑΝΙΚΑΣ, Β. ΤΑΜΠΑΚΑΣ

Προγραμματισμός με Μεταβίβαση Μηνυμάτων

Κατανεμημένος και Παράλληλος Προγραμματισμός. Εισαγωγή στο MPI. Εγκατάσταση MPICH σε ένα ΗΥ 10/3/2017

30/4/2012 Συστήματα κατανεμημένης μνήμης και ο προγραμματισμός τους (Ι) Β. Δημακόπουλος

Laborator 11. Mulţimi Julia. Temă

ΕΚΔΟΣΗ 1.0 ΟΚΤΩΒΡΙΟΣ, 2017 ΕΙΣΑΓΩΓΗ ΣΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΣΥΣΤΗΜΑΤΑ ΤΟ ΠΡΩΤΟΚΟΛΛΟ TARRY ΕΠΙΜΕΛΕΙΑ: Β. ΤΣΑΚΑΝΙΚΑΣ, Β. ΤΑΜΠΑΚΑΣ

Curs 10 Funcţii reale de mai multe variabile reale. Limite şi continuitate.

Συστήματα Παράλληλης και Κατανεμημένης Επεξεργασίας

Περίληψη. Υπερυπολογιστές. Υπολογιστικά προβλήµατα. TOP 500 (Ιούνιος 2007) TOP 500 (Ιούνιος 2009) Ε-85: Ειδικά Θέµατα Λογισµικού

Ε-85: Ειδικά Θέµατα Λογισµικού

Παράλληλοι Υπολογισµοί

Κατανεμημένος και Παράλληλος Προγραμματισμός. Εισαγωγή στο MPI. Εγκατάσταση MPICH σε ένα ΗΥ 6/3/2016

Metode iterative pentru probleme neliniare - contractii

Integrala nedefinită (primitive)

Planul determinat de normală şi un punct Ecuaţia generală Plane paralele Unghi diedru Planul determinat de 3 puncte necoliniare

riptografie şi Securitate

ΕΚΔΟΣΗ 1.0 ΟΚΤΩΒΡΙΟΣ, 2017 ΕΙΣΑΓΩΓΗ ΣΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΣΥΣΤΗΜΑΤΑ ΓΕΝΙΚΟΙ ΓΡΑΦΟΙ ΣΤΟ MPI ΕΠΙΜΕΛΕΙΑ: Β. ΤΣΑΚΑΝΙΚΑΣ, Β. ΤΑΜΠΑΚΑΣ

Επιμερισμός δεδομένων

Διάλεξη 3η: Τύποι Μεταβλητών, Τελεστές, Είσοδος/Έξοδος

Εισαγωγή στον Προγραµµατισµό. Διάλεξη 2 η : Βασικές Έννοιες της γλώσσας προγραµµατισµού C Χειµερινό Εξάµηνο 2011

Curs 1 Şiruri de numere reale

5.4. MULTIPLEXOARE A 0 A 1 A 2

Προγραμματισμό για ΗΜΥ

Curs 4 Serii de numere reale

Π. Σταθοπούλου ή Οµάδα Α (Φοιτητές µε µονό αριθµό Μητρώου ) ιδασκαλία : Παρασκευή 11πµ-13µµ ΗΛ7

Seminariile Capitolul X. Integrale Curbilinii: Serii Laurent şi Teorema Reziduurilor

Sisteme diferenţiale liniare de ordinul 1

DISTANŢA DINTRE DOUĂ DREPTE NECOPLANARE

(a) se numeşte derivata parţială a funcţiei f în raport cu variabila x i în punctul a.

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Metode de interpolare bazate pe diferenţe divizate

Προγραμματισμός Η/Υ (ΤΛ2007 )

Κεφάλαιο : Εισαγωγή στην C: (Διαλέξεις 3-4)

Δομημένος Προγραμματισμός (ΤΛ1006)

Κατανεμημένα και Παράλληλα Συστήματα (εργαστήριο) Παραδείγματα με openmp


Λ10 Παράλληλος & Κατανεμημένος Προγραμματισμός Μάθημα 8 ο & 9 ο 1 & 8/12/2009

Subiecte Clasa a VII-a

a n (ζ z 0 ) n. n=1 se numeste partea principala iar seria a n (z z 0 ) n se numeste partea

Componente şi Circuite Electronice Pasive. Laborator 3. Divizorul de tensiune. Divizorul de curent

Προγραμματισμός Η/Υ (ΤΛ2007 )

Συστήματα Παράλληλης & Κατανεμημένης Επεξεργασίας

Κεφάλαιο Πίνακες Ι. (Διάλεξη 16)

ΕΠΛ 032.3: Προγραµµατισµός ΜεθόδωνΕπίλυσηςΠροβληµάτων

ΕΚΔΟΣΗ 1.1 ΜΑΙΟΣ, 2018 ΕΙΣΑΓΩΓΗ ΣΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΣΥΣΤΗΜΑΤΑ ΕΚΛΟΓΗ ΑΡΧΗΓΟΥ ΕΠΙΜΕΛΕΙΑ: Β. ΤΣΑΚΑΝΙΚΑΣ, Β. ΤΑΜΠΑΚΑΣ

2CP Electropompe centrifugale cu turbina dubla

5. FUNCŢII IMPLICITE. EXTREME CONDIŢIONATE.

5.5. REZOLVAREA CIRCUITELOR CU TRANZISTOARE BIPOLARE

Αριθμητικοί αλγόριθμοι

Conice. Lect. dr. Constantin-Cosmin Todea. U.T. Cluj-Napoca

Π. Σταθοπούλου ή Οµάδα Α (Φοιτητές µε µονό αριθµό Μητρώου ) ιδασκαλία : Παρασκευή 11πµ-13µµ ΗΛ7

ιαφάνειες παρουσίασης #6 (β)

ΕΚΔΟΣΗ 1.0 ΟΚΤΩΒΡΙΟΣ, 2017 ΕΙΣΑΓΩΓΗ ΣΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΣΥΣΤΗΜΑΤΑ ΚΑΤΑΝΕΜΗΜΕΝΑ ΡΟΛΟΓΙΑ ΕΠΙΜΕΛΕΙΑ: Β. ΤΣΑΚΑΝΙΚΑΣ, Β. ΤΑΜΠΑΚΑΣ

a. 11 % b. 12 % c. 13 % d. 14 %

Transcript:

MPI - Message Passing Interface MPI este un standard pentru comunicarea prin mesaje Elaborat de MPI Forum. Sisteme anterioare: de la IBM, Intel (NX/2) Express, ncube (Vertex), PARMACS, Zipcode, Chimp, PVM, Chameleon, PICL. MPI are la bază modelul proceselor comunicante prin mesaje. MPI este o bibliotecă nu un limbaj. MPI specifică reguli de apel pentru: C, C++, FORTRAN.77, FORTRAN90. Istoric MPI 1 (1993) orientat pe comunicarea punct la punct. Alte versiuni mai importanta MPI 1.2 (1997) MPI 2 (1997) include: Procese dinamice Comunicarea one-sided Operatii de I/E paralele Comunicarea punct la punct Operaţii de bază Forma clasică: send (adresa, lungime, destinatie, tag) recv (adresa, maxlung, sursă, tag, actlung) In MPI: MPI_SEND (buf, count, datatype, dest, tag, comm) MPI_RECV (buf, count, datatype, source, tag, comm, status) In C: int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm); int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status); Elemente noi introduse de MPI Tamponul de comunicatie este definit de tripleta (adresa, contor, tip_de_date) Contextul Fiecare comunicare de mesaj se derulează într-un anumit context. Mesajele caracterizate de context si tag Mesajele sunt intotdeauna primite în contextul în care au fost transmise. Mesajele transmise în contexte diferite nu interferã. Grup de procese Contextul este partajat de un grup de procese. Fiecare proces are un rang (nr intreg de la 0 la n-1) Fiecare proces caracterizat de grup si rang in grup Comunicator = Informaţiile de context şi de grup Comunicator predefinit: MPI_COMM_WORLD Un exemplu simplu # include mpi.h main (int argc, char **argv) { char message[40]; int myrank; MPI_Status status; MPI_Init (&argc, &argv); MPI_Comm_rank (MPI_COMM_WORLD, &myrank); if (myrank==0) { strcpy (message, Hello, there ); MPI_Send (message, strlen(message), MPI_CHAR, 1, 99,MPI_COMM_WORLD); else { MPI_Recv (message, 20, MPI_CHAR, 0, 99, MPI_COMM_WORLD,&status); printf( \treceived:%s \n, message); MPI_Finalize(); Operaţii MPI int MPI_Init (int *argc, char ***argv); int MPI_Initialized(int *flag); int MPI_Finalize (void); int MPI_Comm_rank(MPI_Comm comm, int *rank); Modurile de comunicare: cu şi fără tampon send si receive sunt blocante Probleme de transmitere în modul standard sender s buffer receiver s buffer Ordonarea operaţiilor send-recv local buffer network local buffer buffered non-buffered

MPI_Sendrecv Operaţii send-recv combinate int MPI_Sendrecv( void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status ) MPI_Sendrecv_replace int MPI_Sendrecv_replace( void *buf, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, MPI_Status *status ) Transmitere prin tampon alocat explicit #define BuffSize 100000 int size; char *buff; MPI_Buffer_attach(malloc(BuffSize), BuffSize); /* Tamponul de BuffSize octeti poate fi folosit acum */ MPI_Bsend(... ); MPI_Buffer_detach(&buff, &size); /* Tamponul redus la zero */ MPI_Buffer_attach(buff, size); /* Tamponul disponibil din nou */ int MPI_Buffer_attach( void *buffer, int size ); int MPI_Buffer_detach(void * bufferptr, int * size ); Transmitere sincronă, în mod pregătit, non-blocantă Transmitere sincronă Transmitere în modul pregătit MPI_Ssend MPI_Rsend Comunicaţia non-blocantă MPI_Isend MPI_Test MPI_Wait MPI_Irecv int MPI_Irecv( void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request ) MPI_Testall MPI_Testany MPI_Testsome MPI_Waitall MPI_Waitany MPI_Waitsome Evitarea întârzierii nelimitate typedef struct { char data [MSIZE]; int dsize; Buffer; Buffer buf[]; MPI_Request req[]; MPI_Status status[]; int index[];... MPI_Comm_rank(comm, &rank); MPI_Comm_size(comm, &size); if(rank!= size-1) { /* client code */ buf = (Buffer *) malloc(sizeof(buffer)); while(1) { produce_request( buf->data, &buf->dsize); MPI_Send(buf->data, buf->dsize, MPI_CHAR, size-1, tag, comm); else { /* rank == size-1; server code */ buf = (Buffer *) malloc(sizeof(buffer)*(size-1)); req = (MPI_Request *) malloc(sizeof(mpi_request)*(size-1)); status = (MPI_Status *) malloc(sizeof(mpi_status)*(size-1)); index = (int *) malloc(sizeof(int)*(size-1)); for(i=0; i < size-1; i++) MPI_Irecv(buf[i].data, MSIZE, MPI_CHAR, i, tag, comm, &req[i]); while (1){ MPI_Waitsome(size-1, req, &count, index, status); for (i=0; i < count; i++){ j = index[i]; MPI_Get_count(&status[i], MPI_CHAR, &buf[j].dsize); process_request(buf[j].data, buf[j].dsize); MPI_Irecv(buf[j].data, MSIZE, MPI_CHAR, j, tag, comm, &req[j]); Programatorul poate: crea o cerere persistentã declansa operatia astepta terminarea dealoca cererea persistentã cu Cereri de comunicare persistente MPI_Send_init, MPI_Recv_init MPI_Start, MPI_Startall MPI_Wait, sau MPI_Request_free. MPI_request *request; MPI_Recv_init (buf, count, datatype, source, tag, comm, request); MPI_Start (request); // are semantica MPI_Irecv MPI_Wait (request, status); MPI_Request_free (request); int MPI_Start( MPI_Request *request) int MPI_Wait ( MPI_Request *request, MPI_Status *status) int MPI_Request_free( MPI_Request *request )

Tipuri de date în MPI Tipuri predefinite toate tipurile tipurile de bazã din C (si din FORTRAN) plus MPI_BYTE si MPI_PACKED. tip de date MPI MPI_CHAR MPI_SHORT MPI_INT MPI_LONG MPI_UNSIGNED_CHAR MPI_UNSIGNED_SHORT MPI_UNSIGNED MPI_UNSIGNED_LONG MPI_FLOAT MPI_DOUBLE MPI_LONG_DOUBLE tip corespondent in C signed char signed short int signed int signed long int unsigned char unsigned short int unsigned int unsigned long int float double long double Tipurile derivate Tipurile derivate - trebuie construite; ex: MPI_Type_contiguous (count, datatype, &newtype); MPI_Type_commit (&newtype); MPI_Send (buffer, 1, newtype, dest, tag, comm); MPI_Type_free (&newtype); Mecanisme pentru descrierea unui tip general de date. harta tipului = secventa de perechi (tip, deplasare) Typemap = {(type 0, disp 0 ),..., (type n-1, disp n-1 ) semnatura tipului = secventa tipurilor Typesig = {type 0,..., type n-1 titlu (handle) extindere (extent) adrese absolute = deplasari relative la adresa zero MPI_BOTTOM. Cateva tipuri derivate int MPI_Type_contiguous( int count, MPI_Datatype old_type, MPI_Datatype *newtype) int MPI_Type_vector( int count, int blocklength, int stride, MPI_Datatype old_type, MPI_Datatype *newtype ) int MPI_Type_hvector( int count, int blocklength, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype *newtype ) int MPI_Type_indexed( int count, int array_of_blocklengths[], int array_of_indices[], MPI_Datatype old_type, MPI_Datatype *newtype ) int MPI_Type_hindexed( int count, int array_of_blocklengths[], MPI_Aint array_of_displacements[], MPI_Datatype old_type, MPI_Datatype *newtype ) int MPI_Type_create_struct(int count, int array_of_blocklengths[], MPI_Aint array_of_displacements[], MPI_Datatype array_of_types[], MPI_Datatype *newtype) # define MAX_PART 1000 Struct Part_struct { int class; /* clasa particulei */ double d[6]; /* coordonatele particulei */ char b[7]; /* alte informatii */ ; struct Part_struct particle[max_part]; int i, dest, rank; MPI_Comm comm; /* constructia tipului care descrie structura MPI a unei particule, ParticleType */ MPI_Datatype ParticleType; MPI_Datatype type[3] = {MPI_INT, MPI_DOUBLE, MPI_CHAR; /* semnat */ int blocklen [3] = { 1, 6, 7; /* lungimi blocuri */ MPI_Aint disp[3]; /* deplasari */ int base; /* calculul deplasarilor folosind adrese absolute*/ MPI_Address (particle, disp); MPI_Address (particle[0].d, disp+1); MPI_Address (particle[0].b, disp+2); base=disp[0]; for (i=0; i<3; i++) disp [i] -= base; MPI_Type_struct ( 3, blocklen, disp, type, &ParticleType); /* transmiterea intregului tablou */ MPI_Type_commit (&ParticleType); MPI_Send (particle, MAX_PART, ParticleType, dest, tag, comm); Eficienţa transmisiei Transmitere a două coloane matrice a de m linii şi n coloane - Operaţii separate pe fiecare coloană MPI_Type_vector (m, 1, n, MPI_FLOAT, &newtype); for (i=2; i<4; i++) MPI_Send (&a[0][i], 1, newtype,...); Topologii de procese Topologii virtuale Grila sau graf Usurinta de programare Nu conteaza la maparea pe topologii reale Procesele nu trebuie sa deschida explicit canale Structura carteziana - O singură operaţie MPI_Type_vector (m, 2, n, MPI_FLOAT, &newtype2); MPI_Send (&a[0][2], 1, newtype2,...); int MPI_Cart_create ( MPI_Comm comm_old, int ndims, int *dims, int *periods, int reorder, MPI_Comm *comm_cart )

Primitive pentru topologii carteziene Calcul dims MPI_Dims_create (nrnodes, ndims, dims); Furnizare dims, periods si coords proces apelant int MPI_Cart_get ( MPI_Comm comm, int maxdims, int *dims, int *periods, int *coords ) Intoarce coords procesului rank din grupul comm int MPI_Cart_coords ( MPI_Comm comm, int rank, int maxdims, int *coords ) Intoarce rank-urile procs sursa si dest pentru send-recv int MPI_Cart_shift ( MPI_Comm comm, int direction, int displ, int *source, int *dest ) int coords[2]; MPI_Comm_rank(comm, &rank); MPI_Cart_coords (comm, rank, 2, coords); MPI_Cart_shift (comm, 0, coords[1], &source, &dest); MPI_Sendrecv_replace(&A,1,MPI_FLOAT,dest,0,source,0,comm,&status); Comunicare colectivă Sincronizare de tip barieră a tuturor proceselor grupului Comunicări colective, în care se include: Difuzarea Colectarea datelor de la membrii grupului la rădăcinã Distribuirea datelor de la rădăcină spre membrii grupului Combinaţii de colectare / distribuire (allgather şi alltoall) Calcule colective: Operaţii de reducere Combinaţii reducere / distribuire : calculul lui π prin integrare numerică 1 1 1 π dx = arctan( x) = 2 1+ x 0 4 0 Foloseşte 2 operaţii colective MPI_Bcast(buffer, count, datatype, root, comm) MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm) # include mpi.h # include <math.h> int main (int argc, char **argv) { int n, myid, numprocs, i, rc; double mypi, pi, h, sum, x, a; MPI_Status status; MPI_Init (&argc, &argv); MPI_Comm_size (MPI_COMM_WORLD, &numprocs); MPI_Comm_rank (MPI_COMM_WORLD, &myid); while (1) { if (myid==0) { printf( Numar subintervale (0=gata): ); scanf( %d,&n); MPI_Bcast (&n, 1, MPI_INT, 0, MPI_COMM_WORLD); if(!n) break; h=1.0/(double)n; sum=0.0; for (i = myid + 1; i <= n; i += numprocs) { x = h*((double)i-0.5); sum += (4.0 / (1.0 + x*x)); mypi = h * sum; MPI_Reduce (&mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); if (!myid) printf( pi este %f\n, pi); MPI_Finalize();

Comunicări colective MPI_Gatherv (sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm);