pql a purely declarative java extension for parallel
play

PQL: A Purely-Declarative Java Extension for Parallel Programming - PowerPoint PPT Presentation

PQL: A Purely-Declarative Java Extension for Parallel Programming Christoph Reichenbach 1 , 2 , Yannis Smaragdakis 1 , 3 , Neil Immerman 1 1: University of Massachusetts, Amherst 2: Goethe University Frankfurt 3: University of Athens 1 W RITING


  1. PQL: A Purely-Declarative Java Extension for Parallel Programming Christoph Reichenbach 1 , 2 , Yannis Smaragdakis 1 , 3 , Neil Immerman 1 1: University of Massachusetts, Amherst 2: Goethe University Frankfurt 3: University of Athens 1

  2. W RITING PARALLEL PROGRAMS IS HARD • locking • races • side effect order • consistency models • distributing computations . . . PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 2

  3. E ASIER PARALLELISM Approach Problems User actions map-reduce emb. parallel + aggregation split computation fork-join divide-and-conquer (recursively) divide up problem PLINQ SQL-like, over containers tag parallel steps Pregel graph algorithms split into graph compu- tations, -mutations Frameworks for manual parallelisation Casual parallelism: fully automatic PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 3

  4. C ASUAL PARALLELISM • Pitfalls: – Side effects – Order dependency Declarative language Specify the ‘ what ’, not the ‘how’ PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 4

  5. PQL/J AVA • Declarative extension to Java: P arallel Q uery L anguage • Fully automatic parallelisation • Processes and builds Java containers PQL Java PQL PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 5

  6. PQL/J AVA • Declarative extension to Java: P arallel Q uery L anguage • Fully automatic parallelisation • Processes and builds Java containers Java for sequential code, PQL for parallel code PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 6

  7. PQL EXAMPLE DocRepository search_terms doc doc . . results contains all . doc ? doc query (Set.contains(doc)): DocRepository.getAll().contains(doc) && forall x: doc.contains(search_terms[x]); PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 7

  8. W HAT RICH LANGUAGE GIVES US CASUAL PARALLELISM ? • Embarrassingly parallel: Executable in O (1) with enough CPUs • Result from Descriptive Complexity : This language is precisely First-Order Logic a Using O ( n 3 ) cores may be a bit much... a if we assume a polynomial number of CPUs PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 8

  9. M AKING F IRST -O RDER L OGIC M ORE U SEFUL • Assert or compute results: – Finite set comprehension – SQL-style queries (minus aggregation, ordering) ∃ y. a[ x ] = b[ y ] x 0 true 1 false representation: ⇒ { 0 , 3 , . . . } 2 false 3 true . . . . . . PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 9

  10. A DDING REDUCTION reduce (add) x over i: x == a[i] • log-parallel performance • user-supplied reductors PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 10

  11. PQL OVERVIEW • +, − , . . . , ?:, ==, instanceof , &&, ||, − > • forall , exists • Java expressions as constants • m[k], m.get(k), c.length, c.size(), s.contains(e) • Container construction: – query (Set.contains( int x)): ... – query (Array[x] == float f): ... – query (Map.get(String s) == int i [ default v]): ... • reduce (sumInt) int x [ over y ]: ... PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 11

  12. M ORE PQL EXAMPLES assert forall Node n: sorted_list.contains(n) − > n.prev.value <= n.value; PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 12

  13. M ORE PQL EXAMPLES • Check sortedness of list PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 13

  14. M ORE PQL EXAMPLES • Check sortedness of list Set<Item> intersection = query (Set.get(Item element)): set0.contains(element) && set1.contains(element) && !element.is_dead; PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 14

  15. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 15

  16. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering query (Map.get(employee) == double bonus): employees.contains(employee) && bonus == employee.dept.bonus_factor ∗ ( reduce (sumDouble) v: exists Bonus b: employee.bonusSet.contains(b) && v == b.bonus_base); PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 16

  17. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering • Employee bonus table PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 17

  18. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering • Employee bonus table dot_product = reduce (add) x over y: x == a[y] ∗ b[y]; PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 18

  19. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering • Employee bonus table • Vector dot product PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 19

  20. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering • Employee bonus table • Vector dot product query (Map.find(value) == keyset default new PSet()): keyset == query (Set.contains(key)): m.get(key) == value; PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 20

  21. M ORE PQL EXAMPLES • Check sortedness of list • Set intersection together with filtering • Employee bonus table • Vector dot product • Invert map . . . PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 21

  22. R EALISTIC PQL EXAMPLE far out in the uncharted DocRepository results backwaters of the . . . it was abright cold day far 1 doc in april . out 1 doc in 2 doc the the 1 ✄ � . . count . . . . ✂ ✁ DocRepository.getAll().contains(doc) & PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 22

  23. R EALISTIC PQL EXAMPLE far out in the uncharted DocRepository results backwaters of the . . . it was abright cold day far 1 doc in april . out 1 doc in 2 doc in the 1 ✄ � . . count . . . . ✂ ✁ DocRepository.getAll().contains(doc) & PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 23

  24. R EALISTIC PQL EXAMPLE far out in the uncharted DocRepository results backwaters of the . . . it was abright cold day far 1 doc in april . out 1 doc in 2 doc the 1 ✄ � . . count . . . . ✂ ✁ query (Map.get( int word_id) == int wcount default 0): wcount == reduce (sum) 1 over doc: DocRepository.getAll().contains(doc) && exists i: doc.words[i] == word_id; PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 24

  25. I MPLEMENTATION • Extension to javac 1.6: – PQL to relations – Access path selection / Query scheduling – Optimisation – Code generation • Run-time library support: – parallel execution PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 25

  26. E XAMPLE ✄ � Gen. relational IL ✂ ✁ reduce (max) int x: a[x] > 0 Query ordering Optimisation Code generation Int( x ) Translation into relational IL PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 26

  27. E XAMPLE ✄ � Gen. relational IL ✂ ✁ reduce (max) int x: a[x] > 0 Query ordering Optimisation Code generation Int( x ) ArraySub(a, x , t 0 ) Translation into relational IL PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 27

  28. E XAMPLE ✄ � Gen. relational IL ✂ ✁ reduce (max) int x: a[x] > 0 Query ordering Optimisation Code generation Int( x ) ArraySub(a, x , t 0 ) GT( t 0 , 0) Translation into relational IL PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 28

  29. E XAMPLE ✄ � Gen. relational IL ✂ ✁ reduce (max) int x: a[x] > 0 Query ordering Optimisation Code generation Int( x ) ArraySub(a, x , t 0 ) GT( t 0 , 0) Unordered! PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 29

  30. E XAMPLE Gen. relational IL reduce (max) int x: a[x] > 0 ✞ ☎ Query ordering ✝ ✆ Optimisation Code generation Int( x w ) ArraySub(a r , x r , t 0 w ) GT( t 0 r , 0) Order #1: Must iterate over 2 32 values! PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 30

  31. E XAMPLE Gen. relational IL reduce (max) int x: a[x] > 0 ✞ ☎ Query ordering ✝ ✆ Optimisation Code generation ArraySub(a r , x w , t 0 w ) Int( x r ) GT( t 0 r , 0) Order #2: Iterate over a.length values PQL: P ARALLEL Q UERIES FOR J AVA C. R EICHENBACH , Y. S MARAGDAKIS , N. I MMERMAN (UM ASS ) 31

Recommend


More recommend