Introduction
The Platform-Neutral Compute Intermediate Language, or PENCIL, is a C99-based language developed as part of the
CARP Project.
A key goal of the language is to serve as an intermediate language for the compilation of domain-specific languages.
The PENCIL representation can then be compiled into efficient, device-specific OpenCL code using a PENCIL-to-OpenCL compiler such as
PPCG.
This eliminates the need for the DSL implementer to develop different platform-specific backends: all that is needed to target different platforms is a PENCIL backend!
The PENCIL Scala library
The
PENCIL repository
contains a Scala library that can be used to implement a PENCIL backend for a DSL compiler.
The library provides the following:
- An in-memory representation of the PENCIL as a set of Scala
classes.
- Validation functions for the in-memory PENCIL representation.
- A printer to obtain PENCIL code from the in-memory representation.
This library significantly simplifies the development process of targeting a DSL to PENCIL,
by providing an API for building, manipulating, and printing the PENCIL intermediate representation.
Using the PENCIL Scala library
- Download the library:
git clone git@github.com:carpproject/pencil.git
- Build the library following the instructions in the README.txt file
-
To use the library, add the pencil.jar file to your CLASSPATH:
export CLASSPATH=$CLASSPATH:${PENCIL_CLONE}/pencil.jar
-
There is an example demonstrating the PENCIL library usage:
github
This example can also be found in the example directory in the PENCIL library repository.
Useful links
- VOBLA: a DSL for linear algebra targeting PENCIL:
github
- PENCIL IR internal documentation:
doxygen
- PENCIL to CUDA/OpenCL compiler:
PPCG