13 research outputs found

    Stream Fusion, to Completeness

    Full text link
    Stream processing is mainstream (again): Widely-used stream libraries are now available for virtually all modern OO and functional languages, from Java to C# to Scala to OCaml to Haskell. Yet expressivity and performance are still lacking. For instance, the popular, well-optimized Java 8 streams do not support the zip operator and are still an order of magnitude slower than hand-written loops. We present the first approach that represents the full generality of stream processing and eliminates overheads, via the use of staging. It is based on an unusually rich semantic model of stream interaction. We support any combination of zipping, nesting (or flat-mapping), sub-ranging, filtering, mapping-of finite or infinite streams. Our model captures idiosyncrasies that a programmer uses in optimizing stream pipelines, such as rate differences and the choice of a "for" vs. "while" loops. Our approach delivers hand-written-like code, but automatically. It explicitly avoids the reliance on black-box optimizers and sufficiently-smart compilers, offering highest, guaranteed and portable performance. Our approach relies on high-level concepts that are then readily mapped into an implementation. Accordingly, we have two distinct implementations: an OCaml stream library, staged via MetaOCaml, and a Scala library for the JVM, staged via LMS. In both cases, we derive libraries richer and simultaneously many tens of times faster than past work. We greatly exceed in performance the standard stream libraries available in Java, Scala and OCaml, including the well-optimized Java 8 streams

    Finally, a Polymorphic Linear Algebra Language (Pearl)

    Get PDF
    Many different data analytics tasks boil down to linear algebra primitives. In practice, for each different type of workload, data scientists use a particular specialised library. In this paper, we present Pilatus, a polymorphic iterative linear algebra language, applicable to various types of data analytics workloads. The design of this domain-specific language (DSL) is inspired by both mathematics and programming languages: its basic constructs are borrowed from abstract algebra, whereas the key technology behind its polymorphic design uses the tagless final approach (a.k.a. polymorphic embedding/object algebras). This design enables us to change the behaviour of arithmetic operations to express matrix algebra, graph algorithms, logical probabilistic programs, and differentiable programs. Crucially, the polymorphic design of Pilatus allows us to use multi-stage programming and rewrite-based optimisation to recover the performance of specialised code, supporting fixed sized matrices, algebraic optimisations, and fusion

    Fold-based fusion as a library: a generative programming pearl

    Get PDF
    Fusion is a program optimisation technique commonly implemented using special-purpose compiler support. In this paper, we present an alternative approach, implementing fold-based fusion as a standalone library. We use staging to compose operations on folds; the operations are partially evaluated away, yielding code that does not construct unnecessary intermediate data structures. The technique extends to partitioning and grouping of collections

    An efficient implementation of lazy functional programming languages based on the generalized intensional transformation

    Get PDF
    Αυτή η εργασία διερευνά θεωρητικά και πρακτικά ζητήματα της αλληλεπίδρασης μεταξύ (ευρέως γνωστών και νέων) τεχνικών μεταγλώττισης, όπως ο γενικευμένος νοηματικός μετασχηματισμός, ο μετασχηματισμός σε συναρτησιακά αντικείμενα, η ξεχωριστή μεταγλώττιση και η λάμβδα άρση. Ένας πειραματικός μεταγλωττιστής για τη γλώσσα Haskell (GIC), ο οποίος χρησιμοποιεί τις τεχνικές αυτές, δίνει τη δυνατότητα σε νέες ιδέες να υλοποιηθούν και να αξιολογηθούν μέσα σε ένα πρακτικό πλαίσιο. Ως μέρος αυτής της δουλειάς πραγματοποιήθηκαν διάφορες προσθήκες και αλλαγές στο μεταγλωττιστή, είτε προκειμένου να γίνει ο μεταγλωττιστής πληρέστερος είτε προκειμένου να βελτιωθεί ο τελικός κώδικας που παράγεται από το LAR back-end του μεταγλωττιστή.This dissertation investigates theoretical and practical issues of the integration between (well-known and novel) compilation techniques, such as the generalized intensional transformation, defunctionalization, separate compilation, and lambda lifting. An experimental Haskell compiler (GIC), which incorporates these techniques, serves as a workbench allowing ideas to be demonstrated and evaluated in a practical context. Within the scope of this work, several additions and changes were made to the compiler either towards enchancing the tool’s robustness or towards the optimization of the code generated by the compiler’s LAR back-end

    Proceedings of the 4th DIKU-IST Joint Workshop on the Foundations of Software

    Get PDF

    Compilation and Code Optimization for Data Analytics

    Get PDF
    The trade-offs between the use of modern high-level and low-level programming languages in constructing complex software artifacts are well known. High-level languages allow for greater programmer productivity: abstraction and genericity allow for the same functionality to be implemented with significantly less code compared to low-level languages. Modularity, object-orientation, functional programming, and powerful type systems allow programmers not only to create clean abstractions and protect them from leaking, but also to define code units that are reusable and easily composable, and software architectures that are adaptable and extensible. The abstraction, succinctness, and modularity of high-level code help to avoid software bugs and facilitate debugging and maintenance. The use of high-level languages comes at a performance cost: increased indirection due to abstraction, virtualization, and interpretation, and superfluous work, particularly in the form of tempory memory allocation and deallocation to support objects and encapsulation. As a result of this, the cost of high-level languages for performance-critical systems may seem prohibitive. The vision of abstraction without regret argues that it is possible to use high-level languages for building performance-critical systems that allow for both productivity and high performance, instead of trading off the former for the latter. In this thesis, we realize this vision for building different types of data analytics systems. Our means of achieving this is by employing compilation. The goal is to compile away expensive language features -- to compile high-level code down to efficient low-level code
    corecore