Algebraic Specialization of Generic Functions for Recursive Types - PowerPoint PPT Presentation
Algebraic Specialization of Generic Functions for Recursive Types By: Alcino Cunha, Hugo Pacheco Presented by: Joseph Tsun Kiet Man 1 Index 1. Introduction 1. Problem 2. Solutions 2. Specialization: Non-recursive Types 1. Theory 2.
Algebraic Specialization of Generic Functions for Recursive Types By: Alcino Cunha, Hugo Pacheco Presented by: Joseph Tsun Kiet Man 1
Index 1. Introduction 1. Problem 2. Solutions 2. Specialization: Non-recursive Types 1. Theory 2. Example 3. Specialization: Recursive Types 1. Theory 2. Example 4. Concluding remarks 2 5. Summary
Introduction | Problem Given the following data structure: IMDB Movie Actor Name Played Year Title Box Office Director Review Country Value Year Title Role Award 3
Introduction | Problem 4
Introduction | Problem πππππ = ππππππππππ ( πππ ππππππ π‘ππ‘π ) wher ere π‘ππ‘π ππππππ π = ππππππ π Performance loss due to: Run-time checks to determine at each node whether to β’ apply specific / generic behaviour. Traversal through whole data structure. β’ 5
Introduction | Solutions How to solve the inefficiencies? Restricting the power of traversal combinators. β’ Offsets run-time checks to compile-time. β’ Specialization β’ Transformation Generic function Specialized function πππππ β² = π‘ππ β πππ π‘ππ β πππ π‘ππ‘π β πππππππ‘ β ππππππ‘ wher ere ππππππ‘ π½ππ½π½ π π = π 6 πππππππ‘ ππππππ π = π
Specialization: Non-recursive Types Theory Recapitulation SYB: 7
Specialization: Non-recursive Types Theory Recapitulation SYB: 8
Specialization: Non-recursive Types Theory Point-free combinators and functions: 9
Specialization: Non-recursive Types Theory Algebraic Transformation Laws: 10
Specialization: Non-recursive Types Theory Algebraic Query Laws: 11
Specialization: Non-recursive Types Example πππππ = ππππππππππ ( πππ ππππππ π‘ππ‘π ) wher ere π‘ππ‘π ππππππ π = ππππππ π Rewrite: 12
Specialization: Non-recursive Types Example πππππ = ππππππππππ ( πππ ππππππ π‘ππ‘π ) wher ere π‘ππ‘π ππππππ π = ππππππ π Rewrite: 13
Specialization: Non-recursive Types Example πππππ = ππππππππππ ( πππ ππππππ π‘ππ‘π ) wher ere π‘ππ‘π ππππππ π = ππππππ π Rewrite: 14
Specialization: Non-recursive Types Example πππππ = ππππππππππ ( πππ ππππππ π‘ππ‘π ) wher ere π‘ππ‘π ππππππ π = ππππππ π Rewrite: 15
Specialization: Recursive Types Theory Apply same concept to catamorphisms and paramorphisms: 16
Specialization: Recursive Types Theory Catamorphisms: functions defined by iteration. 17
Specialization: Recursive Types Theory Paramorphisms: all functions that can be defined by primitive recursion. 18
Specialization: Recursive Types Theory Idea: Rewrite the everywhere function. β’ Rewrite the everything function β’ 19
Specialization: Recursive Types Theory Everywhere function redefined: 20
Specialization: Recursive Types Theory Everywhere function redefined: 21
Specialization: Recursive Types Theory Recap - Algebraic Transformation Laws: 22
Specialization: Recursive Types Theory New additional laws for catamorphisms and paramorphisms. 23
Specialization: Recursive Types Example Function 24
Specialization: Recursive Types Example Function 25
Specialization: Recursive Types Application 26
Specialization: Performance 27
Specialization: Improvements Improvements: Support for non-regular data types (e.g. nested). β’ Added symbolic evaluation (intermediate structures are β’ completely removed during optimization). 28
Specialization: Conclusion Specialization comes near handwritten code. β’ Specialized code can be optimized by compiler β’ optimization methods. Specialization by rewriting generic function to β’ specialized functions. 29
Recommend
More recommend
Explore More Topics
Stay informed with curated content and fresh updates.