Intel vISA Spec: The Virtual ISA Object Format
intel_gpu_visa)Intel Gen9–Gen12 / Xe-LP / Xe-HPG / Xe-HPC / Xe2
master
Summary
Intel IGC Virtual ISA specification chapter: The Virtual ISA Object Format.
Syntax / Encoding
The Virtual ISA Object Format
Reference Notes
# The Virtual ISA Object Format
A virtual ISA object file consists of a stream of bytes, and the binary
format is presented in pseudo-structures similar to Java class file
format. Items in a structure are declared using the fundamental data
types (UW, UD, etc.). Each item in a structure takes at least one byte
of storage. If an item is a bit-field, its content is stored from the
LSB (bit 0) to the MSB. Multiple bit-field items may be packed into a
single byte, and the unused bits in a byte must be set to zero. If an
item is a byte sequence (e.g., a double word), its content is stored in
little-endian format starting from the least significant byte to the
most significant byte. Successive items in a structure are stored
sequentially without padding or alignment. The virtual ISA file contains
several variable-sized tables whose size is specified in another
number-of-elements item in the same structure (usually immediately
preceding the table). The table may itself contain other variable-sized
tables.
In addition to the binary format, a textual specification of the virtual
ISA format is also available. When in text format, a virtual ISA
assembly file is in ASCII text. Lines are separated by the newline
character ('n'). Whitespace is used to separate tokens in the assembly
file. Operands and variables in the text format description are
surrounded by angular brackets '<>', which are not part of the
assembly. Square brackets '\[\]' are used to signify that the field is
optional. Vertical bar '|' is used to represent that only one of the
items separated by it will be candidate. A number of pre-defined
directives may be used to declare variables and specify properties about
the kernel.
**Pre-defined Directives**
| Directive | Meaning |
| --- | --- |
| .kernel_attr | Attributes (global) |
| .decl | Variable declaration |
| .input | Input declaration |
| .version | Version number |
| .kernel | Name of the kernel |
| .function | Name of the function |
## Virtual ISA Header
The virtual ISA file header has the following format:
### common_isa_header
common_isa_header {
UD magic_number;
UB major_version;
UB minor_version;
UW num_kernels;
kernel_info kernel_info[num_kernels];
UW num_variables;
file_scope_var_info file_scope_var_info[num_variables];
UW num_functions;
function_info function_info[num_functions];
}
- **magic_number:** A magic number used to identify a virtual ISA binary file. This number is equal to 0x41534943 ('CISA' in hex).
- **major_version:** Version number for the virtual ISA binary file. For backward-compatibility, the vISA finalizer should accept any virtual ISA file whose version is less than its declared version.
- **minor_version:** Version number for the virtual ISA binary file. For backward-compatibility, the vISA finalizer should accept any virtual ISA file whose version is less than its declared version.
- **num_kernels:** Number of kernels included in the virtual ISA file. The maximum number of kernels allowed in a virtual ISA file is 512.
- **kernel_info:** Metadata information of a vISA kernel.
- **num_variables:** Number of file scope variable declarations included in the virtual ISA object.
- **file_scope_var_info:** Metadata information of a vISA variable. See file_scope_var_info for details.
- **num_functions:** Number of functions included in the virtual ISA.
- **function_info:** Metadata information of a vISA function. See function_info for details.
Each kernel in the table has the format:
### kernel_info
kernel_info {
UW name_len;
UB name[name_len];
UD offset;
UD size;
UD input_offset;
UW num_syms_variable;
variable_reloc_symtab variable_reloc_symtab[num_syms_variable];
UW num_syms_function;
function_reloc_symtab function_reloc_symtab[num_syms_function];
UB num_gen_binaries;
gen_binary_info gen_binary_info[num_gen_binaries];
}
- **name_len:** The length of the name of the kernel, must be between 1 to 65535 characters.
- **name:** The name of the kernel. It is not null-terminated.
- **offset:** The byte offset of the kernel, from the beginning of the file. The format of the kernel object is described in Section 4.5.8.
- **size:** The size of the kernel object in bytes. This does not include the optional GEN binary of the kernel.
- **input_offset:** The byte offset to the num_inputs field of the kernel object (see Section 4.5.8), from the beginning of the file. This field is used by the virtual ISA runtime to quickly access the input symbol table and set up thread payload.
- **num_syms_variable:** The number of file-scope variables refered to in this kernel.
- **variable_reloc_symtab:** The relocation maps for each file scope general variable symbolic reference. The format is described by reloc_sym
- **num_syms_function:** The number of file-scope functions refered to in this kernel.
- **function_reloc_symtab:** the relocation information (maps) for each function symbolic reference in this vISA object. The format is described by reloc_sym.
- **num_gen_binaries:** Virtual ISA provides optional fat binary support by allowing a kernel's GEN binary to be directly embedded in its virtual ISA file. Valid values are 0-4.
- **gen_binary_info:** The format is described by gen_binary_info.
The format of the relocation information for a symbol is described by:
### variable_reloc_symtab
variable_reloc_symtab {
UW symbolic_index;
UW resolved_index;
}
- **symbolic_index:** The original index used by a kernel to refer to another function or file-scope variable.
- **resolved_index:** The resolved index into either the variables or the functions table.
The format of the Gen Binary described by:
### gen_binary_info
gen_binary_info {
UB gen_platform;
UD binary_offset;
UD binary_size;
}
- **gen_platform:** GEN platform for this binary. Valid values are:
- 3: BDW
- 5: SKL
- 6: BXT
- 10: ICLLP
- 12: TGLLP
- **binary_offset:** The byte offset of the GEN binary for this kernel, from the beginning of the file.
- **binary_size:** The size of the GEN binary for this kernel in bytes.
The file_scope_var_info structure describes the characteristics of a general variable and has the following format:
### file_scope_var_info
file_scope_var_info {
UB linkage;
UW name_len;
UB name[name_len];
UB bit_properties;
UW num_elements;
UB attribute_count;
attribute_info attribute_info[attribute_count];
}
- **linkage:** Valid values are
- 0: extern
- 1: static
- 2: global
- **name_len:** The length of the name of the file scope variable; it must be between 1 to 255 characters.
- **name:** The name of the file scope variable. It is not null-terminated.
- **bit_properties:** This byte contains two items: type and alignment.
- type (bit 0-3): the data type of the variable. A variable may have type UD, D, UW, W, UB, B, UQ, Q, DF, and F.
- alignment (bit 4-7): the minimum byte alignment requirement for this variable. Valid values are:
| Binary Value| Alignment| Bytes |
| --- | --- | --- |
| 0 | BYTE | 1 (no alignment) |
| 1 | WORD | 2 |
| 2 | DWORD | 4 |
| 3 | QWORD | 8 |
| 4 | OWORD | 16 |
| 5 | GRF | 32 |
| 6 | 2_GRF | 64 |
| 7 | HWORD | 32 |
| 8 | 32WORD | 64 |
| 9 | 64WORD | 128 |
- **num_elements:** Describes the number of elements in this variable. Valid range is [1, 1024].
- **attribute_count:** Attributes for this variable.
- **attribute_info:** Description of Attributes for this variable. The format is described by attribute_info.
Metadata information of a vISA function object. Its format is described by
### function_info
function_info {
UB linkage;
UW name_len;
UB name[name_len];
UD offset;
UD size;
UW num_syms_variable;
variable_reloc_symtab variable_reloc_symtab[num_syms_variable];
UW num_syms_function;
function_reloc_symtab function_reloc_symtab[num_syms_function];
}
- **linkage:** For functions with extern linkage, the offset and size field must be 0. Valid values are
- 0: extern
- 1: static
- 2: global
- **name_len:** The length of the name of the function, must be between 1 to 65535 characters.
- **name:** The name of the function. It is not null-terminated.
- **offset:** The byte offset of the kernel, from the beginning of the file. The format of the kernel object is described in Section 4.5.8.
- **size:** The size of the kernel object in bytes. This does not include the optional GEN binary of the kernel.
- **num_syms_variable:** The number of file-scope variables refered to in this function.
- **variable_reloc_symtab:** The relocation maps for each file scope general variable symbolic reference. The format is described by reloc_sym
- **num_syms_function:** The number of file-scope functions refered to in this kernel.
- **function_reloc_symtab:** the relocation information (maps) for each function symbolic reference in this vISA object. The format is described by reloc_sym.
## vISA Object Format
| |
| --- |
| vISA Header |
| FN0 vISA Object |
| FN1 vISA Object |
| ... |
| KL0 vISA Object |
| KL0 GEN Binary (Optional) |
| ... |
**Kernels**
| **KL0** | Name length| Name string | vISA offset | vISA size | vISA input offset | GEN binaries | GEN binary offsets |
| --- | --- | --- | --- | --- | --- | --- | --- |
**Functions**
| **FN0 Name** | Linkage | Name length | Name string | vISA offset | vISA size |
| --- | --- | --- | --- | --- | --- |
## String Pool
The virtual ISA kernel binary maintains a table of string literals used
by a kernel. Each entry contains a string represent the names of a
variable, function, or attribute. The strings may have variable length.
The maximum length of each string is determined by whether it's used as
a variable/attribute/function/kernel name. In the object file, the
string pool appears as a byte stream where each string is stored
consecutively and separated by the null character. The first string in
the table (**n0**) is reserved to represent the null string ("").
## Attributes
The kernel declaration itself as well as most variable declarations may
contain one or more attributes. The purpose of an attribute is to
provide extensible mechanism for the front-end compiler to pass
auxiliary information about the vISA object (e.g., whether a variable's
life range is limited to one subroutine) that may assist the finalizer
in its code generation. It is the front end compiler's responsibility to
ensure that the appropriate attribute values are applied as the
finalizer will not verify their correctness. The finalizer will silently
ignore attributes that it does not recognize.
Two types of attributes are supported: one is an attribute with integer
constant value, and the other with string constant value. An integer
attribute's size can be of 0 to 4 bytes. An integer attribute without
value (or 0 byte as its value) is considered as a boolean attribute, which
is equivalent to an integer attribute with 0 or 1 as its value. vISA APIs
allow clients to choose what size to use for an integer attribute.
The **attribute_info** structure has the following format:
### attribute_info
attribute_info {
UD name;
UB size;
value;
}
- **name:** Index of the string storing the name of the attribute. It may have a maximum length of 64 bytes, and each byte must be one of the ASCII printable characters.
- **size:** The size in bytes of