La présentation est en train de télécharger. S'il vous plaît, attendez

La présentation est en train de télécharger. S'il vous plaît, attendez

Algorithmes parallèles à grain adaptatif : Quelques exemples Projet MOAIS (www-id.imag.fr/MOAIS) Laboratoire ID-IMAG (CNRS-INRIA.

Présentations similaires


Présentation au sujet: "Algorithmes parallèles à grain adaptatif : Quelques exemples Projet MOAIS (www-id.imag.fr/MOAIS) Laboratoire ID-IMAG (CNRS-INRIA."— Transcription de la présentation:

1

2 Algorithmes parallèles à grain adaptatif : Quelques exemples Jean-Louis.Roch@imag.fr Projet MOAIS (www-id.imag.fr/MOAIS) Laboratoire ID-IMAG (CNRS-INRIA INPG-UJF)

3 MOAIS Multi-programmation et Ordonnancement pour les Applications Interactives de Simulation Programming and Scheduling Design of Interactive Simulation Applications on Distributed Resources

4 ID Research activities Adaptive middleware –Resource management and scheduling systems –Resource brokering based on prediction tools –2nd generation Open Grid Service Architecture with a P2P approach –Operational aspect of P2P systems –Deployability of P2P services (memberships) Network operating systems –Open source Grid-aware OS (extensions of Linux) Distributed algorithms –Dependable and adaptative Programming models & languages –High-performance component models –Lightweight component platforms –QoS aware self-organizing component platforms with dynamic reconfiguration –Automatic exploitation of coarse-grain algorithms Communication models –Generic framework Computational models Novel algorithms & applications –Need for grid-aware algorithms and applications Large scale data management –Shared objects, persistence, coherency Security / Accountability –P2P services in an unfriendly world Tools –Performance analysis & prediction Application testbeds –Bioinformatics –Engineering applications

5 ID Research activities Two INRIA projects : –MOAIS [contact: Jean-Louis.Roch@imag.fr] Programming & scheduling Adaptive and interactive applications –2 full-time researchers [INRIA] –4 [assistant| ] professors [3 INPG, 1 UJF] –14 Ph-D students –MESCAL [contact: Bruno.Gaujal@inrialpes.fr] Dynamic resource management Performance evaluation and dimensioning –2 full-time researchers [INRIA, CNRS] –6 [assistant| ] professors [2 INPG, 4 UJF] –13 Ph-D students

6 Objective Programming of applications where performance is a matter of resources: take benefit of more and suit to less – eg : a global computing platform (P2P) Application code : independent from resources and adaptive Target applications: interactive simulation – virtual observatory MOAIS intearction simulation rendering Performance is related to #resources - simulation : precision=size/order #procs, memory space - rendering : images wall, sounds,... #video-projectors, #HPs,... - interaction : acquisition peripherals #cameras, #haptic sensors, …

7 GRIMAGE platform 2003 : 11 PCs, 8 projectors and 4 cameras First demo : 12/03 2005: 30 PCs, 16 projectors and 20 cameras –A display wall : Surface: 2x2.70 m Resolution: 4106x3172 pixels Very bright: daylight work Commodity components [B. Raffin]

8 Video [J Allard, C Menier]

9 Description of potential parallelism + synchronizations Middleware Processs creation, communications Discovery / Resilience of resources MOAIS abstraction technology : almost non-preemptive scheduling Dynamic Architecture Application [macro dataflow graph] Athapascan-like MOAIS : to adapt parallelism by scheduling Local preemptive scheduling / time sharing Primitives for synchronization

10 How to adapt the application ? By minimizing communications e.g. amortizing synchronizations in the simulation [Beaumont, Daoudi, Maillard, Manneback, Roch - PMAA 2004] adaptive granularity By contolling latency (interactivity constraints) : FlowVR [Allard, Menier, Raffin] overhead By managing node failures and resilience [Checkpoint/restart][checkers] FlowCert [Jafar, Krings, Leprevost; Roch, Varrette] By adapting granularity malleable tasks [Trystram, Mounié] dataflow cactus-stack : Athapascan/Kaapi [Gautier] recursive parallelism by « work-stealling » [Blumofe-Leiserson 98, Cilk, Athapascan,... ] Self-adaptive grain algorithms dynamic extraction of paralllelism [Daoudi, Gautier, Revire, Roch - J. TSI 2004 ]

11 Algorithmes parallèles à grain adaptatif : Quelques exemples Ordonnancement de programme parallèle à grain fin : work-stealing et efficacité Algorithmes à grain adaptatif : principe d une « cascade » dynamique Exemples

12 In « practice »: coarse granularity Splitting into p = #resources Drawback : heterogeneous architecture, dynamic In « theory »: fine granularity Maximal parallelism Drawback : overhead of tasks management How to choose/adapt granularity ? a b H(a) O(b,7) F(2,a) G(a,b)H(b) High potential degree of parallelism

13 Parallelism and efficiency Difficult in general (coarse grain) But easy if T small (fine grain) T p = T 1 /p + T [Greedy scheduling, Graham69] Expensive in general (fine grain) But small overhead if coarse grain Scheduling efficient policy (close to optimal) control of the policy (realisation) Problem : how to adapt the potential parallelism to the resources ? «Depth » parallel time on resources T = #ops on a critcal path « Work » sequential time T 1 = #operations => to have T small with coarse grain control

14 Work stealing scheduling of a parallel recursive fine-grain algorithm Work-stealing scheduling an idle processor steals the oldest ready task Interests : => #succeeded steals suited to heterogeneous architectures [Bender-Rabin 03,....] Hypothesis for efficient parallel executions: the parallel algorithm is « work-optimal » T is very small (recursive parallelism) a « sequential » execution of the parallel algorithm is valid e.g. : search trees, Branch&Bound,... Implementation : work-first principle [Multilisp, Cilk, …] overhead of task creation only upon steal request: sequential degeneration of the parallel algorithm cactus-stack management

15 Intérêt : Grain fin « statique », mais contrôle dynamique Inconvénient: surcôut possible de lalgorithme parallèle [ex. préfixes] f2 Implementation of work-stealing fork f2 f1() { …. fork f2 ; … } steal f1 P + non-préemptive execution of ready task P Hypothesis : a sequential schedule is valid f1 Stack

16 Experimentation: knary benchmark SMP Architecture Origin 3800 (32 procs) Cilk / Athapascan Distributed Archi. iCluster Athapascan #procsSpeed-Up 87,83 1615,6 3230,9 6459,2 10090,1 T s = 2397 s T 1 = 2435

17 How to obtain an efficient fine-grain algorithm ? Hypothesis for efficiency of work-stealing : the parallel algorithm is « work-optimal » T is very small (recursive parallelism) Problem : Fine grain (T small) parallel algorithms may involve a large overhead with respect to a sequential efficient algorithm: Overhead due to parallelism creation and synchronization But also arithmetic overhead

18 Sequential algorithm : for (i= 0 ; i <= n; i++ ) P[ i ] = P[ i – 1 ] * a [ i ] ; T 1 = n Parallel algorithm : T =2. log n BUT T 1 = 2.n i Indeed parallelism often costs... Préfixe ( n / 2 ) a0a0 a1a1 a2a2 anan a3a3 *** a n-1 P0P0 P2P2 P n-1 * P3P3 * P1P1 * PnPn

19 Algorithmes parallèles à grain adaptatif : Quelques exemples Ordonnancement de programme parallèle à grain fin : work-stealing et efficacité Algorithmes à grain adaptatif : principe d une « cascade » dynamique Exemples

20 Self-adaptive grain algorithm Principle : To save parallelism overhead by provilegiating a sequential algorithm : => use parallel algorithm only if a processor becomes idle by extracting parallelism from a sequential computation Hypothesis : two algorithms : - 1 sequential : SeqCompute - 1 parallel : LastPartComputation => at any time, it is possible to extract parallelism from the remaining computations of the sequential algorithm SeqCompute Extract_par LastPartComputation SeqCompute

21 Generic self-adaptive grain algorithm

22 Illustration : f(i), i=1..100 LastPart(w) W=2..100 SeqComp(w) sur CPU=A f(1)

23 Illustration : f(i), i=1..100 LastPart(w) W=3..100 SeqComp(w) sur CPU=A f(1);f(2)

24 Illustration : f(i), i=1..100 LastPart(w) on CPU=B W=3..100 SeqComp(w) sur CPU=A f(1);f(2)

25 Illustration : f(i), i=1..100 SeqComp(w) sur CPU=A f(1);f(2) LastPart(w) on CPU=B W=3..51 SeqComp(w) LastPart(w) W=52..100 LastPart(w)

26 Illustration : f(i), i=1..100 SeqComp(w) sur CPU=A f(1);f(2) W=3..51 SeqComp(w) LastPart(w) W=52..100 LastPart(w)

27 Illustration : f(i), i=1..100 SeqComp(w) sur CPU=A f(1);f(2) W=3..51 SeqComp(w) sur CPU=B f(52) LastPart(w) W=53..100 LastPart(w)

28 Cascading a parallel and a sequential algorithm In general : two different algorithms may be used: Sequential recursive algorithm : T s operations algo(n) = {...; algo(n-1);... } Parallel algorithm : T small but T 1 >> T s Work-preserving speed-up [Bini-Pan 94] = cascading technique [Jaja92] Careful interplay of both algorithms to build one with both T small and T 1 = O( T s ) But fine grain : Divide the sequential algorithm into block Each block is compute with the (non-optimal) parallel algorithm Adaptive grain: duale approach : parallelism is extracted from any sequential task

29 E.g.Triangular system solving 0.x = b Sequential algorithm : T 1 = n 2 /2; T = n (fine grain) 0.x = b A 1/ x 1 = - b 1 / a 11 2/ For k=2..n b k = b k - a k1.x 1 0.x = b system of dimension n-1 system of dimension n

30 E.g.Triangular system solving 0.x = b Sequential algorithm : T 1 = n 2 /2; T = n (fine grain) Using parallel matrix inversion : T 1 = n 3 ; T = log 2 n (fine grain) 0 A 21 A 22 A 11 = 0 S A 22 A 11 S= -A 22. A 21. A 11 with A = and x=A -1.b Self-adaptive granularity algorithm : T 1 = n 2 ; T = n.log n 0.x = b ExtractPar and self-adaptive scalar product self adaptive sequential algorithm self-adaptivematrix inversion choice of h = m h m

31 Algorithmes parallèles à grain adaptatif : Quelques exemples Ordonnancement de programme parallèle à grain fin : work-stealing et efficacité Algorithmes à grain adaptatif : principe d une « cascade » dynamique Exemples Produit itéré, préfixe Compression gzip Inversion de systèmes triangulaire Vision 3D / Calcul doct-tree

32 Produit iteré Séquentiel, parallèle, adaptatif [Davide Vernizzi] Séquentiel : Entrée: tableau de n valeurs Sortie: c/c++ code: for (i=0; i<n; i++) res += atoi(x[i]); Algorithme parallèle : calcul récursif par bloc (arbre binaire avec fusion) Taille de bloc = pagesize Code kaapi : athapascan API Expérimentation : parallèle adaptatif

33 Variante : somme de pages Entrée: ensemble de n pages. Chaque page est un tableau de valeurs Sortie: une page où chaque élément est la somme des éléments de même indice des pages pr é c é dentes c/c++ code: for (i=0; i<n; i++) for (j=0; j<pageSize; j++) res [j] += f (pages[i][j]); Expérimentation : - lalgorithme parallèle co û te environ 2 fois plus que l algorithme s é quentiel - lalgorithme adaptatif a une efficacité proche de 1

34 Démonstration sur ensibull Script: [vernizzd@ensibull demo]$ more go-tout.sh #!/bin/sh./spg /tmp/data &./ppg /tmp/data 1 --a1 -thread.poolsize 3 &./apg /tmp/data 1 --a1 -thread.poolsize 3 & Résultat: [vernizzd@ensibull demo]$./go-tout.sh Page size: 4096 Memory allocated 0:In main: th = 1, parallel 0: ----------------------------------------- 0: res = -2.048e+07 0: time = 0.408178 sADAPTATIF (3 procs) 0: Threads created: 54 0: ----------------------------------------- 0: res = -2.048e+07 0: time = 0.964014 sPARALLELE(3 procs) 0: #fork = 7497 0: ----------------------------------------- : ----------------------------------------- : res = -2.048e+07 : time = 1.15204 sSEQUENTIEL (1 proc) : -----------------------------------------

35 Doù vient la différence ? …Les sources des programmes Source des codes pour la somme des pages : parallèle / arbre binaire adaptatif par couplage ; - séquentiel + Fork - LastParComp: génération (récursive) de 3 tâches

36 struct Iterated { void operator() (a1::Shared_w res, int start, int stop) { if ( (stop-start) <2) { // If max num of pages is reached, sequential algorithm Page resLocal (pageSize); IteratedSeq(start, resLocal); res.write(resLocal); } else { // If max num of pages is not reached int half = (start+stop)/2; a1::Shared res1; // First thread result a1::Shared res2; // Second thread result a1::Fork () (res1, start, half); //First thread a1::Fork () (res2, half, stop); //Second thread a1::Fork () (res, res1, res2); //Merging results... }}}; Algorithme parallèle

37 Parallélisation adaptative Calcul par bloc sur des entrées en k blocs: 1 bloc = pagesize Exécution indépendante des k tâches Fusion des resultats

38 Algorithme adaptatif (1/3) Hypothèse: ordonnancement non préemptif - de type work-stealing Couplage séquentiel adaptatif : void Adaptative (a1::Shared_w *resLocal, DescWork dw) { // cout << "Adaptative" << endl; a1::Shared resLPC; a1::Fork () (resLPC, dw); Page resSeq (pageSize); AdaptSeq (dw, &resSeq); a1::Fork () (resLPC, *resLocal, resSeq); }

39 Algorithme adaptatif (2/3) Côt é s é quentiel : void AdaptSeq (DescWork dw, Page *resSeq){ DescLocalWork w; Page resLoc (pageSize); double k; while (!dw.desc->extractSeq(&w)) { for (int i=0; i<pageSize; i++ ) { k = resLoc.get (i) + (double) buff[w*pageSize+i]; resLoc.put(i, k); } *resSeq=resLoc; }

40 Algorithme adaptatif (3/3) Côt é extraction = algorithme parall è le : struct LPC { void operator () (a1::Shared_w resLPC, DescWork dw){ DescWork dw2; dw2.Allocate(); dw2.desc->l.initialize(); if (dw.desc->extractPar(&dw2)) { a1::Shared res2; a1::Fork () (res2, dw2.desc->i, dw2.desc->j); a1::Shared resLPCold; a1::Fork () (resLPCold, dw); a1::Fork () (resLPCold, res2, resLPC); } };

41 Parallélisation adaptative Une seule tache de calcul est demarrée pour toutes les entrées Division du travail qui reste à faire seulement dans le cas où un processeur devient inactif Moins de taches, moins de fusions

42 Exemple 2 : parallélisation de gzip Gzip : Utilisé (web) et coûteux bien que de complexité linéaire Code source :10000 lignes C, structures de données complexes Principe : LZ77 + arbre Huffman Pourquoi gzip ? Problème P-complet, mais parallélisation pratique possible Inconvénient: toute parallélisation (connue) entraîne un surcoût -> perte de taux de compression

43 Fichier compressé Fichier en entrée Compression à la volée Algorithme Partition dynamique en blocs Parallélisation « facile »,100% compatible avec gzip/gunzip Problèmes : perte de taux de compression, grain dépend de la machine, surcoût Blocs compressés Compression parallèle Partition statique en blocs Parallélisation => Comment paralléliser gzip ?

44 Output compressed file Input File Compression à la volée SeqComp LastPartComputation Output compressed blocks Parallel compression Parallélisation gzip à grain adaptatif Dynamic partition in blocks cat

45 Taille Fichiers Gzip Adaptatif 2 procs Adaptatif 8 procs Adaptatif 16 procs 0,86 Mo272573275692280660 5,2 Mo1,023Mo1,027Mo1,05Mo1,08 Mo 9,4 Mo6,60 Mo6,62 Mo6,73 Mo6,79 Mo 10 Mo1,12 Mo1,13 Mo1,14 Mo1,17 Mo 5,2 Mo3,35 s0,96 s0,55 s 9,4 Mo7,67 s6,73 s6,79 s 10 Mo6,79 s1,71 s0,88 s Surcoût en taille de fichier comprimé Gain en T

46 Performances Pentium 4x200Mhz

47 Conclusion Grain adaptatif Cascade dynamique récursive de 2 algos : 1 séquentiel, 1 parallèle Génération de parallélisme que sur inactivité de ressources -> Opérateur de base : ExtractPar de travail séquentiel en cours Programmation générique,... et simple !?? Intérêt Réduction du surcoût lié au parallélisme : - création de tâche, ordonnancement - surcoût arithmétique intrinsèque - Gain pratique: code PL inférence probabiliste [Mazer, SHARP] Perspectives - Expérimentations SMP et distribuées : gzip, préfixes,.... - Extension au cas distribué et hétérogène : ajout/résilience - Extensions à dautres algorithmes: [action IMAG-INRIA AHA] Vision 3D, calcul formel,...

48 APACHE/MOAIS + EVASION, [J Allard, C Menier, R Revire, F Zara] Video Questions ?

49 Performance

50 Performances sur SMP Pentium 4x200 Mhz

51 Performances en distribué Séquentiel Pentium 4x200 Mhz SMP Pentium 4 x200 Mhz Architecture distribuée Myrinet Pentium 4 x200 Mhz + 2 x333 Mhz Recherche distribuée dans 2 répertoires de même taille chacun sur un disque distant (NFS)


Télécharger ppt "Algorithmes parallèles à grain adaptatif : Quelques exemples Projet MOAIS (www-id.imag.fr/MOAIS) Laboratoire ID-IMAG (CNRS-INRIA."

Présentations similaires


Annonces Google