Join GitHub today
Asp: A SEJITS Implementation for Python
Asp is a research prototype and implementation of SEJITS (Selective, Embedded Just-in-Time Specialization) for Python. With the aid of application-specific specializers, it compiles fragments of Python down to low-level parallelized CPU and GPU implementations. For more information on the SEJITS methodology, see our paper.
Available on Github at
git clone git://github.com/shoaibkamil/asp.git
A list of links to Technical Papers about SEJITS.
Send all feedback to skamilATmitDOTedu.
Installation: There's are several ways to get started with Asp: Using a VM, Using a VM via Vagrant (if you have Ruby installed), or Installing Required Libraries (on Mac or Linux). Alternatively, if installing Ruby/Vagrant/etc is not desirable, you can do a bare install of Ubuntu in a VM (using Virtualbox or VMware) and follow the instructions in Installing Required Libraries. To install the required libraries in a Windows environment, follow the instructions in Getting Started on Windows x64.
- Tutorials on Developing for Asp
- Screencasts at YouTube introducing Asp
- Debugging hints and suggestions
A specializer is a small compiler, written in Python, which translates a code fragment written in a subset of Python into a low-level language for fast, parallel execution. See Specializers for a list of existing specializers with contact and download information.
Namespaces / API
Contains classes used for code generation and manipulation.
Python AST nodes and manipulation. Currently, the same as Python's AST library, using the same interfaces.
AST nodes for C++. Available nodes include those in CodePy, plus others we've added as needed. For CodePy nodes, see the documentation for codepy.cgen. Additional nodes are in the file asp/codegen/cpp_ast.py. See the StencilKernel example and ConvertAST for lots of examples of using these.
ConvertAST: Converts Python ASTs to C++ ASTs. This only provides very basic conversion, and doesn't handle many of Python's constructs. The idea is that specializers create their own class that inherits from this to do their custom code generation. ConvertAST supplies the basics, such as converting simple arithmetic expressions.
ASTNodeReplacer: A very limited replacer for Python AST nodes. Designed to do simple replacements of names.
NodeVisitor: Asp's version of NodeVisitor works for both C++ and Python ASTs. Implements the visitor pattern on ASTs.
NodeTransformer: ASP's version of NodeTransformer performs the visitor pattern on ASTs with node replacement.
Provides Mako's template interface. Currently is exactly like Mako's API. Note that asp.codegen.templating.template is just a synonym for the mako.templating.template namespace. Let us know if more functionality from Mako is wanted/required.
Wrapper around CodePy's codepy.jit library, implementing just-in-time compilation.
The ASPModule class implements a facade around CodePy's module and toolchain abstractions, while enabling specializers to use strings and not just cpp_ast nodes to define functions, add libraries, add header files, etc. The source file is pretty self explanatory, but see the two examples for how to use it as well.
Functions for specifying build targets, querying things from configuration files, etc. Currently only implements platform detection for Linux targets.
Contains debug_print() which will only output if the environment variable ASP_DEBUG exists.
Currently the best way to get a feel for the code is to look in the tests/ subdirectory for unit tests, as well as the example included: ArrayDoubler. ArrayDoubler is a toy example that uses templates to generate a string, which is then compiled into a Python module and called.
For additional example specializers see Specializers. Particularly illustrative is the Stencil/Structured Grid specializer, which implements a full abstract syntax tree (AST) transformation specializer, by having a phased tree-walk through the AST.