The first open standard intermediate language for parallel compute and graphics

同时能在特效和并行计算中使用无需调整的shader language,还是很万金油的

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 will be incorporated as part of the core specification of both OpenCL 2.1 and the new Vulkan graphics and compute API. SPIR-V exposes the machine model for OpenCL 1.2, 2.0, 2.1 and Vulkan - including full flow control, and graphics and parallel constructs not supported in LLVM. SPIR-V also supports OpenCL 1.2, 2.0, 2.1 kernel languages as well as the GLSL shader language for Vulkan (under development).

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 Tools        

         SPIR-V LLVM       

SPIR-V Online Compiler

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

Evolution of SPIR

Driving the SPIR-V Open Source Ecosystem

Open Source Eco