Skip to content

Latest commit

 

History

History
127 lines (95 loc) · 4.54 KB

cl_khr_spir.asciidoc

File metadata and controls

127 lines (95 loc) · 4.54 KB

Standard Portable Intermediate Representation Binaries

This extension adds the ability to create an OpenCL program object from a Standard Portable Intermediate Representation (SPIR) instance. A SPIR instance is a vendor-neutral non-source representation for OpenCL C programs.

The extension name is cl_khr_spir. This extension has been superseded by the SPIR-V intermediate representation, which is supported by the cl_khr_il_program extension, and is a core feature in OpenCL 2.1.

General information

Version history

Date Version Description

2020-04-21

1.0.0

First assigned version.

Additions to Chapter 4 of the OpenCL 2.2 Specification

Add a new device property to table 4.3 in section 4.2:

Table 1. List of supported param_names by {clGetDeviceInfo}
Device Info Return Type Description

{CL_DEVICE_SPIR_VERSIONS}

{char_TYPE}[]

A space separated list of SPIR versions supported by the device.

For example, returning "1.2" in this query implies that SPIR version 1.2 is supported by the implementation.

Additions to Chapter 5 of the OpenCL 2.2 Specification

Additions to section 5.8.1 — Creating Program Objects:

"{clCreateProgramWithBinary} can be used to load a SPIR binary. Once a program object has been created from a SPIR binary, {clBuildProgram} can be called to build a program executable or {clCompileProgram} can be called to compile the SPIR binary."

Modify the {CL_PROGRAM_BINARY_TYPE} entry in table 5.14 for {clGetProgramBuildInfo} to add a potential value {CL_PROGRAM_BINARY_TYPE_INTERMEDIATE}:

Table 2. List of supported param_names by {clGetProgramBuildInfo}
Program Build Info Return Type Description

{CL_PROGRAM_BINARY_TYPE}

{cl_program_binary_type_TYPE}

{CL_PROGRAM_BINARY_TYPE_INTERMEDIATE} — An intermediate (non-source) representation for the program is loaded as a binary. The program must be further processed with {clCompileProgram} or {clBuildProgram}.

If processed with {clCompileProgram}, the result will be a binary of type {CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT} or {CL_PROGRAM_BINARY_TYPE_LIBRARY}. If processed with {clBuildProgram}, the result will be a binary of type {CL_PROGRAM_BINARY_TYPE_EXECUTABLE}.

Additions to section 5.8.4 — Compiler Options:

"The compile option -x spir must be specified to indicate that the binary is in SPIR format, and the compile option -spir-std must be used to specify the version of the SPIR specification that describes the format and meaning of the binary. For example, if the binary is as described in SPIR version 1.2, then -spir-std=1.2 must be specified. Failing to specify these compile options may result in implementation defined behavior."

Additions to section 5.8.5 — Separate Compilation and Linking of Programs:

Replace this error for {clCompileProgram}:

  • {CL_INVALID_OPERATION} if program has no source or IL available, i.e. it has not been created with {clCreateProgramWithSource} or {clCreateProgramWithIL}.

with:

  • {CL_INVALID_OPERATION} if program has no source or IL available, i.e. it has not been created with {clCreateProgramWithSource} or {clCreateProgramWithIL} or {clCreateProgramWithBinary} where -x spir is present in options.

Additions to section 5.9.3 — Kernel Object Queries:

Modify following text in {clGetKernelArgInfo} from:

"Kernel argument information is only available if the program object associated with kernel is created with {clCreateProgramWithSource} and the program executable is built with the -cl-kernel-arg-info option specified in options argument to {clBuildProgram} or {clCompileProgram}."

to:

"Kernel argument information is only available if the program object associated with kernel is created with {clCreateProgramWithSource} and the program executable is built with the -cl-kernel-arg-info option specified in options argument to {clBuildProgram} or {clCompileProgram}, or if the program object associated with kernel is created with {clCreateProgramWithBinary} and the program executable is built with the -cl-kernel-arg-info and -x spir options specified in options argument to {clBuildProgram} or {clCompileProgram}."