1 / 12

8INF433

8INF433. Algorithmes parallèles. Algorithmes parallèles. Trois nouvelles instructions: s pawn s ync parallèle. Exemple: Fibonacci. P-Fib (n) if n<=1 return n else x = spawn P-Fib(n-1) y = P-Fib(n-2) sync return x+y. Exemple: Fibonacci.

karim
Download Presentation

8INF433

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 8INF433 Algorithmes parallèles

  2. Algorithmes parallèles Trois nouvelles instructions: • spawn • sync • parallèle

  3. Exemple: Fibonacci P-Fib(n) if n<=1 return n else x = spawn P-Fib(n-1) y = P-Fib(n-2) sync return x+y

  4. Exemple: Fibonacci

  5. Mesures de performance • Travail (work): temps séquentiel • Durée (span): temps parallèle • TP:temps d’exécution sur P processeurs • T1: travail • T∞:durée • Loi du travail: TP ≥ T1/P • Loi de la durée: TP ≥ T∞ • Parallélisme: T1/T∞≥ T1/Tp(accélération)

  6. Analyse de P-Fib T1(n) = θ(ϕn) où ϕ est le nombre d’or T∞(n) = max(T∞(n-1), T∞(n-2)) + θ(1) = T∞(n-1) + θ(1) = θ(n) Parallélisme: θ(ϕn/n)

  7. Boucles parallèles Exemple: On veut multiplier une matrice M par un vecteur x Mat-Vec(M,x,n) parallèle for i=1 to n do y[i]=0 parallèle for i=1 to n do for j=1 to n do y[i] = y[i] + M[i,j]*x[j] return y

  8. Implémentation des boucles parallèles On implémente les boucles parallèles à l’aide de l’instruction spawn: Mat-Vec-Main-Loop(M,x,y,n,d,f) if (d==f) for j=1 to n do y[d] = y[d] + M[d,j]*x[j] else m = (d+f)/2 spawn Mat-Vec-Main-Loop(M,x,y,n,d,m) Mat-Vec-Main-Loop(M,x,y,n,m+1,f) sync

  9. Implémentation des boucles parallèles

  10. Analyse de Mat-Vec(A,x,n) • Travail: θ(n2) • Durée: Total: θ(n) • Parallélisme: θ(n2/n) = θ(n) Mat-Vec(M,x,n) parallèle for i=1 to n do y[i]=0 parallèle for i=1 to n do for j=1 to n do y[i] = y[i] + M[i,j]*x[j] return y Θ(lg n) Θ(lg n) + θ(n) Θ(1)

  11. Multiplication matricielle (1) P-Square-Matrix-Multiply(A,B,n) parallèle for i=1 to n do parallèle for j=1 to n do C[i,j]=0 for k=1 to n do C[i,j] = C[i,j] + A[i,k]*B[k,j] return C

  12. Multiplication matricielle (2)

More Related