Writing Loopless APL Compiler

living the loopless life n.w
1 / 109
Embed
Share

"Explore the development of a loopless APL compiler designed to be data-parallel, GPU-friendly, fast, maintainable, and portable. Discover the innovative approach focusing on syntactic control flow syntax. Dive into the world of functional programming without traditional loops."

  • Functional Programming
  • APL Compiler
  • Loopless
  • Data-Parallel
  • GPU-Friendly

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Living the Loopless Life Aaron W. Hsu arcfide@sacrideo.us LambdaConf 2024, Estes Park, CO

  2. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code,

  3. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL.

  4. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless,

  5. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless, meaning no syntactic control flow syntax.

  6. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless, meaning no syntactic control flow syntax. It is designed to be:

  7. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless, meaning no syntactic control flow syntax. It is designed to be: Data-parallel, GPU-friendly,

  8. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless, meaning no syntactic control flow syntax. It is designed to be: Data-parallel, GPU-friendly, Fast,

  9. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless, meaning no syntactic control flow syntax. It is designed to be: Data-parallel, GPU-friendly, Fast, Maintainable,

  10. ? ? ? ? ? ? ? ? ? ? ? Background I write APL code, primarily a compiler for APL written in APL. Almost all of it is Loopless, meaning no syntactic control flow syntax. It is designed to be: Data-parallel, GPU-friendly, Fast, Maintainable, Portable.

  11. ? ? ? ? ? ? ? ? ? ? ? Background APL is (one of) the best language(s) for this. Why?

  12. ? ? ? ? ? ? ? ? ? ? ? Background APL is (one of) the best language(s) for this. Why? From an HCI/d perspective,

  13. ? ? ? ? ? ? ? ? ? ? ? Background APL is (one of) the best language(s) for this. Why? From an HCI/d perspective, how does APL support large-scale, data-parallel, loopless software?

  14. ? ? ? ? ? ? ? ? ? ? ? Background APL is (one of) the best language(s) for this. Why? From an HCI/d perspective, how does APL support large-scale, data-parallel, loopless software? What are its unique ergonomic affordances?

  15. ? ? ? ? ? ? ? ? ? ? ? Background Most people don t get APL. They miss the big picture.

  16. ? ? ? ? ? ? ? ? ? ? ? Baseline

  17. ? ? ? ? ? ? ? ? ? ? ? Baseline This is the part everyone gets :

  18. ? ? ? ? ? ? ? ? ? ? ? Baseline Monadic Conjugate Negative Signum Reciprocal Magnitude CeilingMaximum Floor Exponent Nat Log Factorial Dyadic + - | * ! Plus Minus Times Divide Residue Minimum Power Logarithm Binomial

  19. ? ? ? ? ? ? ? ? ? ? ? Baseline Monadic Conjugate Negative Signum Reciprocal Magnitude CeilingMaximum Floor Exponent Nat Log Factorial Dyadic Dyadic And Or Nand Nor + - | * ! Plus Minus Times Divide Residue Minimum Power Logarithm Binomial

  20. ? ? ? ? ? ? ? ? ? ? ? Baseline Monadic Conjugate Negative Signum Reciprocal Magnitude CeilingMaximum Floor Exponent Nat Log Factorial Dyadic Dyadic And Or Nand Nor < Less than Less than or Equal = Equal Greater than > Greater than or Equal Not Equal + - | * ! Plus Minus Times Divide Residue Minimum Power Logarithm Binomial

  21. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d

  22. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d ,A A

  23. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d ,A n ,A A k A d A

  24. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d ,A n ,A A k A d A Y Nesting level of A

  25. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d ,A n ,A A k A d A Y Nesting level of A X Y X same as Y X Y X not same as Y

  26. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d ,A n ,A A k A d A Y Nesting level of A X Y X same as Y X Y X not same as Y Scalars Arrays

  27. ? ? ? ? ? ? ? ? ? ? ? Baseline ?: Array Elements: e e e ? Shape: d d ,A n ,A A k A d A Y Nesting level of A X Y X same as Y X Y X not same as Y Scalars Arrays (make-array (array-shape A) (map s-prim (array-elems A)))

  28. ? ? ? ? ? ? ? ? ? ? ? Baseline Dyadic Application 0 1 2 3 4 0 1 2 3 4 0 1 4 9 16 5 6 7 8 9 0 1 2 3 4 0 6 14 24 36 10 11 12 13 14 0 1 2 3 4 0 11 24 39 56 15 16 17 18 19 0 1 2 3 4 0 16 34 54 76 20 21 22 23 24 0 1 2 3 4 0 21 44 69 96

  29. ? ? ? ? ? ? ? ? ? ? ? Baseline Scalar Extension 0 1 2 3 4 0 5 10 15 20 5 6 7 8 9 25 30 35 40 45 10 11 12 13 14 5 50 55 60 65 70 15 16 17 18 19 75 80 85 90 95 20 21 22 23 24 100 105 110 115 120

  30. ? ? ? ? ? ? ? ? ? ? ? Baseline Rank Polymorphic Pointwise Lifting Scalar Function Primitives

  31. ? ? ? ? ? ? ? ? ? ? ? Baseline Indexing/Assignment A[I ; ;I ] I I A

  32. ? ? ? ? ? ? ? ? ? ? ? Baseline Indexing/Assignment A[I ; ;I ] X A[I ; ;I ] (f A) X I I A

  33. ? ? ? ? ? ? ? ? ? ? ? Baseline Indexing/Assignment A[I ; ;I ] X A[I ; ;I ] X(f@g)Y (f A) X I I A

  34. ? ? ? ? ? ? ? ? ? ? ? Baseline Indexing/Assignment A[I ; ;I ] X A[I ; ;I ] X(f@g)Y (f A) X I I A Composition (Points-free/Tacit) X f g Y (X f (g Y)) X f Y Y f X X f g Y f (X g Y) A f Y (A f Y) X A Y A X f g Y (g X) f (g Y) f A Y (Y f A) X(f g h)Y (X f Y) g (X h Y) X (f g) Y f (X g Y)

  35. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern

  36. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern {X} f {X} f[axis] Y Along axis Y Each/Map

  37. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern {X} f {X} f[axis] Y Along axis X .f Y Outer product X f.g Y Inner product Y Each/Map

  38. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern {X} f {X} f[axis] Y Along axis X .f Y Outer product X f.g Y Inner product {X} f N Y Repeated iteration {X} f g Y Fixed Point Y Each/Map

  39. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern {X} f {X} f[axis] Y Along axis X .f Y Outer product X f.g Y Inner product {X} f N Y Repeated iteration {X} f g Y Fixed Point {X} f v Y Rank {X} f s Y Stencil {X} f Y Key/Group by Y Each/Map

  40. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern Y Each/Map f Y Reduce (First axis) {X} f {X} f[axis] Y Along axis f/ Y Reduce (Last axis) X .f Y Outer product X f.g Y Inner product {X} f N Y Repeated iteration {X} f g Y Fixed Point {X} f v Y Rank {X} f s Y Stencil {X} f Y Key/Group by

  41. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern Y Each/Map f Y Reduce (First axis) {X} f {X} f[axis] Y Along axis f/ Y Reduce (Last axis) X .f Y Outer product X f Y N-wise reduce (First) X f.g Y Inner product X f/ Y N-wise reduce (Last) {X} f N Y Repeated iteration {X} f g Y Fixed Point {X} f v Y Rank {X} f s Y Stencil {X} f Y Key/Group by

  42. ? ? ? ? ? ? ? ? ? ? ? Iteration/Traversal Pointwise isn t the only pattern Y Each/Map f Y Reduce (First axis) {X} f {X} f[axis] Y Along axis f/ Y Reduce (Last axis) X .f Y Outer product X f Y N-wise reduce (First) X f.g Y Inner product X f/ Y N-wise reduce (Last) {X} f N Y Repeated iteration f Y Scan (First axis) {X} f g Y Fixed Point f\ Y Scan (Last axis) {X} f v Y Rank {X} f s Y Stencil {X} f Y Key/Group by

  43. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to change the structure of arrays

  44. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to change the structure of arrays Y Table X Y Catenate (First) X , Y Catenate (Last)

  45. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to change the structure of arrays Y Table Y Lift depth X Y Take X Y Catenate (First) Y Push depth X Y Drop X , Y Catenate (Last)

  46. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to change the structure of arrays X , Y Catenate (Last) Y Lift depth X Y Take Y Table Y Push depth X Y Drop X Y Catenate (First) Y Reverse (Last) Y Reverse (First) X Y Rotate (Last) X Y Rotate (First)

  47. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to change the structure of arrays X , Y Catenate (Last) Y Lift depth X Y Take Y Table Y Push depth X Y Drop X Y Catenate (First) X Y Transpose Y Reverse (Last) Y Reverse (First) X Y Rotate (Last) X Y Rotate (First)

  48. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to change the structure of arrays X , Y Catenate (Last) Y Lift depth X Y Take Y Table Y Push depth X Y Drop X Y Catenate (First) X Y Transpose Y Reverse (Last) Y Reverse (First) Y Enclose X Y Enc. Partition X Y Rotate (Last) Y Nest X Y Partition X Y Rotate (First) Y Flatten

  49. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to select elements from arrays

  50. ? ? ? ? ? ? ? ? ? ? ? Manipulation We need to select elements from arrays Y First X Y Pick

Related


More Related Content