SPIR Overview


The first open standard intermediate language for parallel compute and graphics

SPIR (Standard Portable Intermediate Representation) was initially developed for use by OpenCL and SPIR versions 1.2 and 2.0 were based on LLVM. SPIR has now evolved into a true cross-API standard that is fully defined by Khronos with native support for shader and kernel features – called SPIR-V.

SPIR-V is the first open standard, cross-API intermediate language for natively representing parallel compute and graphics and is incorporated as part of the core specification of both OpenCL 2.1 and OpenCL 2.2 and the new Vulkan graphics and compute API.

SPIR-V exposes the machine model for OpenCL 1.2, 2.0, 2.1, 2.2 and Vulkan - including full flow control, and graphics and parallel constructs not supported in LLVM. SPIR-V also supports OpenCL C and OpenCL C++ kernel languages as well as the GLSL shader language for Vulkan (under development).

SPIR-V 1.1, launched in parallel with OpenCL 2.2, now supports all the kernel language features of OpenCL C++ in OpenCL 2.2, including initializer and finalizer function execution modes to support constructors and destructors. SPIR-V 1.1 also enhances the expressiveness of kernel programs by supporting named barriers, subgroup execution, and program scope pipes.

SPIR-V is catalyzing a revolution in the language compiler ecosystem - it can split the compiler chain across multiple vendors’ products, enabling high-level language front-ends to emit programs in a standardized intermediate form to be ingested by Vulkan or OpenCL drivers.   For hardware vendors, ingesting SPIR-V eliminate the need to build a high-level language source compiler into device drivers, significantly reducing driver complexity, and will enable a broad range of language and framework front-ends to run on diverse hardware architectures.

For developers, using SPIR-V means that kernel source code no longer has to be directly exposed, kernel load times can be accelerated and developers can choose the use of a common language front-end, improving kernel reliability and portability across multiple hardware implementations.


SPIR–V 1.2 Resources

  • The SPIR V 1.2 Specification is available in the Khronos Registry
  • SPIR-V Tools project including an assembler, binary module parser, disassembler, and validator for SPIR-V
  • SPIR-V Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.
  • SPIR-V LLVM framework is intended to contain LLVM <-> SPIR-V converter and serve as a foundation for LLVM-based front-end compilers targeting SPIR-V.
  • SPIR-V issue reporting on Github
  • SPIR-V feedback forum offers community support for questions and feedback

SPIR–V 1.1 Resources

SPIR–V 1.0 Resources

SPIR 1.2/2.0 Resources

SPIR 2.0 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 2.0 specification. SPIR 2.0 supports all core features and KHR extensions for version 2.0 of OpenCL C

SPIR-V Transforms the Language Ecosystem

  • First multi-API, intermediate language for parallel compute and graphics
    • Native representation for Vulkan shader and OpenCL kernel source languages
    • https://www.khronos.org/registry/spir-v/papers/WhitePaper.pdf
  • Cross vendor intermediate representation
    • Language front-ends can easily access multiple hardware run-times
    • Acceleration hardware can leverage multiple language front-ends
    • Encourages tools for program analysis and optimization in SPIR form

Evolution of SPIR Family

SPIR–V is first fully specified Khronos-defined SPIR standard

  • Does not use LLVM to isolate from LLVM roadmap changes
  • Includes full flow control, graphics and parallel constructs beyond LLVM
  • Khronos has open sourced SPIR-V <-> LLVM conversion tools to enable construction of flexible toolchains that use both intermediate languages

Driving the SPIR-V Open Source Ecosystem