1 / 14

8INF856

8INF856. Algorithmes parallèles. Le langage parallèle Cilk. Trois nouveaux mots clés: s pawn s ync Parallel Si on enlève ces mots clés, on obtient un programme C standard. Exemple: Fibonacci. P-Fib (n) if n<=1 return n else x = spawn P-Fib(n-1) y = P-Fib(n-2)

chinue
Télécharger la présentation

8INF856

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. 8INF856 Algorithmes parallèles

  2. Le langage parallèle Cilk Trois nouveaux mots clés: • spawn • sync • Parallel Si on enlève ces mots clés, on obtient un programme C standard.

  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

  6. Mesures de performance • Loi du travail: TP ≥ T1/P • Loi de la durée: TP ≥ T∞ • Accélération: T1/Tp ≤ P • Parallélisme: T1/T∞ ≥ T1/Tp

  7. 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)

  8. 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

  9. 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

  10. Implémentation des boucles parallèles

  11. 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)

  12. 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

  13. Multiplication matricielle (2)

  14. Algorithme de Strassen

More Related