-
Notifications
You must be signed in to change notification settings - Fork 1
Home
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.
Send all feedback to skamilATcs.berkeley.edu.
Available on Github at
git clone git://github.com/shoaibkamil/asp.git
Everything is in a state of flux and coding, but an API freeze is planned to occur "soon" (late summer). Feature requests/patches/anything of the form "It would make things easier if...." are much appreciated.
There's two ways to get started with Asp: Using a VM via Vagrant 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.
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 two examples included: StencilKernel and ArrayDoubler.
StencilKernel implements a full AST transformation specializer, by having a phased tree-walk through the AST. The first phase is done by StencilProcessAST, which replaces the stencil iterators with special nodes. The second phase is done by StencilConvertAST (which subclasses ConvertAST), which converts these Python AST nodes and special nodes into C++ code. This is the general pattern for the AST-walking specializers: do multiple walks of the AST at both the python_ast and cpp_ast level, implementing optimizations and domain-specific code generation as converting special nodes.
ArrayDoubler is a toy example that uses templates to generate a string, which is then compiled into a Python module and called.