Miary Wydajności Czas wykonania równoległego (Tpar) jest czasem pomiędzy momentem rozpoczęcia obliczeń do momentu gdy ostatni procesor zakończy obliczenia Przyspieszenie (S) jest definiowane jako stosunek czasu niezbędnego do rozwiązania problemu z wykorzystaniem jednego procesora (Tseq) do czasu potrzebnego do rozwiązania tego samego problemu z wykorzystaniem systemu równoległego o "p" procesorach (Tpar) względne - Tseq jest czasem wykonania algorytmu równoległego na jednym z procesorów systemu wieloprocesorowego rzeczywiste - Tseq jest czasem wykonania najlepszego algorytmu sekwencyjnego na jednym z procesorów systemu równoległego bezwględne - Tseq jest czasem wykonania najlepszego algorytmu sekwencyjnego na najlepszym komputerze sekwencyjnym 1 1
Miary Wydajności Efektywność programu równoległego (E) jest definiowana jako stosunek przyśpieszenia do liczby procesorów Koszt jest zwykle definiowany jako iloczyn równoległego czasu przetwarzania i liczby procesorów. Skalowalność systemu równoległego jest miarą jego zdolności do zwiększenia przyśpieszenia proporcjonalnie do liczby procesorów. 2 2
Koszt komunikacji w sieciach statycznych Podstawowe parametry - czas przygotowania (startup time) (t s ) - czas przesłania nagłówka (per-hop time) (t h ) - czas przesłania jednego słowa (t w ) Strategie przesyłania - store and forward (zapamiętaj i prześlij) - cut-through routing
Komunikat przesyłany od procesora P 0 do P Time P 0 P 1 P 2 P Komunikat przesyłany metodą SF Time P 0 P 1 P 2 P Komunikat przesyłany metodą CT (podział na dwie części) Time P 0 P 1 P 2 P Komunikat przesyłany metodą CT (podział na cztery części)
Koszt Komunikacji Store and forward routing (SF) komunikat jest przesyłany pomiędzy procesorami w taki sposób, że każdy z pośredniczących w przesłaniu procesorów najpierw zapamiętuje cały komunikat w swojej lokalnej pamięci i dopiero potem wysyła komunikat dalej t t ( mt t ) l comm s w h Cut-through routing (CT) komunikat jest dzielony na równe części, które są przesyłane pomiędzy procesorami bez oczekiwania na odebranie całego komunikatu tcomm ts lth mtw 5 5
Podstawowe Prymitywy komunikacyjne -Pojedynczy komunikat pomiędzy dwoma procesorami - One-to-all broadcast - All-to-all broadcast - One-to-all personalized - All-to-all personalized - Circular shift 6 6
Komunikacja grupowa One-to-all broadcast M M M M 0 1 p-1 Single-node accumulation 0 1 p-1 M p-1 M p-1 M p-1 All-to-all broadcast M 1 M 0 M 1 M p-1 M 0 0 1 p-1 0 1 p-1 Multinode accumulation M 1 M 0 M 1 M 0 7 7
Komunikacja grupowa M p-1 M 1 M 0 One-to-all personalized M 0 M 1 M p-1 0 1 p-1 0 1 p-1 Single-node gather M 0,p-1 M 1,p-1 M p-1,p-1 M p-1,0 M p-1,1 M p-1.p-1 M 0,1 M 0,0 M 1,1 M 1,0 M p-1,1 M p-1,0 All-to-all personalized M 1,0 M 0,0 M 1,1 M 0,1 M 1,p-1 M 0,p-1 0 1 p-1 0 1 p-1 Multinode gather 8 8
One-to-all broadcast - SF 7 6 5 2 0 1 2 1 2 Dla sieci typu ring 7 6 5 T one _ to_ all_ b p 2 t t m s w 2 0 1 2 1 2 9 9
One-to-all broadcast - SF 12 1 1 15 8 9 10 11 5 6 7 1 2 0 1 2 2 T 2 t t m Dla sieci typu mesh z zapętleniem one _ to_ all_ b s w 10 10 p 2
One-to-all broadcast - SF (110) (111) 6 7 (010) (011) 2 2 1 2 5 (100) (101) 0 1 (000) (001) Dla sieci hypercube T t t m log p one_ to_ all_ b s w 11 11
One-to-all broadcast - SF procedure ONE_TO_ALL_BC(d,my_id,X); begin mask:=2 d -1; for i:=d-1 downto 0 do begin mask:=mask XOR 2 i ; if (my_id AND mask)=0 then if (my_id AND 2 i )=0 then begin msg_destination:=my_id XOR 2 i ; send X to msg_destination; endif else begin msg_source:=my_id XOR 2 i ; receive X from msg_source; endelse; endfor; end ONE_TO_ALL_BC Procesor 0 wysyła komunikat 12 12
All-to-all broadcast - SF 1(6) 1(5) 1() 7 6 5 1(7) (7) (6) (5) () (0) (1) (2) () 1() Pierwszy krok 0 1 2 1(0) 1(1) 1(2) 2(5) 2() 2() 7 6 5 2(6) (6,7) (5,6) (,5) (,) (0,7) (0,1) (1,2) (2,) 2(2) Drugi krok 0 1 2 2(7) 2(0) 2(1) 1 1
All-to-all broadcast - SF 7(0) 7(7) 7(6) 7 6 5 (1..7) (0..6) (0..5,7) (0..,6,7) (0,2..7) (0,1,..7) (0..2,..7) (0..,5..7) 0 1 2 7(2) 7() 7() 7(5) Siódmy krok 1 1
All-to-all broadcast - SF procedure ALL_TO_ALL_BC_RING(my_id,my_msg,p,result); begin left:=(my_id - 1) mod p; right:=(my_id + 1) mod p; result:=my_msg; msg:=result; for i:=1 to p-1 do begin send msg to right; receive msg from left; result:=result msg; endfor; end ALL_TO_ALL_BC_RING; T all to all bc t t m p 1 s w 15 15
All-to-all broadcast - SF (6) (7) 6 7 (6,7) (6,7) 6 7 (2) 2 () (2,) 2 (2,) (0) 0 () 1 (1) 5 (5) (0,1) 0 (,5) 1 5 (0,1) (,5) a) Wstępne rozmieszczenie komunikatów b) Rozmieszczenie komunikatów przed drugim krokiem 16 16
All-to-all broadcast - SF (..7) (..7) 6 7 (0..7) (0..7) 6 7 (0..) 2 (0..) (0..7) 2 (0..7) (0..) 0 (..7) 1 5 (0..) (..7) (0..7) 0 (0..7) 1 5 (0..7) (0..7) c) Rozmieszczenie komunikatów przed trzecim krokiem d) Końcowe rozmieszczenie komunikatów T all to all bc t s log p t w m p 1 17 17
One-to-all personalized - SF 7 6 5 0 1 2 Pierwszy krok 1(7) 7 6 5 0 1 2 Drugi krok 2(6) 2(7) 18 18
One-to-all personalized - SF 7(7) 7(6) 7(5) 7 6 5 0 1 2 7(1) 7(2) 7() 7() Siódmy krok T one to all pers t t m p 1 s w 19 19
One-to-all personalized - SF (12..15) 12 1 1 15 (8..11) 8 9 10 11 (..7) 5 6 7 (0..) 0 1 2 20 20
One-to-all personalized - SF 12 1 1 15 (12) (1) (1) (15) 8 0 9 10 11 (8) (9) (10) (11) 5 6 7 () (5) (6) (7) 1 2 (0) (1) (2) () T one to all pers p 1 t m p 1 2t s w 21 21
One-to-all personalized broadcast - SF 6 7 6 7 2 2 (0..7) 0 1 5 (0..) 0 (..7) 1 5 a) Wstępne rozmieszczenie komunikatów b) Rozmieszczenie komunikatów przed drugim krokiem 22 22
One-to-all personalized broadcast - SF (6,7) 6 7 (6) (7) 6 7 (2,) 2 (2) 2 () (0,1) 0 (,5) 1 5 (0) 0 () 1 (1) 5 (5) c) Rozmieszczenie komunikatów przed trzecim krokiem d) Końcowe rozmieszczenie komunikatów T one to all pers t s log p t w m p 1 2 2
Collective Communication MPI provides a variety of routines for distributing & redistributing data, gathering data, performing global sums etc. communications involving a group of processes It always involves every process in the communicator. Three classes of collective operations: synchronization - barrier data movement - broadcast, scatter, gather collective computation - global sum, global maximum, etc. 2 2
Characteristics of collective communication Collective communications cannot interfere with point-to-point communications and vice versa Collective and point-to-point communication are transparent to one another. A collective communication may or may not synchronize the processes involved Completion implies the buffer can be used or re-used. However, there is no such thing as a non-blocking collective communication in MPI. All processes in the communicator must call the collective communication. 25 25
Similarities & Differences with P2P Similarities: A message is an array of a particular data type. Data type must match between send and receive. Differences: There is no concept of tags. The sent message must fill the specified receive buffer. 26 26
Barrier synchronization This is the simplest of all the collective operations and involves no data at all. It blocks the calling processes until all group members have called it. In one phase of computation, all processes participate in writing a file. The file is to be used for the next phase of computation. Therefore, no process should proceed to the second phase until all processes are completed in phase one. MPI_Barrier(MPI_Comm communicator); 27 27
One_to_all Broadcast data from one process to all processes in a communicator A broadcast has a specified root process and every process receives one copy of the message from the root. All processes must specify the same root. data rank A0 broadcast A0 A0 A0 A0 MPI_Bcast(void *buf, /* INOUT buffer */ int count, MPI_Datatype datatype, int root, MPI_COMM_WORLD) 28 28
MPI_SCATTER Scatter data from one process to all processes in a communicator These routines also specify a root process and all processes must specify the same root. The main difference from broadcast is that send & receive details are different. 29 29
MPI_SCATTER data rank A0 A1 A2 A scatter A0 A1 A2 A MPI_Scatter(void *sendbuf, int sendcount, /* sent to each process */ MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_COMM_WORLD); 0 0
MPI_ALLGATHER, MPI_ALLTOALL Gather data from all processes in a group to one process These routines don t have a specified root process. Send & receive details are significant on all processes and can be different. 1 1
MPI_ALLGATHER, MPI_ALLTOALL data rank A0 A1 gather A0 A1 A2 A A2 A MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, /* for any single recv */ MPI_Datatype recvtype, int root, MPI_COMM_WORLD); 2 2
Global reduction operations These are used when we want to compute a result which involves data distributed across a group of processes. Sum of two integers Product of two real numbers The product of two square matrices Maximum of two integers return a result to a process or all processes MPI_Reduce( ); MPI_Allredule( );