GithubHelp home page GithubHelp logo

tensordsl's Introduction

Haskell-based implementation of a stand-alone compiler for the core CFDlang domain-specific language.

This project implements a stand-alone compiler for the CFDlang DSL (domain-specific language) in Haskell. The compiler translates tensor kernels specified in the CFDlang DSL into C functions. This project focuses on the core elements of the CFDlang DSL to showcase the adequacy of functional programming for parsing and for manipulating ASTs (abstract syntax trees), including semantic analysis and (intermediate) code generation. This is of pronounced significance since relying on functional programming languages for implementations of high-level code generators is not very common in CFDlang's application domain, i.e. Computational Fluid Dynamics (CFD).

References

The reference implementation of the full CFDlang language appears in the repository at github.com/normanrink/cfdlang. For a comprehensive description of CFDlang and its implementation, please refer to the article CFDlang: High-level code generation for high-order methods in fluid dynamics. Note, however, that the core part of CFDlang that is accepted by the stand-alone compiler in the present repository is closer to the language described in Modeling of languages for tensor manipulation.

Getting started

The stand-alone CFDlang compiler is built with cabal. Running cabal build from the project root directory actually produces two executable binaries:

  • CKernelGen translates a tensor kernel written in CFDlang into a semantically equivalent C function that will typically consist of sequences of loop nests and will accept multi-dimensional arrays as formal arguments.
  • FrontEnd implements the same functionality as CKernelGen, except that it prints out the CFDlang source code that the current invocation of FrontEnd operates on as well as a transformed version of this source code with lifted tensor contractions. For example, running <build-dir>/FrontEnd <src-dir>/tests/axbxc.in produces output
       Program with lifted periods:
       var in a : [2 3]
       var in b : [2 3]
       var in c : [2 3]
       var in u : [3 3 3]
       var out w : [2 2 2]
    
       _t0 = (((a#b)#c)#u).[1 6]
       _t1 = _t0.[2 5]
       w = _t1.[3 4]
    
    followed by C source code that implements this CFDlang kernel. Tensor contractions are lifted in the CFDlang kernel above because every expression in an assignment contains at most one contraction (denoted by .[m n]) at the top level; no nested contractions appear inside expressions.

Both the CKernelGen and FrontEnd binaries accept a command line argument that should be the path to a CFDlang source file. Alternatively, CFDlang source code can be entered on the console after either of the CKernelGen or FrontEnd executables has been invoked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.