The Standard Portable Intermediate Representation for Device Programs
SPIR (Standard Portable Intermediate Representation) is a portable, non-source representation for devices programs. It enables application developers to avoid shipping kernel source and to manage the proliferation of devices and drivers from multiple vendors. SPIR enables the consumption of code from third party compiler front-ends for alternative languages to C, such as C++. SPIR 1.2 supports OpenCL C as defined in the OpenCL 1.2 specification.
SPIR is a mapping from the OpenCL C programming language into LLVM IR. This version of the SPIR is based on LLVM 3.2 and OpenCL C as defined in the OpenCL 1.2 specification. The goal of SPIR is to provide a portable interchange format for partly compiled OpenCL C programs. A secondary goal of SPIR is to provide a useful target format for compilers of other programming languages. SPIR is:
- Vendor neutral
- Is not C source code
- Supports all core features and KHR extensions for version 1.2 of OpenCL C
- Is designed to support vendor extensions.
- Is compact.
- Is designed to be efficiently loaded by an OpenCL implementation.
- The SPIR 1.2 Specification is available in the Khronos Registry
- The SPIR forum – good for questions and feedback
- For SPIR bug reporting use the Khronos Bugzilla system under OpenCL SPIR
- The latest SPIR FAQ
- The SPIR Verifier from Khronos Github (LLVM pass checks SPIR validity)
- Press Release: Khronos Launches Final SPIR Specification 21st Jan 2014
The following diagram provides a high-level summary of SPIR. A more in-depth overview is found in the SPIR presentation in the resources section above.