450 likes | 553 Views
Parallelism in Logic Programming. Claudio F. R. Geyer II - UFRGS Inês de Castro Dutra COPPE - Sistemas - UFRJ. Outline. Introduction Sequential Implementation Parallel Implementation Performance Conclusions Future Work. Introduction. Why logic programming? Formal basis
E N D
Parallelism in Logic Programming Claudio F. R. Geyer II - UFRGS Inês de Castro Dutra COPPE - Sistemas - UFRJ
Outline • Introduction • Sequential Implementation • Parallel Implementation • Performance • Conclusions • Future Work
Introduction • Why logic programming? • Formal basis • expression power • implicit parallelism • suitability to some problems • Main Language: Prolog • syntax • declarative and operational semantics
parent(arthur,carol). parent(carol,john). grandparent(X,Y) :- parent(X,Z), parent(Z,Y). length([H|T],N) :- length(T,N1), N is N1+1. length([],0). Introduction
Sequential Implementation • Interpreters x Compilers • WAM (WarrenAbstract Machine) • structure copying • environments • choicepoints • heap • trail
Parallel Implementation • Control Parallelism • ORP: Or-parallelism • ANDP: And-parallelism • And + Or • Data Parallelism • Unification • Path
Parallel Implementation: ORP • Problems • representation of multiple bindings to the same variable • Solutions • stack sharing • stack copying
Parallel Implementation: ORP • Stack sharing • binding arrays • hash windows • version vectors • variable importation • …
Parallel Implementation: ORP • Speculative work • Prolog semantics? • Side-effects and pruning • Scheduling
Parallel Implementation: ANDP • IAP: Independent and-parallelism • DAP: Dependent and-parallelism • DetAP: Determinate and-parallelism
Parallel Implementation: IAP • Goals that do not share variables can proceed in parallel. • Compiler support • CGEs: Conditional Graph Expressions
Parallel Implementation: IAP paper(P,A,D,L) :- author(A), date(D), loc(P,A,D,L). Possible CGE: indep(A) & indep(D) => author(A) & date(D),loc(P,A,D,L)
Parallel Implementation: IAP • Cross-product of solutions • Recomputation qsort([], []). qsort([P|T],L) :- partition(T,P,A,B), qsort(A,L1), qsort(B,L2), append(L1,[P|L2],L).
Parallel Implementation: DAP • Goals that share variables can proceed in parallel • Producer and consumer • Chosen at compile-time or runtime • one value or stream • Compiler support
Parallel Implementation: DAP producer(N,Out) :- N > 0, N1 is N - 1, Out = [ferrari|Ms], producer(N1,Ms). producer(0,Out) :- Out = []. consumer([ferrari|Ms]) :- go-ride-ferrari, consumer(Ms). consumer([]).
Parallel Implementation: DetAP • Goals that match at most one clause can be executed first and in parallel • Compiler support • Reduction of search space
Parallel Platforms • Shared-memory • Distributed memory • Distributed-shared memory • Implicit x Explicit Parallelism • Programming Model • Process or processor-based
Shared-memory Or-Parallel Systems • Aurora • WAM-based • processor-based • shared stacks • binding arrays
Shared-memory Or-Parallel Systems • Scheduling in Aurora • Wavefront • Argonne • Manchester • Bristol • Dharma
Shared-memory Or-Parallel Systems • Wavefront, Manchester and Argonne: topmost dispatching • Bristol and Dharna: bottom-most dispatching • speculative work
Shared-memory Or-Parallel Systems • Muse • WAM-based • processor-based • stack copying
Muse: Stack Copying • Multiple environments maintained via stack-copying • Memory space divided into identical address spaces to avoid pointer relocation • Incremental copying
Shared-memory Or-Parallel Systems • Scheduling in Muse • Sophisticated operations to avoid data race • workers keep data structures about idle and busy workers below their subtrees • Shadowing • Preference to leftmost work
Shared-memory And-Parallel Systems • &-Prolog • &ACE • DASWAM
Shared-memory And-Parallel Systems • &-Prolog • RAP-WAM • CGEs • compiler support • &ACE • based on &-Prolog • DASWAM • DAP and IAP, producer determined at runtime
Shared-memory And+Or Systems • Andorra-I • ACE • SBA • ParAKL • Penny • DAOS
Andorra-I • Determinate and-parallelism • or-parallelism • side-effects, cuts and commits • teams of workers • scheduling • reduction of search space
Andorra-I DetAP phase #det goals = 0 ORP phase #det goals <> 0
Shared-memory And+Or Systems • ACE • IAP + ORP • Stack copying • IAP a la &-Prolog • Composition tree • Last parallel call optimisation
SBA • IAP + ORP • Stack sharing • Shared Binding Arrays • IAP a la &ACE • Binding array divided into fixed segment sizes • Conditional variable bound to a pair <seg#,offset>
Performance prog name Andorra-I JAM Aurora Muse nrv400 8.25 8.37 ---- ---- bt_cluster 9.37 9.70 ---- ---- bt_wms 3.32 ---- ---- ---- road_markings 6.24 ---- ---- ---- chat_80_db5 7.30 ---- 7.30 5.91 5x4x3_puzzle 9.66 ---- 9.51 8.69 warplan 1.20 ---- 2.63 1.06 protein_all 6.81 ---- 9.49 8.64 protein_1st 2.78 ---- 4.10 3.12 fly_pan 6.88 ---- ---- ---- scanner 5.47 ---- ---- ---- cipher 5.65 ---- ---- ----
Performance Pgm map 8queen Xword 8queenp zebra flypan Prolog 5003 383146 6377 133612 19404 10539 Andorra-I 1047 214918 835 8496 5757 1517 Reduction in search space
Applications • Optimisation Problems • Databases • Natural Language Processing • Data Mining • Constraint Satisfaction Problems • ….
Conclusions • Logic programming: high level of abstraction • Favours Implicit Parallelism • Several applications • Good performance on small to medium parallel architectures • High performance is coming!
Future Work • More efficient methods to combine and + or parallelism • Scheduling is an important issue • Sophisticated compiler support • Memory management • Parallel constraint logic programming • Efficient cluster implementations • Applications
Future Work Ideal System