The disclosure relates generally to computer processor architecture, and, more specifically, to floating-point support circuitry to implement floating-point operations on a two-dimensional grid of fixed-point processing elements.
A processor, or set of processors, executes instructions from an instruction set, e.g., the instruction set architecture (ISA). The instruction set is the part of the computer architecture related to programming, and generally includes the native data types, instructions, register architecture, addressing modes, memory architecture, interrupt and exception handling, and external input and output (I/O). It should be noted that the term instruction herein may refer to a macro-instruction, e.g., an instruction that is provided to the processor for execution, or to a micro-instruction, e.g., an instruction that results from a processor's decoder decoding macro-instructions.
The present disclosure is illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements and in which:
In the following description, numerous specific details are set forth. However, it is understood that examples may be practiced without these specific details. In other instances, well-known circuits, structures, and techniques have not been shown in detail in order not to obscure the understanding of this description.
Matrices may be increasingly important in many computing tasks such as machine learning and other bulk data processing. Deep Learning is a class of machine learning algorithms. Deep learning architectures, such as deep neural networks, may be applied to fields including computer vision, speech recognition, natural language processing, audio recognition, social network filtering, machine translation, bioinformatics, and drug design.
Inference and training, two tools used for deep learning, may utilize low precision arithmetic. Maximizing throughput of deep learning algorithms and computations may assist in meeting the needs of deep learning processors, for example, those performing deep learning in a data center.
Matrix-matrix multiplication (a.k.a., GEMM or General Matrix Multiplication) is a compute-heavy operation on certain processors. Special hardware for matrix multiplication (e.g., GEMM) is a good option for improving the peak compute (and energy efficiency) of certain applications, such as deep learning. Some of these applications, including deep learning, can operate on input data elements with relatively few bits without losing accuracy, as long as the output elements have enough bits (e.g., more than the inputs).
In certain processors, handling matrices is a difficult and/or instruction intensive task. For example, rows of a matrix could be put into a plurality of packed data (e.g., SIMD or vector) registers and then operated on individually. For example, an add two 8×2 (e.g., row by column) matrices may require a load or gather into four packed data registers depending upon data sizes. Then a first add of packed data registers corresponding to a first row from each matrix is performed and a second add of packed data registers corresponding to a second row from each matrix is performed. Then the resulting packed data registers are scattered back to memory. While for small matrices this scenario may be acceptable, it is often not acceptable with larger matrices.
Described herein are mechanisms to support matrix operations in computer hardware such as central processing units (CPUs), graphic processing units (GPUs), and accelerators. The matrix operations utilize 2-dimensional (2-D) data structures representing one or more packed regions of memory such as registers. Throughout this description, these 2-D data structures are referred to as tiles. Note that a matrix may be smaller than a tile (use less than all of a tile) or utilize a plurality of tiles (the matrix is larger than the size of any one tile). Throughout the description, matrix (tile) language is used to indicate operations performed using tiles that impact a matrix; whether or not that matrix is larger than any one tile is not typically relevant.
Each tile may be acted upon by different operations such as those that are detailed herein and include, but are not limited to: matrix (tile) multiplication, tile add, tile subtract, tile diagonal, tile zero, tile transform, tile dot product, tile broadcast, tile row broadcast, tile column broadcast, tile multiplication, tile multiplication and accumulation, tile move, etc. Additionally, support for operators such as the use of a scale and/or bias may be used with these operations or in support of non-numeric applications in the future, for instance, OpenCL “local memory,” data compression/decompression, etc. Also described herein are instructions for performing matrix operation (e.g., TILEPARTIALDOTPRODUCT) instructions.
Portions of storage (such as memory (non-volatile and volatile), registers, cache, etc.) are arranged into tiles of different horizontal and vertical dimensions. For example, a tile may have horizontal dimension of 4 (e.g., four rows of a matrix) and a vertical dimension of 8 (e.g., 8 columns of the matrix). Typically, the horizontal dimension is related to element sizes (e.g., 2-, 4-, 8-, 16-, 32-, 64-, 128-bit, etc.). Multiple datatypes (single precision floating point, double precision floating point, integer, etc.) may be supported.
In some examples, tile parameters can be configured. For example, a given tile may be configured to provide tile options. Exemplary tile options include but are not limited to: a number of rows of the tile, a number of columns of the tile, whether the tile is VALID, and whether the tile consists of a PAIR of equal-sized tiles.
In some examples, tile parameters are definable. For example, a “palette” is used to provide tile options. Exemplary options include, but are not limited to: the number of tile names, the number of bytes in a row of storage, the number of rows and columns in a tile, etc. For example, a maximum “height” (number of rows) of a tile may be defined as:
Tile Max Rows=Architected Storage/(The Number of Palette Names*The Number of Bytes per row).
As such, an application can be written such that a fixed usage of names will be able to take advantage of different storage sizes across implementations.
Configuration of tiles is done using a tile configuration (“TILECONFIG”) instruction, where a particular tile usage is defined in a selected palette. This declaration includes the number of tile names to be used, the requested number of rows and columns per name (tile), and, in some examples, the requested datatype of each tile. In some examples, consistency checks are performed during the execution of a TILECONFIG instruction to determine that it matches the restrictions of the palette entry.
Tile loads from memory and stores to memory are typically strided accesses from the application memory to packed rows of data. Exemplary TILELOAD and TILESTORE instructions, or other instruction references to application memory as a TILE operand in load-op instructions, are, in some examples, restartable to handle (up to) 2*rows of page faults, unmasked floating point exceptions, and/or interrupts per instruction.
In (B), a matrix is stored in a tile comprised of a plurality of registers such as packed data registers (single instruction, multiple data (SIMD) or vector registers). In this example, the tile is overlaid on three physical registers. Typically, consecutive registers are used, however, this need not be the case.
In (C), a matrix is stored in a tile in non-register storage accessible to a fused multiply accumulate (FMA) circuit used in tile operations. This storage may be inside of a FMA, or adjacent to it. Additionally, in some examples, discussed below, the storage may be for a data element and not an entire row or tile.
The supported parameters for the TMMA architecture are reported via CPUID. In some examples, the list of information includes a maximum height and a maximum SIMD dimension. Configuring the TMMA architecture requires specifying the dimensions for each tile, the element size for each tile and the palette identifier. This configuration is done by executing the TILECONFIG instruction.
Successful execution of a TILECONFIG instruction enables subsequent TILE operators. A TILERELEASEALL instruction clears the tile configuration and disables the TILE operations (until the next TILECONFIG instructions executes). In some examples, XSAVE, XSTORE, etc. are used in context switching using tiles. In some examples, 2 XCR0 bits are used in XSAVE, one for TILECONFIG metadata and one bit corresponding to actual tile payload data.
TILECONFIG not only configures the tile usage, but also sets a state variable indicating that the program is in a region of code with tiles configured. An implementation may enumerate restrictions on other instructions that can be used with a tile region such as no usage of an existing register set, etc.
Exiting a tile region is typically done with the TILERELEASEALL instruction. It takes no parameters and swiftly invalidates all tiles (indicating that the data no longer needs any saving or restoring) and clears the internal state corresponding to being in a tile region.
In some examples, tile operations will zero any rows and any columns beyond the dimensions specified by the tile configuration. For example, tile operations will zero the data beyond the configured number of columns (factoring in the size of the elements) as each row is written. For example, with 64-byte rows and a tile configured with 10 rows and 12 columns, an operation writing FP32 elements would write each of the first 10 rows with 12*4 bytes with output/result data and zero the remaining 4*4 bytes in each row. Tile operations also fully zero any rows after the first 10 configured rows. When using 1K tile with 64-byte rows, there would be 16 rows, so in this example, the last 6 rows would also be zeroed.
In some examples, a context restore instruction (e.g., XRSTOR), when loading data, enforces that the data beyond the configured rows for a tile will be maintained as zero. If there is no valid configuration, all rows are zeroed. XRSTOR of tile data can load garbage in the columns beyond those configured. It should not be possible for XRSTOR to clear beyond the number of columns configured because there is not an element width associated with the tile configuration.
Context save (e.g., XSAVE) exposes the entire TILE storage area when writing it to memory. If XRSTOR loaded garbage data into the rightmost part of a tile, that data will be saved by XSAVE. XSAVE will write zeros for rows beyond the number specified for each tile.
In some examples, tile instructions are restartable. The operations that access memory allow restart after page faults. The computational instructions that deal with floating point operations also allow for unmasked floating-point exceptions, with the masking of the exceptions controlled by a control and/or status register.
To support restarting instructions after these events, the instructions store information in the start registers detailed below.
In this example, a coherent memory interface 303 is coupled to the host processor/processing system 301 and matrix operations accelerator 307 such that they can share memory.
In some examples, tiles are supported using an overlay over physical registers. For example, a tile may utilize 16 1,024-bit registers, 32 512-bit registers, etc. depending on the implementation. In some examples, the matrix operations utilize 2-dimensional (2-D) data structures representing one or more packed regions of memory such as registers. Throughout this description, these 2-D data structures are referred to as tiles or tile registers.
In some examples, the matrix operations accelerator 307 includes a plurality of FMAs 309 coupled to data buffers 305 (in some implementations, one or more of these buffers 305 are stored in the FMAs of the grid as shown). The data buffers 305 buffer tiles loaded from memory and/or tiles to be stored to memory (e.g., using a tileload or tilestore instruction). Data buffers may be, for example, a plurality of registers. Typically, these FMAs are arranged as a grid of chained FMAs 309 which are able to read and write tiles. In this example, the matrix operations accelerator 307 is to perform a matrix multiply operation using tiles T0, T1, and T2. At least one of tiles is housed in the FMA grid 309. In some examples, all tiles in an operation are stored in the FMA grid 309. In other examples, only a subset is stored in the FMA grid 309. As shown, T1 is housed and T0 and T2 are not. Note that A, B, and C refer to the matrices of these tiles which may or may not take up the entire space of the tile.
The number of rows in the matrix (TILE A 601) matches the number of serial (chained) FMAs comprising the computation's latency in certain examples. An implementation is free to recirculate on a grid of smaller height, but the computation remains the same.
The source/destination vector comes from a tile of N rows (TILE C 605) and the grid of FMAs 611 performs N vector-matrix operations resulting in a complete instruction performing a matrix multiplication of tiles. Tile B 603 is the other vector source and supplies “broadcast” terms to the FMAs in each stage.
In operation, in some examples, the elements of matrix B (stored in a tile B 603) are spread across the rectangular grid of FMAs. Matrix B (stored in tile A 601) has its elements of a row transformed to match up with the columnar dimension of the rectangular grid of FMAs. At each FMA in the grid, an element of A and B are multiplied and added to the incoming summand (from above in the Figure) and the outgoing sum is passed to the next row of FMAs (or the final output).
The latency of a single step is proportional to K (row height of matrix B) and dependent TMMAs typically have enough source-destination rows (either in a single tile or across tile) to hide that latency. An implementation may also split the SIMD (packed data element) dimension M (row height of matrix A) across time steps, but this simply changes the constant that K is multiplied by. When a program specifies a smaller K than the maximum enumerated by the TMMA, an implementation is free to implement this with “masking” or “early outs.”
The latency of an entire TMMA is proportional to N*K. The repeat rate is proportional to N. The number of MACs per TMMA instruction is N*K*M.
A first signed source (source 1 701) and a second signed source (source 2 703) each have four packed data elements. Each of these packed data elements stores signed data such as floating-point data. A third signed source (source 3 709) has two packed data elements, each of which stores signed data. The sizes of the first and second signed sources 701 and 703 are half that of the third signed source (initial value or previous result) 709. For example, the first and second signed sources 701 and 703 could have 32-bit packed data elements (e.g., single precision floating point) while the third signed source 709 could have 64-bit packed data elements (e.g., double precision floating point).
In this illustration, only the two most significant packed data element positions of the first and second signed sources 701 and 703 and the most significant packed data element position of the third signed source 709 are shown. Of course, the other packed data element positions would also be processed.
As illustrated, packed data elements are processed in pairs. For example, the data of the most significant packed data element positions of the first and second signed sources 701 and 703 are multiplied using a multiplier circuit 705, and the data from second most significant packed data element positions of the first and second signed sources 701 and 703 are multiplied using a multiplier circuit 707. In some examples, these multiplier circuits 705 and 707 are reused for other packed data elements positions. In other examples, additional multiplier circuits are used so that the packed data elements are processed in parallel. In some contexts, parallel execution is done using lanes that are the size of the signed third source 709. The results of each of the multiplications are added using addition circuitry 711.
The result of the addition of the results of the multiplications is added to the data from most significant packed data element position of the signed source 3 709 (using a different adder 713 or the same adder 711).
Finally, the result of the second addition is either stored into the signed destination 715 in a packed data element position that corresponds to the packed data element position used from the signed third source 709 or passed on to the next iteration if there is one. In some examples, a writemask is applied to this storage such that if a corresponding writemask (bit) is set, the storage happens, and, if not set, the storage does not happen.
A first signed source (source 1 801) and a second signed source (source 2 803) each have four packed data elements. Each of these packed data elements stores signed data such as integer data. A third signed source (source 3 809) has two packed data elements, each of which stores signed data. The sizes of the first and second signed sources 801 and 803 are half that of the third signed source 809. For example, the first and second signed sources 801 and 803 could have 32-bit packed data elements (e.g., single precision floating point) the third signed source 809 could have 64-bit packed data elements (e.g., double precision floating point).
In this illustration, only the two most significant packed data element positions of the first and second signed sources 801 and 803 and the most significant packed data element position of the third signed source 809 are shown. Of course, the other packed data element positions would also be processed.
As illustrated, packed data elements are processed in pairs. For example, the data of the most significant packed data element positions of the first and second signed sources 801 and 803 are multiplied using a multiplier circuit 805, and the data from second most significant packed data element positions of the first and second signed sources 801 and 803 are multiplied using a multiplier circuit 807. In some examples, these multiplier circuits 805 and 807 are reused for other packed data elements positions. In other examples, additional multiplier circuits are used so that the packed data elements are processed in parallel. In some contexts, parallel execution is done using lanes that are the size of the signed third source (initial value or previous iteration result) 809. The results of each of the multiplications are added to the signed third source 809 using addition/saturation circuitry 813.
Addition/saturation (accumulator) circuitry 813 preserves a sign of an operand when the addition results in a value that is too big. In particular, saturation evaluation occurs on the infinite precision result between the multi-way-add and the write to the destination or next iteration. When the accumulator 813 is floating point and the input terms are integer, the sum of products and the floating-point accumulator input value are turned into infinite precision values (fixed-point numbers of hundreds of bits), the addition of the multiplication results and the third input is performed, and a single rounding to the actual accumulator type is performed.
Unsigned saturation means the output values are limited to a maximum unsigned number for that element width (all 1s). Signed saturation means a value is limited to the be in the range between a minimum negative number and a max positive number for that element width (for bytes for example, the range is from −128 (=−2{circumflex over ( )}7) to 127 (=2{circumflex over ( )}7−1)).
The result of the addition and saturation check is stored into the signed result 815 in a packed data element position that corresponds to the packed data element position used from the signed third source 809 or passed on to the next iteration if there is one. In some examples, a writemask is applied to this storage such that if a corresponding writemask (bit) is set, the storage happens, and, if not set, the storage does not happen.
A first signed source (source 1 901) and a second unsigned source (source 2 903) each have four packed data elements. Each of these packed data elements has data such as floating point or integer data. A third signed source (initial value or result 915) has a packed data element of which stores signed data. The sizes of the first and second sources 901 and 903 are a quarter of the third signed source 915. For example, the first and second sources 901 and 903 could have 16-bit packed data elements (e.g., word) and the third signed source 915 could have 64-bit packed data elements (e.g., double precision floating point or 64-bit integer).
In this illustration, the four most significant packed data element positions of the first and second sources 901 and 903 and the most significant packed data element position of the third signed source 915 are shown. Of course, other packed data element positions would also be processed if there are any.
As illustrated, packed data elements are processed in quadruplets. For example, the data of the most significant packed data element positions of the first and second sources 901 and 903 are multiplied using a multiplier circuit 905, data from second most significant packed data element positions of the first and second sources 901 and 903 are multiplied using a multiplier circuit 907, data from third most significant packed data element positions of the first and second sources 901 and 903 are multiplied using a multiplier circuit 909, and data from the least significant packed data element positions of the first and second sources 901 and 903 are multiplied using a multiplier circuit 911. In some examples, the signed packed data elements of the first source 901 are sign extended and the unsigned packed data elements of the second source 903 are zero extended prior to the multiplications.
In some examples, these multiplier circuits 905-911 are reused for other packed data elements positions. In other examples, additional multiplier circuits are used so that the packed data elements are processed in parallel. In some contexts, parallel execution is done using lanes that are the size of the signed third source 915. The results of each of the multiplications are added using addition circuitry 913.
The result of the addition of the results of the multiplications is added to the data from most significant packed data element position of the signed source 3 915 (using a different adder 917 or the same adder 913).
Finally, the result 919 of the second addition is either stored into the signed destination in a packed data element position that corresponds to the packed data element position used from the signed third source 915 or passed to the next iteration. In some examples, a writemask is applied to this storage such that if a corresponding writemask (bit) is set, the storage happens, and, if not set, the storage does not happen.
A first signed source 1001 and a second unsigned source 1003 each have four packed data elements. Each of these packed data elements stores data such as floating point or integer data. A third signed source 1015 (initial or previous result) has a packed data element of which stores signed data. The sizes of the first and second sources are a quarter of the third signed source 1015 (initial or previous result). For example, the first and second sources could have 16-bit packed data elements (e.g., word) and the third signed source 1015 (initial or previous result) could have 64-bit packed data elements (e.g., double precision floating point or 64-bit integer).
In this illustration, the four most significant packed data element positions of the first signed source 1001 and the second unsigned source 1003 and the most significant packed data element position of the third signed source 1015 are shown. Of course, other packed data element positions would also be processed if there are any.
As illustrated, packed data elements are processed in quadruplets. For example, the data of the most significant packed data element positions of the first signed source 1001 and the second unsigned source 1003 are multiplied using a multiplier circuit 1005, data from second most significant packed data element positions of the first signed source 1001 and the second unsigned source 1003 are multiplied using a multiplier circuit 1007, data from third most significant packed data element positions of the first signed source 1001 and the second unsigned source 1003 are multiplied using a multiplier circuit 1009, and data from the least significant packed data element positions of the first signed source 1001 and the second unsigned source 1003 are multiplied using a multiplier circuit 1011. In some examples, the signed packed data elements of the first signed source 1001 are sign extended and the unsigned packed data elements of the second unsigned source 1003 are zero extended prior to the multiplications.
In some examples, these multiplier circuits 1005-1011 are reused for other packed data elements positions. In other examples, additional multiplier circuits are used so that the packed data elements are processed in parallel. In some contexts, parallel execution is done using lanes that are the size of third signed source 1015 (initial or previous result). The result of the addition of the results of the multiplications is added to the data from most significant packed data element position of third signed source 1015 (initial or previous result) using adder/saturation 1013 circuitry.
Addition/saturation (accumulator) circuitry 1013 preserves a sign of an operand when the addition results in a value that is too big or too small for signed saturation. In particular, saturation evaluation occurs on the infinite precision result between the multi-way-add and the write to the destination. When the accumulator 1013 is floating point and the input terms are integer, the sum of products and the floating-point accumulator input value are turned into infinite precision values (fixed-point numbers of hundreds of bits), the addition of the multiplication results and the third input is performed, and a single rounding to the actual accumulator type is performed.
The result 1019 of the addition and saturation check is stored into the signed destination in a packed data element position that corresponds to the packed data element position used from third signed source 1015 (initial or previous result) or passed to the next iteration. In some examples, a writemask is applied to this storage such that if a corresponding writemask (bit) is set, the storage happens, and, if not set, the storage does not happen.
For an accumulator having 4× input sizes (in other words, the accumulator input value is four times the size of the packed data element sizes of the sources), table 1103 illustrates different configurations. For byte sized sources, the accumulator uses 32-bit integer or single-precision floating-point (SPFP) values that are 32-bit in size. For word sized sources, the accumulator uses 64-bit integer or double-precision floating-point (DPFP) values that are 64-bit in size in some examples.
For an accumulator having 8× input sizes (in other words, the accumulator input value is eight times the size of the packed data element sizes of the sources), table 1105 illustrates a configuration. For byte sized sources, the accumulator uses 64-bit integer.
As hinted at earlier, matrix operations circuitry may be included in a core, or as an external accelerator.
A plurality of cores, core 0 1201, core 1 1203, core 2 1205, and core N 1207 provide non-tile-based instruction support. In some examples, matrix operations circuitry 1251 is provided in a core 1203, and in other examples matrix operations circuitries 1211 and 1213 are accessible on the ring interconnect 1245.
Additionally, one or more memory controllers 1223-1225 are provided to communicate with memory 1233 and 1231 on behalf of the cores and/or matrix operations circuitry.
The branch prediction and decode circuitry 1303 is coupled to allocate/rename 1307 circuitry which is coupled, in some examples, to scheduler circuitry 1309. In some examples, these circuits provide register renaming, register allocation, and/or scheduling functionality by performing one or more of: 1) renaming logical operand values to physical operand values (e.g., a register alias table in some examples), 2) allocating status bits and flags to the decoded instruction, and 3) scheduling the decoded instruction for execution on execution circuitry out of an instruction pool (e.g., using a reservation station in some examples).
The scheduler circuitry 1309 represents any number of different schedulers, including reservations stations, central instruction window, etc. The scheduler circuitry 1309 is coupled to, or includes, physical register file(s) 1315. Each of the physical register file(s) 1315 represents one or more physical register files, different ones of which store one or more different data types, such as scalar integer, scalar floating point, packed integer, packed floating point, vector integer, vector floating point, status (e.g., an instruction pointer that is the address of the next instruction to be executed), tiles, etc. In one example, the physical register file(s) 1315 comprises vector registers circuitry, write mask registers circuitry, and scalar registers circuitry. These register circuits may provide architectural vector registers, vector mask registers, and general-purpose registers. The physical register file(s) 1315 is overlapped by a retirement circuit 1317 to illustrate various ways in which register renaming and out-of-order execution may be implemented (e.g., using a reorder buffer(s) and a retirement register file(s); using a future file(s), a history buffer(s), and a retirement register file(s); using a register maps and a pool of registers; etc.). The retirement circuit 1317 and the physical register file(s) 1315 are coupled to the execution circuitry 1311.
While register renaming is described in the context of out-of-order execution, it should be understood that register renaming may be used in an in-order architecture. While the illustrated example of the processor may also include separate instruction and data cache units and a shared L2 cache unit, alternative examples may have a single internal cache for both instructions and data, such as, for example, a Level 1 (L1) internal cache, or multiple levels of internal cache. In some examples, the system may include a combination of an internal cache and an external cache that is external to the core and/or the processor. Alternatively, all of the cache may be external to the core and/or the processor.
The execution circuitry 1311 is a set of one or more execution circuits, including scalar circuitry 1321, vector/SIMD circuitry 1323, and matrix operations circuitry 1327, as well as memory access circuitry 1325 to access cache 1313. The execution circuits perform various operations (e.g., shifts, addition, subtraction, multiplication) and on various types of data (e.g., scalar floating point, packed integer, packed floating point, vector integer, vector floating point). While some examples may include a number of execution units dedicated to specific functions or sets of functions, other examples may include only one execution unit or multiple execution units that all perform all functions. The scalar circuitry 1321 performs scalar operations, the vector/SIMD circuitry 1323 performs vector/SIMD operations, and matrix operations circuitry 1327 performs matrix (tile) operations detailed herein.
By way of example, the exemplary register renaming, out-of-order issue/execution core architecture may implement a pipeline as follows: 1) an instruction fetch circuit performs fetch and length decoding stages; 2) the branch and decode circuitry 1303 performs a decode stage; 3) the allocate/rename 1307 circuitry performs an allocation stage and renaming stage; 4) the scheduler circuitry 1309 performs a schedule stage; 5) physical register file(s) (coupled to, or included in, the scheduler circuitry 1309 and allocate/rename 1307 circuitry and a memory unit perform a register read/memory read stage; the execution circuitry 1311 performs an execute stage; 6) a memory unit and the physical register file(s) unit(s) perform a write back/memory write stage; 7) various units may be involved in the exception handling stage; and 8) a retirement unit and the physical register file(s) unit(s) perform a commit stage.
The core may support one or more instructions sets (e.g., the x86 instruction set (with some extensions that have been added with newer versions); the MIPS instruction set of MIPS Technologies of Sunnyvale, CA; the ARM instruction set (with optional additional extensions such as NEON) of ARM Holdings of Sunnyvale, CA), including the instruction(s) described herein. In one example, the core 1390 includes logic to support a packed data instruction set extension (e.g., AVX1, AVX2), thereby allowing the operations used by many multimedia applications to be performed using packed data.
It should be understood that the core may support multithreading (executing two or more parallel sets of operations or threads), and may do so in a variety of ways including time sliced multithreading, simultaneous multithreading (where a single physical core provides a logical core for each of the threads that physical core is simultaneously multithreading), or a combination thereof (e.g., time sliced fetching and decoding and simultaneous multithreading thereafter such as in the Intel® Hyperthreading technology).
The branch prediction and decode circuitry 1403 is coupled to allocate/rename 1407 circuitry which is coupled, in some examples, to scheduler circuitry 1409. In some examples, these circuits provide register renaming, register allocation, and/or scheduling functionality by performing one or more of: 1) renaming logical operand values to physical operand values (e.g., a register alias table in some examples), 2) allocating status bits and flags to the decoded instruction, and 3) scheduling the decoded instruction for execution on execution circuitry out of an instruction pool (e.g., using a reservation station in some examples).
The scheduler circuitry 1409 represents any number of different schedulers, including reservations stations, central instruction window, etc. The scheduler unit(s) scheduler circuitry 1409 is coupled to, or includes, physical register file(s) 1415. Each of the physical register file(s) 1415 represents one or more physical register files, different ones of which store one or more different data types, such as scalar integer, scalar floating point, packed integer, packed floating point, vector integer, vector floating point, status (e.g., an instruction pointer that is the address of the next instruction to be executed), tiles, etc. In one example, the physical register file(s) 1415 comprises vector registers circuitry, write mask registers circuitry, and scalar registers circuitry. These register circuits may provide architectural vector registers, vector mask registers, and general-purpose registers. The physical register file(s) 1415 is overlapped by a retirement circuit 1417 to illustrate various ways in which register renaming and out-of-order execution may be implemented (e.g., using a reorder buffer(s) and a retirement register file(s); using a future file(s), a history buffer(s), and a retirement register file(s); using a register maps and a pool of registers; etc.). The retirement circuit 1417 and the physical register file(s) 1415 are coupled to the execution circuitry 1411.
While register renaming is described in the context of out-of-order execution, it should be understood that register renaming may be used in an in-order architecture. While the illustrated example of the processor may also include separate instruction and data cache units and a shared L2 cache unit, alternative examples may have a single internal cache for both instructions and data, such as, for example, a Level 1 (L1) internal cache, or multiple levels of internal cache. In some examples, the system may include a combination of an internal cache and an external cache that is external to the core and/or the processor. Alternatively, all of the cache may be external to the core and/or the processor.
The execution circuitry 1411 a set of one or more execution circuits 1427 and a set of one or more memory access circuits 1425 to access cache 1413. The execution circuits 1427 perform matrix (tile) operations detailed herein.
By way of example, the exemplary register renaming, out-of-order issue/execution core architecture may implement a pipeline as follows: 1) an instruction fetch circuit performs fetch and length decoding stages; 2) the branch and decode circuitry 1403 performs a decode stage; 3) the allocate/rename 1407 circuitry performs an allocation stage and renaming stage; 4) the scheduler circuitry 1409 performs a schedule stage; 5) physical register file(s) (coupled to, or included in, the scheduler circuitry 1409 and allocate/rename 1407 circuitry and a memory unit perform a register read/memory read stage; the execution circuitry 1411 performs an execute stage; 6) a memory unit and the physical register file(s) unit(s) perform a write back/memory write stage; 7) various units may be involved in the exception handling stage; and 8) a retirement unit and the physical register file(s) unit(s) perform a commit stage.
The core may support one or more instructions sets (e.g., the x86 instruction set (with some extensions that have been added with newer versions); the MIPS instruction set of MIPS Technologies of Sunnyvale, CA; the ARM instruction set (with optional additional extensions such as NEON) of ARM Holdings of Sunnyvale, CA), including the instruction(s) described herein. In one example, the core 1490 includes logic to support a packed data instruction set extension (e.g., AVX1, AVX2), thereby allowing the operations used by many multimedia applications to be performed using packed data.
It should be understood that the core may support multithreading (executing two or more parallel sets of operations or threads), and may do so in a variety of ways including time sliced multithreading, simultaneous multithreading (where a single physical core provides a logical core for each of the threads that physical core is simultaneously multithreading), or a combination thereof (e.g., time sliced fetching and decoding and simultaneous multithreading thereafter such as in the Intel® Hyperthreading technology).
Throughout this description, data is expressed using row major data layout. Column major users should translate the terms according to their orientation.
In some examples, row-major semantics are utilized in hardware, and column major data is to swap the operand order with the result being transforms of matrix, but for subsequent column-major reads from memory it is the correct, non-transformed matrix.
For example, if there are two column-major matrices to multiply:
The input matrices would be stored in linear memory (column-major) as:
Reading those matrices as row-major with dimensions 2×3 and 3×2, they would appear as:
Swapping the order and matrix multiplying:
The transform matrix is out and can then be stored in in row-major order:
and used in subsequent column major computations, it is the correct un-transformed matrix:
The exemplary code as shown includes the usage of a tile configuration instruction and is executed to configure tile usage, load tiles, a loop to process the tiles, store tiles to memory, and release tile usage.
As discussed above, tile usage typically needs to be configured prior to use. For example, full usage of all rows and columns may not be needed. Not only does not configuring these rows and columns save power in some examples, but the configuration may be used to determine if an operation will generate an error. For example, a matrix multiplication of the form (N×M)*(L×N) will typically not work if M and L are not the same.
Prior to using matrices using tiles, in some examples, tile support is to be configured. For example, how many rows and columns per tile, tiles that are to be used, etc. are configured. A TILECONFIG instruction is an improvement to a computer itself as it provides for support to configure the computer to use a matrix accelerator (either as a part of a processor core, or as an external device). In particular, an execution of the TILECONFIG instruction causes a configuration to be retrieved from memory and applied to matrix (tile) settings within a matrix accelerator.
Instruction execution resources 1811 of a processor/core 1805 stores aspects of a tile description 1803 into tile configurations 1817. The tile configurations 1817 include palette table 1813 to detail what tiles for a palette are configured (the number of rows and columns in each tile) and a marking that matrix support is in use. In particular, instruction execution resources 1811 are configured to use tiles as specified by the tile configurations 1817. The instruction execution resources 1811 may also include a machine specific register or configuration register to indicate tile usage. Additional values such as in-use and start values are also set. The tile configurations 1817 utilize register(s) 1819 to store tile usage and configuration information.
Byte 1 stores a value to be stored in a “startRow” register 1903 and byte 2 stores a value to be stored in a register, startP 1905. To support restarting instructions after these events, the instructions store information these registers. To support restarting instructions after break events such as those detailed above, the instructions store information in these registers. The startRow value indicates the row that should be used for restart. The startP value indicates the position within the row for store operations when pairs are used and, in some examples, indicates the lower half of the row (in the lower tile of a pair) or higher half of the row (in the higher tile of a pair). Generally, the position in the row (the column) is not needed.
With the exception of TILECONFIG and STTILECFG, successfully executing matrix (tile) instructions will set both startRow and startP to zero.
Any time an interrupted matrix (tile) instruction is not restarted, it is the responsibility of software to zero the startRow and startP values. For example, unmasked floating point exception handlers might decide to finish the operation in software and change the program counter value to another instruction, usually the next instruction. In this case the software exception handler must zero the startRow and startP values in the exception presented to it by the operating system before resuming the program. The operating system will subsequently reload those values using a restore instruction.
Byte 3 stores an indication of pairs (1b per tile) of tiles 1907.
Bytes 16-17 store the number of rows 1913 and columns 1915 for tile 0, bytes 18-19 store the number of rows and columns for tile 1, etc. In other words, each 2-byte group specifies a number of rows and columns for a tile. If a group of 2 bytes is not used to specify tile parameters, they should have the value zero. Specifying tile parameters for more tiles than the implementation limit or the palette limit results in a fault. Unconfigured tiles are set to an initial state with 0 rows, 0 columns.
Finally, the configuration in memory typically ends with an ending delineation such as all zeros for several consecutive bytes.
Other combinations are contemplated such as combining the start registers into a single register where they are shown separately, etc.
In certain examples, it is desirable for high-end high performance computing (HPC) systems to move beyond exascale (e.g., where exascale refers to a computer that performs at least 10{circumflex over ( )}18 floating-point operations per second), e.g., using 5-10 exa(quintillion) floating point operations (“flops”) for certain double-precision matrix multiplications (e.g., to meet a HPLinpack benchmark).
To achieve these performance targets, substantial improvements in performance-per-Watt are required over existing architectures. Certain architectures (e.g., central processing unit (CPU), graphics processing unit (GPU), field programmable gate array (FPGA), custom processor, artificial intelligence (AI) specific accelerators, etc.) use hardware matrix operation (e.g., multiplication) accelerators in the form of systolic arrays to enhance low-precision AI performance. In certain examples, the systolic array is a two-dimensional grid of processing elements to perform processing operations, e.g., on input matrices.
The operations may be performed on numerical data having different formats (e.g., representations) in a computing system (e.g., accelerator and/or processor). In certain examples, a number is in fixed-point format or a floating-point format. An integer may be represented in a binary format. A signed integer may be represented in a two's (2's) complement format (e.g., where the leading bit being zero indicates a positive integer and a leading bit being one indicates a negative integer), e.g., but the leading bit is part of the number. A signed integer may be represented in a signed magnitude format that is divided into two parts of the (i) sign bit and (ii) magnitude, e.g., where the sign bit is 1 for a negative number and 0 for a positive number, and the magnitude of the number is represented with the binary form of the number. For example, where in signed magnitude a 0 has two different representations: the first is +0 (e.g., +0 being 0:0000000) and the second is −0 (e.g., −0 being 1:0000000) and in 2's complement a 0 has only one representation for −0 and +0 (+0 or −0 both being 00000000). A (e.g., real) number may be represented in floating-point format, e.g., to represent, with a fixed number of digits, numbers of different orders of magnitude.
One example of a numerical format is where a number is generally approximated to a fixed number of significant digits (the significand) and scaled using an exponent in some fixed base (e.g., a base of two, ten, or sixteen). An example of a floating-point format is as follows:
An example of a floating-point format (where S represents a sign bit, M a mantissa, and E an exponent) is as follows:
In accordance with the IEEE 754 standard for binary floating-point (FP) arithmetic, the mantissa is an unsigned number (e.g., a binary fraction) and a normalized floating-point number has a single one in the most-significant-bit (MSB) position. In certain examples, this bit (e.g., to the left of the decimal point) is implicit and therefore the mantissa does not need to store it. In certain examples, the exponent is represented here as a non-negative integer from which a constant bias is subtracted. Examples of floating-point formats are floating point 16 (e.g., binary16), floating point 32 (e.g., binary32), floating point 64 (e.g., binary64), floating point 128 (e.g., binary128), and floating point 256 (e.g., binary256), although any number of sign, significand (e.g., mantissa thereof), or exponent bits may be used in certain examples. In one example, binary16 format has one bit for the sign bit, 5 bits for the exponent, and 11 bits implicit (10 explicitly stored) for the significand. In one example, binary32 format has one bit for the sign bit, 8 bits for the exponent, and 24 bits implicit (23 explicitly stored) for the significand. In one example, binary64 format has one bit for the sign bit, 11 bits for the exponent, and 53 bits implicit (52 explicitly stored) for the significand. In one example, binary 128 format has one bit for the sign bit, 15 bits for the exponent, and 113 bits implicit (112 bits explicitly stored) for the significand. In one example, binary256 format has one bit for the sign bit, 19 bits for the exponent, and 237 bits implicit (236 bits explicitly stored) for the significand.
In certain examples, the systolic array is a two-dimensional grid of fixed-point (e.g., integer only) processing elements. In certain examples, a two-dimensional grid of floating-point (e.g., floating-point only) processing elements utilize more power and takes more time to perform an operation compares to a two-dimensional grid of fixed-point (e.g., integer only) processing elements. In certain examples, it is desirable to not utilize and/or not include a floating-point systolic array (e.g., floating-point only) within a computing system (e.g., processor). In certain examples, it is desirable to not utilize and/or not include a two-dimensional grid of floating-point (e.g., floating-point only) processing elements within a computing system (e.g., processor). In certain examples, it is desirable to not utilize vector execution circuitry to perform floating-point matrix operations (e.g., vector execution circuitry to implement chained multiply accumulate operations (e.g., QMADD, OMADD)), e.g., to instead utilize a (e.g., faster and/or more power efficient) two-dimensional grid of fixed-point (e.g., integer only) processing elements to perform floating-point operations. In certain examples, a QMADD operation (e.g., instruction) is to use vector execution circuitry to perform a matrix multiplication of two 2×2 input matrices and accumulate the results with a third 2×2 matrix, and an OMADD operation (e.g., instruction) is to use vector execution circuitry to perform a matrix multiplication of two 4×4 input matrices and accumulate the results with a third 4×4 matrix.
Examples herein overcome these issues by introducing circuitry (e.g., floating-point support circuitry) to support operations on floating-point values by a two-dimensional grid of fixed-point (e.g., integer only) processing elements, e.g., such that values are still input into the two-dimensional grid of fixed-point (e.g., integer only) processing elements as fixed-point values but the floating-point support circuitry enables floating-point inputs and floating-point outputs to be generated by a hardware matrix operation (e.g., multiplication) accelerator via its two-dimensional grid of fixed-point (e.g., integer only) processing elements. Examples herein enable the emulation of floating-point types (e.g., single and/or double precision) using the fixed-point (e.g., integer) arithmetic support provided by a systolic array. In certain examples, this approach requires minimal modifications to existing systolic arrays, e.g., allowing the systolic array to function on both integer values and floating-point values (e.g., via the floating-point support circuitry).
Examples herein improve the functioning of a computer (e.g., processor) by allowing floating-point values to be processed by a two-dimensional grid of fixed-point (e.g., integer only) processing elements, e.g., by including floating-point support circuitry as discussed herein. As discussed herein, the floating-point support circuitry allows for a computer (e.g., processor) to support floating-point matrix operations (e.g., arithmetic) with its two-dimensional grid of fixed-point (e.g., fixed-point only) processing elements without utilizing (and/or not even including) a floating-point systolic array (e.g., floating-point only) within the computer (e.g., processor). As discussed herein, the floating-point support circuitry allows for a computer (e.g., processor) to support floating-point matrix operations (e.g., arithmetic) with its two-dimensional grid of fixed-point (e.g., fixed-point only) processing elements without utilizing (and/or not even including) a two-dimensional grid of floating-point (e.g., floating-point only) processing elements within a computer (e.g., processor). As discussed herein, the floating-point support circuitry also allows for minimal modifications to an (e.g., existing) fixed-point systolic array where it is desired to add floating-point functionality.
In certain examples, a processor (e.g., core) supports one or more instructions that are to cause floating-point support circuitry to enable support of floating-point matrix operations (e.g., arithmetic) with a two-dimensional grid of fixed-point (e.g., fixed-point only) processing elements. Those instructions disclosed herein are improvements to the functioning of a processor (e.g., of a computer) itself. Instruction decoder circuitry (e.g., a decoder) not having such an instruction as a part of its instruction set would not decode as discussed herein. An execution circuit not having such an instruction as a part of its instruction set would not execute as discussed herein. For example, a processor that, is to (i) decode, by a decoder circuit of a hardware processor comprising a matrix operations accelerator circuit including a two-dimensional grid of fixed-point processing elements, floating-point support circuitry coupled to the two-dimensional grid of fixed-point processing elements, and storage for a first, a second, and a destination two-dimensional floating-point matrices coupled to the floating-point support circuitry, the single “floating-point matrix operations” instruction into a decoded single instruction, the single “floating-point matrix operations” instruction including a first field that identifies the first two-dimensional floating-point matrix, a second field that identifies the second two-dimensional floating-point matrix, and an opcode that indicates an execution circuit of the hardware processor is to cause the matrix operations accelerator circuit to: determine, by the floating-point support circuitry, an extreme exponent for each row of the first two-dimensional floating-point matrix and for each column of the second two-dimensional floating-point matrix, generate, by the floating-point support circuitry, a first fixed-point matrix from the first two-dimensional floating-point matrix and a second fixed-point matrix from the second two-dimensional floating-point matrix, generate, by the two-dimensional grid of fixed-point processing elements, corresponding fixed-point results by a multiplication of fixed-point elements of the first fixed-point matrix by corresponding fixed-point elements of the second fixed-point matrix, scale, by the floating-point support circuitry, the corresponding fixed-point results according to the extreme exponents to generate scaled fixed-point results, generate, by the floating-point support circuitry, a resultant floating-point matrix from the scaled fixed-point results, and store the resultant floating-point matrix into the destination two-dimensional floating-point matrix, and (ii) execute, by the execution circuit of the hardware processor, the decoded single instruction according to the opcode. Certain examples herein allow for multiple precision (e.g., floating-point) matrix multiplication. Certain examples herein allow a matrix operations accelerator circuit including a two-dimensional grid of fixed-point processing elements to process (i) fixed point (e.g., integer) input values when in a first mode and (ii) floating-point input values when in a second mode, see, e.g., the discussion of
In certain examples, matrix multiplication can be thought of as a set of dot product calculations (with much data reuse between dot products). One key idea of examples herein is for a processor to include floating-point support circuitry that enables support of floating-point matrix operations (e.g., arithmetic) with a two-dimensional grid of fixed-point (e.g., fixed-point only) processing elements. In certain examples, the floating-point support circuitry determines the binary “point” of each dot product by examining the input matrices, e.g., once a fixed-point is chosen, the floating-point support circuitry then translates all floating-point input values into fixed-point (e.g., as they stream into the systolic array). To deal with the lower precision (e.g., fixed precision) of certain systolic arrays (e.g., two-dimensional grid of fixed-point (e.g., fixed-point only) processing elements), certain examples herein include floating-point support circuitry that breaks input elements into chunk sized (e.g., word-sized) pieces, and thus (e.g., narrow) chunk sized (e.g., word) multiplications are then used to complete a wider element (e.g., word) multiplication. In certain examples, all multiplication and accumulation in the systolic array are performed in fixed-point, and the results are converted back into floating-point at the end of the matrix multiplication.
Such floating-point support circuitry and two-dimensional grid of fixed-point (e.g., fixed-point only) processing elements cannot practically be performed in the human mind (or with pen and paper). Such floating-point support circuitry is an improvement in the functioning of a computer as discussed herein. An example improvement realized by the floating-point support circuitry is improved matrix multiplication performance and performance per Watt of power consumed, e.g., from 3-8 times better than without using the floating-point support circuitry. Another example improvement realized by the floating-point support circuitry is the ability to add floating-point support to an (e.g., existing) systolic array, e.g., as a component in processor architectures. An example improvement realized by the floating-point support circuitry is because it uses fixed-point, more performance is unlocked where arrays have more integer multiplication support than floating-point multiplication support. Surprisingly, in certain examples, operating in fixed-point also improves the accuracy of the matrix multiplications, which will unlock additional performance gains in some application use cases. Also note that by eliminating the need for floating-point systolic arrays, the fixed-point (e.g., AI) systolic arrays could be made larger in a processor and/or also achieve higher AI performance points.
In this example, a coherent memory interface 2103 is coupled to the host processor/processing system 2101 and matrix operations accelerator 2107 such that they can share memory.
In certain examples, matrix operations circuitry (e.g., matrix operations accelerator 2107 circuitry), and particularly, the two-dimensional grid 2109 of fixed-point processing elements, is augmented by floating-point support circuitry 2117 to logically allow the two-dimensional grid 2109 of fixed-point processing elements to perform floating-point (e.g., arithmetic) operations (e.g., floating-point matrix multiplication), for example, in contrast to using a grid of floating-point processing elements to perform floating-point (e.g., arithmetic) operations.
In certain examples, the floating-point support circuitry 2117 is included to perform a conversion, in hardware, of floating-point values into fixed-point values, breaking wide fixed-point values (e.g., words) into the narrow chunks (e.g., sub-words) supported by the fixed-point systolic array (e.g., grid 2109 of fixed-point processing elements), conducting a set of low-precision matrix multiplications, combining the results of these matrix multiplications, and then converting the inner product result back in to floating-point format. In certain examples, architecturally, the usage of the fixed-point systolic array (e.g., grid 2109 of fixed-point processing elements) is unchanged from its usage and interface for low precision types, e.g., programmers will still provide floating-point matrices as inputs and larger matrix operations will be composed of smaller matrix operations. In certain examples, the hardware modifications (e.g., floating-point support circuitry 2117) to enable the approach are constrained to the perimeter of the array, rather than the array internals. Certain examples herein use floating-point support circuitry 2117 to naturally support a wide range of types including single, double, and single-time-double matrix multiplications.
This observation leads to a way of re-framing floating-point multiplication as fixed-point multiplication. In certain examples of floating-point multiplication, shifting and rounding would happen at each multiplication, based on the arguments to that particular multiplication. However, the extreme exponents provide a way of estimating the exponent of the final inner product result, allowing each input term of the inner product to be scaled to the estimated final exponent prior to any multiplication. This permits all multiplications and additions during the inner product calculation to occur in fixed-point using the extreme exponent as a basis. In certain examples, at the end of the fixed-point inner product calculation, scaling is inverted, and then the result is converted back into floating-point format. In certain examples, scaling and scaling inversion terms (S) are always powers of two. In certain examples, “extreme” exponent (e.g., maximum exponent from that set of values) scaling occurs per row of the ‘A’ input matrix and per column of the ‘B’ input matrix, and with the benefit that it happens only once per input matrix, even if that matrix is reused multiple times as a part of a larger matrix multiplication.
In certain examples, long multiplication as described in
Where C′ is a full-width matrix and can be converted back in to floating-point. S is a matrix scaling inversion terms (e.g., scaling matrix 3104 in
In certain examples, floating-point support circuitry 2117 logically allows the two-dimensional grid 2109 of fixed-point processing elements to perform floating-point (e.g., arithmetic) operations (e.g., floating-point matrix multiplication) via the following algorithm:
In certain examples, this algorithm is performed serially. Below discusses a well-parallelized implementation, e.g., in which 1-6 execute in a pipeline-parallel fashion, for example, where such an arrangement results in little additionally latency relative to the baseline functionality of the systolic array.
To illustrate the operation of the low precision multiplication algorithm, the below describes one example using the values from
In certain examples, if a user requests a smaller precision, the matrix operations accelerator can simply skip some of the latter steps of the “long” multiplication. For example, there is a long-form and a short-form, e.g., where if you have X chunks of A and B, the long form is always X{circumflex over ( )}2 multiply operations and the short form is X*(X+1)/2 pieces, which can be over half the size and complexity. There are certain problems that may only require the “short” form, and this can save additional power. In certain examples, the matrix operations accelerator is able to pick and choose between the long and short forms (and do both). In certain examples, for the short form, the matrix operations accelerator is to, instead of adding up all the Cx terms that go to C_{X*X}, it stops at C_{X+1}. E.g., the matrix operations accelerator computes C_{X+1}=A1*BX+A2*B_{X−1}+ . . . +AX*B1, and does not go any further (e.g., it stops at X*(X+1)/2 multiplications total). In certain examples, a matrix operations accelerator is able to stop the algorithm early, e.g., the hardware determines (e.g., based on a desired level of precision) no further sums are needed, stop here, and skip to step 6.
For example, taking value A[1] of 63, this is binary 1.11111000000000000000000 with an exponent of 2{circumflex over ( )}5, so to shift that exponent by the extreme exponent of A (which is 2{circumflex over ( )}−5 in this example) results in a zero shift, and thus a shifted binary fixed-point value of A[1] of 1.11111000000000000000000 (e.g., as a shift of 0 bits because the −5 and 5 exponents sum to zero). For example, taking value A[2] of 1.000244141, this is binary 1.00000000000100000000000 with an exponent of 2{circumflex over ( )}0, so to shift that exponent by the extreme exponent of A (which is 2{circumflex over ( )}−5 in this example) results in a shifted binary fixed-point value of A[2] of 0.00001000000000001000000 (e.g., as a right shift of 5 bits because the −5 and 0 exponents sum to −5). For example, taking value B[1] of 4, this is binary 1.00000000000000000000000 with an exponent of 2{circumflex over ( )}2, so to shift that exponent by the extreme exponent of B (which is 2{circumflex over ( )}−4 in this example) results in a shifted binary fixed-point value of B[1] of 0.01000000000000000000000 (e.g., as a right shift of 2 bits because the −4 and 2 exponents sum to −2).
Further,
Said another way, shifted A[0]=A′1[0]+(2{circumflex over ( )}−9)*A′2[0]+(2{circumflex over ( )}−18)*A′3[0], where 0 is the element index of an element of a matrix (e.g., element index in a row or element index in a column, and the number after the ‘ is the “chunk index” into a single element, shown here as chunk indices 1-3).
In certain examples, the chunk values are 9-bit precision (corresponds to 10-bit signed multiplication). Fixed-point representation is used to aid in understanding. In certain examples, actual fixed-point multiplication support is not required.
Using the examples from
In certain examples, the final step in low-precision (e.g., chunked fixed-point) multiplication is to scale and combine the C′n terms to form the final multiplication result. In certain examples, this involves scaling each term of the C′n matrices by an appropriate Sn matrix term and then summing up the individual terms of the C′n matrices to obtain a final C matrix term. This term can then be translated into a full-precision floating-point term directly. As shown in the scaling term for C′1, it includes 2{circumflex over ( )}5 (to remove the scaling from the extreme exponent of row A of 2{circumflex over ( )}−5), includes 2{circumflex over ( )}4 (to remove the scaling from the extreme exponent of column B of 2{circumflex over ( )}−4), and a chunk offset (e.g., scaling) of 2{circumflex over ( )}0 because both chunk A′1 and chunk B′1 from A′1*B′1 are not offset chunks. As shown in the scaling term for C′2, it includes 2{circumflex over ( )}5 (to remove the scaling from the extreme exponent of row A of 2{circumflex over ( )}−5), includes 2{circumflex over ( )}4 (to remove the scaling from the extreme exponent of column B of 2{circumflex over ( )}−4), and a chunk offset (e.g., scaling) of 2{circumflex over ( )}−9 because while chunk B′1 from A′2*B′1 is not an offset chunk, chunk A′2 from A′2*B′1 is an offset chunk (it is chunk position “2”, so the chunk offset is −9).
In
The below describes further details of hardware (e.g., floating-point support circuitry) to implement such a fixed-point approach.
Depicted matrix operations accelerator 2107 includes a matrix accelerator controller circuitry 2113, e.g., to control the operations according to the algorithm disclosed herein. In certain examples, matrix accelerator controller circuitry 2113 includes dispatch circuitry 2115, e.g., to control the sending of data (e.g., one or more values from an input matrix) from data buffers 2105 (e.g., registers forming a tile) to the grid of fixed-point processing elements 2109. In certain examples, a request to perform one or more processing operations on input matrix A 2105A and input matrix B 2105B is generated, e.g., by host processor/processing system 2101 in
In certain examples, the input values are stored in (e.g., streamed into) storage 2105A for matrix A and/or storage 2105B for matrix B in floating-point format and then converted by floating-point support circuitry 2117 (e.g., floating-point support circuitry 2117-1 for matrix A and floating-point support circuitry 2117-2 for matrix B) as the input values are input (e.g., streamed) into the two-dimensional grid 2109 of fixed-point processing elements (e.g., with the fixed-point input values of A stored in matrix A storage 3205A and the fixed-point input values of B stored into matrix B storage 3205B in
In certain examples, floating-point support circuitry 2117-3 is to perform an intermediate accumulation of values, e.g., to generate the values of C′n (e.g., as shown in
In certain examples, the final fixed-point C′n values (e.g., as shown in
In certain examples, the final floating-point C values are accumulated in matrix C 2105C (e.g., with previous floating-point values of an initial matrix C) to generate an updated resultant floating-point matrix C).
In certain examples, the final floating-point C values are sent by store circuitry 3106 from (e.g., storage 2105C of matrix C within) matrix operations accelerator 2107 to system memory (e.g., via coherent memory interface 2103 in
In certain examples, while the stores for the A, B, and C matrices are shown as independent, this storage can be unified.
In certain examples, the floating-point support circuitry 2117 (e.g., as discrete components as shown or as a single unitary component in other examples) is included to implement the six steps of the fixed-point matrix multiplication algorithm. In certain examples, step 1 of the algorithm is to determine the extreme exponents for the input matrices, e.g., where this occurs as the matrices are streamed into the array-local storage (2105A, 2105B), with the extreme exponents being stored as additional data (e.g., metadata) along with the matrices (e.g. into extreme exponent storage 2105A-EX and 2105B-EX. In certain examples, step 2 scales matrix values according to the extreme exponents and converts the floating-point values to fixed-point as they are streamed from array-local storage into the array 2109 itself. In certain examples, step 3 forms narrow width (e.g., chunked) matrices, e.g., concurrently with step 2 as values are streamed into the array 2109. In certain examples, at step 4, the matrix multiplication for fixed-point values is unchanged and requires no additional hardware relative to a (e.g., baseline) systolic array. In certain examples, step 5 modifies the array inner product results by inverting part of the extreme exponent scaling and accumulates a partial C′ result. In certain examples, step 6 inverts the remaining extreme exponent scaling converts a C′ back into floating-point matrix C.
In certain examples, all steps are pipelined and so incur little latency penalty and no throughput penalty relative to a baseline systolic array. Additionally, in certain examples, while there are many views of the A, B, and C matrices that are used during low-precision computation in practice only one view of data is materialized at a time and so existing storage structures can be largely reused without additional sizing.
In certain examples, extreme exponents are stored along with the array data for use during Step 2 and Step 4.
In certain examples, the next steps in the method are to convert floating-point values in to appropriately scaled narrow-width (e.g., chunk width as shown in the rightmost three columns of
In certain examples, no modifications or additional floating-point support circuitry is utilized for this step, although the bit widths of the integer multiplications in the array may be optimized (larger or smaller) for certain target markets. In certain examples, this bit width is decoupled from the floating-point type.
In certain examples, intermediate partial sum accumulation hardware (e.g., floating-point support circuitry 2117-3) is included.
In certain examples, during Step 6, the fixed-point result calculated in the systolic array is scaled, converted back in to floating-point, and potentially accumulated into a previously computed floating-point partial sum. In certain examples, this step occurs once all matrix multiplications are complete, as data is streamed from the hardware of Step 5 after the final fixed-point accumulation in that step.
In certain examples, internal array operations happen in fixed-point. Thus, in certain examples, a final conversion step back to floating-point is performed before accumulation into a full-precision result matrix. In certain examples, this step inverts the scaling by extreme exponent values done as input values were streamed into the matrix. In certain examples, these scaling inversion factors are referred to as a scaling matrix (S matrix), e.g., scaling matrix 3104 in
In some examples, extreme exponents may also be determined for result matrices as those result matrices are being calculated.
In certain examples, (e.g., where the processor/core supports out-of-order (OoO) execution), the processor includes a register rename/allocator circuit 3910 coupled to register file/memory circuit 3912 (e.g., unit) to allocate resources and perform register renaming on registers (e.g., registers associated with the initial sources and final destination of the instruction). In certain examples, (e.g., for out-of-order execution), the processor includes one or more scheduler circuits 3910 coupled to the decoder circuit 3908. The scheduler circuit(s) may schedule one or more operations associated with decoded instructions, including one or more operations decoded from “matrix floating-point (FP) operation instructions” instructions 3904, e.g., for execution on the execution circuit 3914.
As one example, “matrix floating-point (FP) operation” instruction 3904 is to cause decoding, by decoder circuit 3908 of a hardware processor comprising a matrix operations accelerator circuit 2107 including a two-dimensional grid of fixed-point processing elements 2109, floating-point support circuitry 2117 coupled to the two-dimensional grid of fixed-point processing elements, and storage 2105 for a first, a second, and a destination two-dimensional floating-point matrices coupled to the floating-point support circuitry, a single instruction into a decoded single instruction, the single instruction including a first field that identifies the first two-dimensional floating-point matrix, a second field that identifies the second two-dimensional floating-point matrix, and an opcode that indicates an execution circuit of the hardware processor is to cause the matrix operations accelerator circuit to: determine, by the floating-point support circuitry, an extreme exponent for each row of the first two-dimensional floating-point matrix and for each column of the second two-dimensional floating-point matrix, generate, by the floating-point support circuitry, a first fixed-point matrix from the first two-dimensional floating-point matrix and a second fixed-point matrix from the second two-dimensional floating-point matrix, generate, by the two-dimensional grid of fixed-point processing elements, corresponding fixed-point results by a multiplication of fixed-point elements of the first fixed-point matrix by corresponding fixed-point elements of the second fixed-point matrix, scale, by the floating-point support circuitry, the corresponding fixed-point results according to the extreme exponents to generate scaled fixed-point results, generate, by the floating-point support circuitry, a resultant floating-point matrix from the scaled fixed-point results, and store the resultant floating-point matrix into the destination two-dimensional floating-point matrix, and executing, by the execution circuit 3914 of the hardware processor, the decoded single instruction according to the opcode.
In certain examples, a write back circuit 3916 is included to write back results of an instruction to a destination (e.g., write them to a tile of data buffers 2105), for example, so those results are visible within a processor (e.g., visible outside of the execution circuit that produced those results).
One or more of these components (e.g., decoder 3908, register rename/register allocator/scheduler 3910, execution circuit 3914, registers (e.g., register file)/memory 3912, or write back circuit 3916) may be in a single core of a hardware processor (e.g., and multiple cores each with an instance of these components).
A processor (e.g., or processor core) may perform method 4000, e.g., in response to receiving a request to execute an instruction from software. Depicted method 4000 includes processing a “matrix floating-point (FP) operation” instruction by: fetch an instruction at 4002, decode, by a decoder circuit of a hardware processor comprising a matrix operations accelerator circuit including a two-dimensional grid of fixed-point processing elements, floating-point support circuitry coupled to the two-dimensional grid of fixed-point processing elements, and storage for a first, a second, and a destination two-dimensional floating-point matrices coupled to the floating-point support circuitry, a single instruction into a decoded single instruction, the single instruction including a first field that identifies the first two-dimensional floating-point matrix, a second field that identifies the second two-dimensional floating-point matrix, and an opcode that indicates an execution circuit of the hardware processor is to cause the matrix operations accelerator circuit to: determine, by the floating-point support circuitry, an extreme exponent for each row of the first two-dimensional floating-point matrix and for each column of the second two-dimensional floating-point matrix, generate, by the floating-point support circuitry, a first fixed-point matrix from the first two-dimensional floating-point matrix and a second fixed-point matrix from the second two-dimensional floating-point matrix, generate, by the two-dimensional grid of fixed-point processing elements, corresponding fixed-point results by a multiplication of fixed-point elements of the first fixed-point matrix by corresponding fixed-point elements of the second fixed-point matrix, scale, by the floating-point support circuitry, the corresponding fixed-point results according to the extreme exponents to generate scaled fixed-point results, generate, by the floating-point support circuitry, a resultant floating-point matrix from the scaled fixed-point results, and store the resultant floating-point matrix into the destination two-dimensional floating-point matrix at 4004, (optionally) retrieve data associated with the instruction at 4006, (optionally) schedule the decoded instruction for execution at 4008, execute the decoded instruction according to the opcode at 4010, and commit a result of the executed instruction at 4012.
In one example, the format of an instruction includes a field to identify matrix A, matrix B, and matrix C. e.g., as discussed herein. In certain examples, the opcode of the instruction is to cause the floating-point support circuitry 2117 to function as discussed herein.
As shown, instruction 4101 includes an opcode 4102 (e.g., MATRIXFPOPERATION), which indicates that the processor is to decode, by decoder circuit of a hardware processor comprising a matrix operations accelerator circuit 2107 including a two-dimensional grid of fixed-point processing elements 2109, floating-point support circuitry 2117 coupled to the two-dimensional grid of fixed-point processing elements, and storage 2105 for a first, a second, and a destination two-dimensional floating-point matrices coupled to the floating-point support circuitry, a single instruction into a decoded single instruction, the single instruction including a first field that identifies the first two-dimensional floating-point matrix, a second field that identifies the second two-dimensional floating-point matrix, and an opcode that indicates an execution circuit of the hardware processor is to cause the matrix operations accelerator circuit to: determine, by the floating-point support circuitry, an extreme exponent for each row of the first two-dimensional floating-point matrix and for each column of the second two-dimensional floating-point matrix, generate, by the floating-point support circuitry, a first fixed-point matrix from the first two-dimensional floating-point matrix and a second fixed-point matrix from the second two-dimensional floating-point matrix, generate, by the two-dimensional grid of fixed-point processing elements, corresponding fixed-point results by a multiplication of fixed-point elements of the first fixed-point matrix by corresponding fixed-point elements of the second fixed-point matrix, scale, by the floating-point support circuitry, the corresponding fixed-point results according to the extreme exponents to generate scaled fixed-point results, generate, by the floating-point support circuitry, a resultant floating-point matrix from the scaled fixed-point results, and store the resultant floating-point matrix into the destination two-dimensional floating-point matrix, and execute, by the execution circuit 3914 of the hardware processor, the decoded single instruction according to the opcode. In
Further exemplary architectures, systems, etc. that the above may be used in are detailed below.
At least some examples of the disclosed technologies can be described in view of the following examples:
Example 1. An apparatus comprising:
In yet another example, an apparatus comprises a data storage device that stores code that when executed by a hardware processor causes the hardware processor to perform any method disclosed herein. An apparatus may be as described in the detailed description. A method may be as described in the detailed description.
Detailed below are descriptions of example computer architectures. Other system designs and configurations known in the arts for laptop, desktop, and handheld personal computers (PC)s, personal digital assistants, engineering workstations, servers, disaggregated servers, network devices, network hubs, switches, routers, embedded processors, digital signal processors (DSPs), graphics devices, video game devices, set-top boxes, micro controllers, cell phones, portable media players, hand-held devices, and various other electronic devices, are also suitable. In general, a variety of systems or electronic devices capable of incorporating a processor and/or other execution logic as disclosed herein are generally suitable.
Processors 4270 and 4280 are shown including integrated memory controller (IMC) circuitry 4272 and 4282, respectively. Processor 4270 also includes interface circuits 4276 and 4278; similarly, second processor 4280 includes interface circuits 4286 and 4288. Processors 4270, 4280 may exchange information via the interface 4250 using interface circuits 4278, 4288. IMCs 4272 and 4282 couple the processors 4270, 4280 to respective memories, namely a memory 4232 and a memory 4234, which may be portions of main memory locally attached to the respective processors.
Processors 4270, 4280 may each exchange information with a network interface (NW I/F) 4290 via individual interfaces 4252, 4254 using interface circuits 4276, 4294, 4286, 4298. The network interface 4290 (e.g., one or more of an interconnect, bus, and/or fabric, and in some examples is a chipset) may optionally exchange information with a coprocessor 4238 via an interface circuit 4292. In some examples, the coprocessor 4238 is a special-purpose processor, such as, for example, a high-throughput processor, a network or communication processor, compression engine, graphics processor, general purpose graphics processing unit (GPGPU), neural-network processing unit (NPU), embedded processor, or the like.
A shared cache (not shown) may be included in either processor 4270, 4280 or outside of both processors, yet connected with the processors via an interface such as P-P interconnect, such that either or both processors' local cache information may be stored in the shared cache if a processor is placed into a low power mode.
Network interface 4290 may be coupled to a first interface 4216 via interface circuit 4296. In some examples, first interface 4216 may be an interface such as a Peripheral Component Interconnect (PCI) interconnect, a PCI Express interconnect or another I/O interconnect. In some examples, first interface 4216 is coupled to a power control unit (PCU) 4217, which may include circuitry, software, and/or firmware to perform power management operations with regard to the processors 4270, 4280 and/or co-processor 4238. PCU 4217 provides control information to a voltage regulator (not shown) to cause the voltage regulator to generate the appropriate regulated voltage. PCU 4217 also provides control information to control the operating voltage generated. In various examples, PCU 4217 may include a variety of power management logic units (circuitry) to perform hardware-based power management. Such power management may be wholly processor controlled (e.g., by various processor hardware, and which may be triggered by workload and/or power, thermal or other processor constraints) and/or the power management may be performed responsive to external sources (such as a platform or power management source or system software).
PCU 4217 is illustrated as being present as logic separate from the processor 4270 and/or processor 4280. In other cases, PCU 4217 may execute on a given one or more of cores (not shown) of processor 4270 or 4280. In some cases, PCU 4217 may be implemented as a microcontroller (dedicated or general-purpose) or other control logic configured to execute its own dedicated power management code, sometimes referred to as P-code. In yet other examples, power management operations to be performed by PCU 4217 may be implemented externally to a processor, such as by way of a separate power management integrated circuit (PMIC) or another component external to the processor. In yet other examples, power management operations to be performed by PCU 4217 may be implemented within BIOS or other system software.
Various I/O devices 4214 may be coupled to first interface 4216, along with a bus bridge 4218 which couples first interface 4216 to a second interface 4220. In some examples, one or more additional processor(s) 4215, such as coprocessors, high throughput many integrated core (MIC) processors, GPGPUs, accelerators (such as graphics accelerators or digital signal processing (DSP) units), field programmable gate arrays (FPGAs), or any other processor, are coupled to first interface 4216. In some examples, second interface 4220 may be a low pin count (LPC) interface. Various devices may be coupled to second interface 4220 including, for example, a keyboard and/or mouse 4222, communication devices 4227 and storage circuitry 4228. Storage circuitry 4228 may be one or more non-transitory machine-readable storage media as described below, such as a disk drive or other mass storage device which may include instructions/code and data 4230 and may implement the storage 4228 in some examples. Further, an audio I/O 4224 may be coupled to second interface 4220. Note that other architectures than the point-to-point architecture described above are possible. For example, instead of the point-to-point architecture, a system such as multiprocessor system 4200 may implement a multi-drop interface or other such architecture.
Processor cores may be implemented in different ways, for different purposes, and in different processors. For instance, implementations of such cores may include: 1) a general purpose in-order core intended for general-purpose computing; 2) a high-performance general purpose out-of-order core intended for general-purpose computing; 3) a special purpose core intended primarily for graphics and/or scientific (throughput) computing. Implementations of different processors may include: 1) a CPU including one or more general purpose in-order cores intended for general-purpose computing and/or one or more general purpose out-of-order cores intended for general-purpose computing; and 2) a coprocessor including one or more special purpose cores intended primarily for graphics and/or scientific (throughput) computing. Such different processors lead to different computer system architectures, which may include: 1) the coprocessor on a separate chip from the CPU; 2) the coprocessor on a separate die in the same package as a CPU; 3) the coprocessor on the same die as a CPU (in which case, such a coprocessor is sometimes referred to as special purpose logic, such as integrated graphics and/or scientific (throughput) logic, or as special purpose cores); and 4) a system on a chip (SoC) that may be included on the same die as the described CPU (sometimes referred to as the application core(s) or application processor(s)), the above described coprocessor, and additional functionality. Example core architectures are described next, followed by descriptions of example processors and computer architectures.
Thus, different implementations of the processor 4300 may include: 1) a CPU with the special purpose logic 4308 being integrated graphics and/or scientific (throughput) logic (which may include one or more cores, not shown), and the cores 4302(A)-(N) being one or more general purpose cores (e.g., general purpose in-order cores, general purpose out-of-order cores, or a combination of the two); 2) a coprocessor with the cores 4302(A)-(N) being a large number of special purpose cores intended primarily for graphics and/or scientific (throughput); and 3) a coprocessor with the cores 4302(A)-(N) being a large number of general purpose in-order cores. Thus, the processor 4300 may be a general-purpose processor, coprocessor, or special-purpose processor, such as, for example, a network or communication processor, compression engine, graphics processor, GPGPU (general purpose graphics processing unit), a high throughput many integrated core (MIC) coprocessor (including 30 or more cores), embedded processor, or the like. The processor may be implemented on one or more chips. The processor 4300 may be a part of and/or may be implemented on one or more substrates using any of a number of process technologies, such as, for example, complementary metal oxide semiconductor (CMOS), bipolar CMOS (BiCMOS), P-type metal oxide semiconductor (PMOS), or N-type metal oxide semiconductor (NMOS).
A memory hierarchy includes one or more levels of cache unit(s) circuitry 4304(A)-(N) within the cores 4302(A)-(N), a set of one or more shared cache unit(s) circuitry 4306, and external memory (not shown) coupled to the set of integrated memory controller unit(s) circuitry 4314. The set of one or more shared cache unit(s) circuitry 4306 may include one or more mid-level caches, such as level 2 (L2), level 3 (L3), level 4 (L4), or other levels of cache, such as a last level cache (LLC), and/or combinations thereof. While in some examples interface network circuitry 4312 (e.g., a ring interconnect) interfaces the special purpose logic 4308 (e.g., integrated graphics logic), the set of shared cache unit(s) circuitry 4306, and the system agent unit circuitry 4310, alternative examples use any number of well-known techniques for interfacing such units. In some examples, coherency is maintained between one or more of the shared cache unit(s) circuitry 4306 and cores 4302(A)-(N). In some examples, interface controller units circuitry 4316 couple the cores 4302 to one or more other devices 4318 such as one or more I/O devices, storage, one or more communication devices (e.g., wireless networking, wired networking, etc.), etc.
In some examples, one or more of the cores 4302(A)-(N) are capable of multi-threading. The system agent unit circuitry 4310 includes those components coordinating and operating cores 4302(A)-(N). The system agent unit circuitry 4310 may include, for example, power control unit (PCU) circuitry and/or display unit circuitry (not shown). The PCU may be or may include logic and components needed for regulating the power state of the cores 4302(A)-(N) and/or the special purpose logic 4308 (e.g., integrated graphics logic). The display unit circuitry is for driving one or more externally connected displays.
The cores 4302(A)-(N) may be homogenous in terms of instruction set architecture (ISA). Alternatively, the cores 4302(A)-(N) may be heterogeneous in terms of ISA; that is, a subset of the cores 4302(A)-(N) may be capable of executing an ISA, while other cores may be capable of executing only a subset of that ISA or another ISA.
In
By way of example, the example register renaming, out-of-order issue/execution architecture core of
The front-end unit circuitry 4430 may include branch prediction circuitry 4432 coupled to instruction cache circuitry 4434, which is coupled to an instruction translation lookaside buffer (TLB) 4436, which is coupled to instruction fetch circuitry 4438, which is coupled to decode circuitry 4440. In one example, the instruction cache circuitry 4434 is included in the memory unit circuitry 4470 rather than the front-end circuitry 4430. The decode circuitry 4440 (or decoder) may decode instructions, and generate as an output one or more micro-operations, micro-code entry points, microinstructions, other instructions, or other control signals, which are decoded from, or which otherwise reflect, or are derived from, the original instructions. The decode circuitry 4440 may further include address generation unit (AGU, not shown) circuitry. In one example, the AGU generates an LSU address using forwarded register ports, and may further perform branch forwarding (e.g., immediate offset branch forwarding, LR register branch forwarding, etc.). The decode circuitry 4440 may be implemented using various different mechanisms. Examples of suitable mechanisms include, but are not limited to, look-up tables, hardware implementations, programmable logic arrays (PLAs), microcode read only memories (ROMs), etc. In one example, the core 4490 includes a microcode ROM (not shown) or other medium that stores microcode for certain macroinstructions (e.g., in decode circuitry 4440 or otherwise within the front-end circuitry 4430). In one example, the decode circuitry 4440 includes a micro-operation (micro-op) or operation cache (not shown) to hold/cache decoded operations, micro-tags, or micro-operations generated during the decode or other stages of the processor pipeline 4400. The decode circuitry 4440 may be coupled to rename/allocator unit circuitry 4452 in the execution engine circuitry 4450.
The execution engine circuitry 4450 includes the rename/allocator unit circuitry 4452 coupled to retirement unit circuitry 4454 and a set of one or more scheduler(s) circuitry 4456. The scheduler(s) circuitry 4456 represents any number of different schedulers, including reservations stations, central instruction window, etc. In some examples, the scheduler(s) circuitry 4456 can include arithmetic logic unit (ALU) scheduler/scheduling circuitry, ALU queues, address generation unit (AGU) scheduler/scheduling circuitry, AGU queues, etc. The scheduler(s) circuitry 4456 is coupled to the physical register file(s) circuitry 4458. Each of the physical register file(s) circuitry 4458 represents one or more physical register files, different ones of which store one or more different data types, such as scalar integer, scalar floating-point, packed integer, packed floating-point, vector integer, vector floating-point, status (e.g., an instruction pointer that is the address of the next instruction to be executed), etc. In one example, the physical register file(s) circuitry 4458 includes vector registers unit circuitry, writemask registers unit circuitry, and scalar register unit circuitry. These register units may provide architectural vector registers, vector mask registers, general-purpose registers, etc. The physical register file(s) circuitry 4458 is coupled to the retirement unit circuitry 4454 (also known as a retire queue or a retirement queue) to illustrate various ways in which register renaming and out-of-order execution may be implemented (e.g., using a reorder buffer(s) (ROB(s)) and a retirement register file(s); using a future file(s), a history buffer(s), and a retirement register file(s); using a register maps and a pool of registers; etc.). The retirement unit circuitry 4454 and the physical register file(s) circuitry 4458 are coupled to the execution cluster(s) 4460. The execution cluster(s) 4460 includes a set of one or more execution unit(s) circuitry 4462 and a set of one or more memory access circuitry 4464. The execution unit(s) circuitry 4462 may perform various arithmetic, logic, floating-point or other types of operations (e.g., shifts, addition, subtraction, multiplication) and on various types of data (e.g., scalar integer, scalar floating-point, packed integer, packed floating-point, vector integer, vector floating-point). While some examples may include a number of execution units or execution unit circuitry dedicated to specific functions or sets of functions, other examples may include only one execution unit circuitry or multiple execution units/execution unit circuitry that all perform all functions. The scheduler(s) circuitry 4456, physical register file(s) circuitry 4458, and execution cluster(s) 4460 are shown as being possibly plural because certain examples create separate pipelines for certain types of data/operations (e.g., a scalar integer pipeline, a scalar floating-point/packed integer/packed floating-point/vector integer/vector floating-point pipeline, and/or a memory access pipeline that each have their own scheduler circuitry, physical register file(s) circuitry, and/or execution cluster—and in the case of a separate memory access pipeline, certain examples are implemented in which only the execution cluster of this pipeline has the memory access unit(s) circuitry 4464). It should also be understood that where separate pipelines are used, one or more of these pipelines may be out-of-order issue/execution and the rest in-order.
In some examples, the execution engine unit circuitry 4450 may perform load store unit (LSU) address/data pipelining to an Advanced Microcontroller Bus (AMB) interface (not shown), and address phase and writeback, data phase load, store, and branches.
The set of memory access circuitry 4464 is coupled to the memory unit circuitry 4470, which includes data TLB circuitry 4472 coupled to data cache circuitry 4474 coupled to level 2 (L2) cache circuitry 4476. In one example, the memory access circuitry 4464 may include load unit circuitry, store address unit circuitry, and store data unit circuitry, each of which is coupled to the data TLB circuitry 4472 in the memory unit circuitry 4470. The instruction cache circuitry 4434 is further coupled to the level 2 (L2) cache circuitry 4476 in the memory unit circuitry 4470. In one example, the instruction cache 4434 and the data cache 4474 are combined into a single instruction and data cache (not shown) in L2 cache circuitry 4476, level 3 (L3) cache circuitry (not shown), and/or main memory. The L2 cache circuitry 4476 is coupled to one or more other levels of cache and eventually to a main memory.
The core 4490 may support one or more instructions sets (e.g., the x86 instruction set architecture (optionally with some extensions that have been added with newer versions); the MIPS instruction set architecture; the ARM instruction set architecture (optionally with optional additional extensions such as NEON)), including the instruction(s) described herein. In one example, the core 4490 includes logic to support a packed data instruction set architecture extension (e.g., AVX1, AVX2), thereby allowing the operations used by many multimedia applications to be performed using packed data.
In some examples, the register architecture 4600 includes writemask/predicate registers 4615. For example, in some examples, there are 8 writemask/predicate registers (sometimes called k0 through k7) that are each 16-bit, 32-bit, 64-bit, or 128-bit in size. Writemask/predicate registers 4615 may allow for merging (e.g., allowing any set of elements in the destination to be protected from updates during the execution of any operation) and/or zeroing (e.g., zeroing vector masks allow any set of elements in the destination to be zeroed during the execution of any operation). In some examples, each data element position in a given writemask/predicate register 4615 corresponds to a data element position of the destination. In other examples, the writemask/predicate registers 4615 are scalable and consists of a set number of enable bits for a given vector element (e.g., 8 enable bits per 64-bit vector element).
The register architecture 4600 includes a plurality of general-purpose registers 4625. These registers may be 16-bit, 32-bit, 64-bit, etc. and can be used for scalar operations. In some examples, these registers are referenced by the names RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP, and R8 through R15.
In some examples, the register architecture 4600 includes scalar floating-point (FP) register file 4645 which is used for scalar floating-point operations on 32/64/80-bit floating-point data using the x87 instruction set architecture extension or as MMX registers to perform operations on 64-bit packed integer data, as well as to hold operands for some operations performed between the MMX and XMM registers.
One or more flag registers 4640 (e.g., EFLAGS, RFLAGS, etc.) store status and control information for arithmetic, compare, and system operations. For example, the one or more flag registers 4640 may store condition code information such as carry, parity, auxiliary carry, zero, sign, and overflow. In some examples, the one or more flag registers 4640 are called program status and control registers.
Segment registers 4620 contain segment points for use in accessing memory. In some examples, these registers are referenced by the names CS, DS, SS, ES, FS, and GS.
Machine specific registers (MSRs) 4635 control and report on processor performance. Most MSRs 4635 handle system-related functions and are not accessible to an application program. Machine check registers 4660 consist of control, status, and error reporting MSRs that are used to detect and report on hardware errors.
One or more instruction pointer register(s) 4630 store an instruction pointer value. Control register(s) 4655 (e.g., CR0-CR4) determine the operating mode of a processor (e.g., processor 4270, 4280, 4238, 4215, and/or 4300) and the characteristics of a currently executing task. Debug registers 4650 control and allow for the monitoring of a processor or core's debugging operations.
Memory (mem) management registers 4665 specify the locations of data structures used in protected mode memory management. These registers may include a global descriptor table register (GDTR), interrupt descriptor table register (IDTR), task register, and a local descriptor table register (LDTR) register.
Alternative examples may use wider or narrower registers. Additionally, alternative examples may use more, less, or different register files and registers. The register architecture 4600 may, for example, be used in register files 1315, 1415, 1819, or physical register file(s) circuitry 4458.
An instruction set architecture (ISA) may include one or more instruction formats. A given instruction format may define various fields (e.g., number of bits, location of bits) to specify, among other things, the operation to be performed (e.g., opcode) and the operand(s) on which that operation is to be performed and/or other data field(s) (e.g., mask). Some instruction formats are further broken down through the definition of instruction templates (or sub-formats). For example, the instruction templates of a given instruction format may be defined to have different subsets of the instruction format's fields (the included fields are typically in the same order, but at least some have different bit positions because there are less fields included) and/or defined to have a given field interpreted differently. Thus, each instruction of an ISA is expressed using a given instruction format (and, if defined, in a given one of the instruction templates of that instruction format) and includes fields for specifying the operation and the operands. For example, an example ADD instruction has a specific opcode and an instruction format that includes an opcode field to specify that opcode and operand fields to select operands (source1/destination and source2); and an occurrence of this ADD instruction in an instruction stream will have specific contents in the operand fields that select specific operands. In addition, though the description below is made in the context of x86 ISA, it is within the knowledge of one skilled in the art to apply the teachings of the present disclosure in another ISA.
Examples of the instruction(s) described herein may be embodied in different formats. Additionally, example systems, architectures, and pipelines are detailed below. Examples of the instruction(s) may be executed on such systems, architectures, and pipelines, but are not limited to those detailed.
The prefix(es) field(s) 4701, when used, modifies an instruction. In some examples, one or more prefixes are used to repeat string instructions (e.g., 0xF0, 0xF2, 0xF3, etc.), to provide section overrides (e.g., 0x2E, 0x36, 0x3E, 0x26, 0x64, 0x65, 0x2E, 0x3E, etc.), to perform bus lock operations, and/or to change operand (e.g., 0x66) and address sizes (e.g., 0x67). Certain instructions require a mandatory prefix (e.g., 0x66, 0xF2, 0xF3, etc.). Certain of these prefixes may be considered “legacy” prefixes. Other prefixes, one or more examples of which are detailed herein, indicate, and/or provide further capability, such as specifying particular registers, etc. The other prefixes typically follow the “legacy” prefixes.
The opcode field 4703 is used to at least partially define the operation to be performed upon a decoding of the instruction. In some examples, a primary opcode encoded in the opcode field 4703 is one, two, or three bytes in length. In other examples, a primary opcode can be a different length. An additional 3-bit opcode field is sometimes encoded in another field.
The addressing information field 4705 is used to address one or more operands of the instruction, such as a location in memory or one or more registers.
The content of the MOD field 4842 distinguishes between memory access and non-memory access modes. In some examples, when the MOD field 4842 has a binary value of 11 (11b), a register-direct addressing mode is utilized, and otherwise a register-indirect addressing mode is used.
The register field 4844 may encode either the destination register operand or a source register operand or may encode an opcode extension and not be used to encode any instruction operand. The content of register field 4844, directly or through address generation, specifies the locations of a source or destination operand (either in a register or in memory). In some examples, the register field 4844 is supplemented with an additional bit from a prefix (e.g., prefix 4701) to allow for greater addressing.
The R/M field 4846 may be used to encode an instruction operand that references a memory address or may be used to encode either the destination register operand or a source register operand. Note the R/M field 4846 may be combined with the MOD field 4842 to dictate an addressing mode in some examples.
The SIB byte 4804 includes a scale field 4852, an index field 4854, and a base field 4856 to be used in the generation of an address. The scale field 4852 indicates a scaling factor. The index field 4854 specifies an index register to use. In some examples, the index field 4854 is supplemented with an additional bit from a prefix (e.g., prefix 4701) to allow for greater addressing. The base field 4856 specifies a base register to use. In some examples, the base field 4856 is supplemented with an additional bit from a prefix (e.g., prefix 4701) to allow for greater addressing. In practice, the content of the scale field 4852 allows for the scaling of the content of the index field 4854 for memory address generation (e.g., for address generation that uses 2scale*index+base).
Some addressing forms utilize a displacement value to generate a memory address. For example, a memory address may be generated according to 2scale*index+base+displacement, index*scale+displacement, r/m+displacement, instruction pointer (RIP/EIP)+displacement, register+displacement, etc. The displacement may be a 1-byte, 2-byte, 4-byte, etc. valuc. In some examples, the displacement field 4707 provides this value. Additionally, in some examples, a displacement factor usage is encoded in the MOD field of the addressing information field 4705 that indicates a compressed displacement scheme for which a displacement value is calculated and stored in the displacement field 4707.
In some examples, the immediate value field 4709 specifies an immediate value for the instruction. An immediate value may be encoded as a 1-byte value, a 2-byte value, a 4-byte value, etc.
Instructions using the first prefix 4701(A) may specify up to three registers using 3-bit fields depending on the format: 1) using the reg field 4844 and the R/M field 4846 of the MOD R/M byte 4802; 2) using the MOD R/M byte 4802 with the SIB byte 4804 including using the reg field 4844 and the base field 4856 and index field 4854; or 3) using the register field of an opcode.
In the first prefix 4701(A), bit positions 7:4 are set as 0100. Bit position 3 (W) can be used to determine the operand size but may not solely determine operand width. As such, when W=0, the operand size is determined by a code segment descriptor (CS.D) and when W=1, the operand size is 64-bit.
Note that the addition of another bit allows for 16 (24) registers to be addressed, whereas the MOD R/M reg field 4844 and MOD R/M R/M field 4846 alone can each only address 8 registers.
In the first prefix 4701(A), bit position 2 (R) may be an extension of the MOD R/M reg field 4844 and may be used to modify the MOD R/M reg field 4844 when that field encodes a general-purpose register, a 64-bit packed data register (e.g., an SSE register), or a control or debug register. R is ignored when MOD R/M byte 4802 specifies other registers or defines an extended opcode.
Bit position 1 (X) may modify the SIB byte index field 4854.
Bit position 0 (B) may modify the base in the MOD R/M R/M field 4846 or the SIB byte base field 4856; or it may modify the opcode register field used for accessing general purpose registers (e.g., general purpose registers 4625).
In some examples, the second prefix 4701(B) comes in two forms—a two-byte form and a three-byte form. The two-byte second prefix 4701(B) is used mainly for 128-bit, scalar, and some 256-bit instructions; while the three-byte second prefix 4701(B) provides a compact replacement of the first prefix 4701(A) and 3-byte opcode instructions.
Instructions that use this prefix may use the MOD R/M R/M field 4846 to encode the instruction operand that references a memory address or encode either the destination register operand or a source register operand.
Instructions that use this prefix may use the MOD R/M reg field 4844 to encode either the destination register operand or a source register operand, or to be treated as an opcode extension and not used to encode any instruction operand.
For instruction syntax that support four operands, vvvv, the MOD R/M R/M field 4846 and the MOD R/M reg field 4844 encode three of the four operands. Bits[7:4] of the immediate value field 4709 are then used to encode the third source register operand.
Bit[7] of byte 2 5117 is used similar to W of the first prefix 4701(A) including helping to determine promotable operand sizes. Bit[2] is used to dictate the length (L) of the vector (where a value of 0 is a scalar or 128-bit vector and a value of 1 is a 256-bit vector). Bits[1:0] provide opcode extensionality equivalent to some legacy prefixes (e.g., 00=no prefix, 01=66H, 10=F3H, and 11=F2H). Bits[6:3], shown as vvvv, may be used to: 1) encode the first source register operand, specified in inverted (1s complement) form and valid for instructions with 2 or more source operands; 2) encode the destination register operand, specified in 1s complement form for certain vector shifts; or 3) not encode any operand, the field is reserved and should contain a certain value, such as 1111b.
Instructions that use this prefix may use the MOD R/M R/M field 4846 to encode the instruction operand that references a memory address or encode either the destination register operand or a source register operand.
Instructions that use this prefix may use the MOD R/M reg field 4844 to encode either the destination register operand or a source register operand, or to be treated as an opcode extension and not used to encode any instruction operand.
For instruction syntax that support four operands, vvvv, the MOD R/M R/M field 4846, and the MOD R/M reg field 4844 encode three of the four operands. Bits[7:4] of the immediate value field 4709 are then used to encode the third source register operand.
The third prefix 4701(C) can encode 32 vector registers (e.g., 128-bit, 256-bit, and 512-bit registers) in 64-bit mode. In some examples, instructions that utilize a writemask/opmask (sec discussion of registers in a previous figure, such as
The third prefix 4701(C) may encode functionality that is specific to instruction classes (e.g., a packed instruction with “load+op” semantic can support embedded broadcast functionality, a floating-point instruction with rounding semantic can support static rounding functionality, a floating-point instruction with non-rounding arithmetic semantic can support “suppress all exceptions” functionality, etc.).
The first byte of the third prefix 4701(C) is a format field 5211 that has a value, in one example, of 62H. Subsequent bytes are referred to as payload bytes 5215-5219 and collectively form a 24-bit value of P[23:0] providing specific capability in the form of one or more fields (detailed herein).
In some examples, P[1:0] of payload byte 5219 are identical to the low two mm bits. P[3:2] are reserved in some examples. Bit P[4] (R′) allows access to the high 16 vector register set when combined with P[7] and the MOD R/M reg field 4844. P[6] can also provide access to a high 16 vector register when SIB-type addressing is not needed. P[7:5] consist of R, X, and B which are operand specifier modifier bits for vector register, general purpose register, memory addressing and allow access to the next set of 8 registers beyond the low 8 registers when combined with the MOD R/M register field 4844 and MOD R/M R/M field 4846. P[9:8] provide opcode extensionality equivalent to some legacy prefixes (e.g., 00=no prefix, 01=66H, 10=F3H, and 11=F2H). P[10] in some examples is a fixed value of 1. P[14:11], shown as vvvv, may be used to: 1) encode the first source register operand, specified in inverted (1s complement) form and valid for instructions with 2 or more source operands; 2) encode the destination register operand, specified in 1s complement form for certain vector shifts; or 3) not encode any operand, the field is reserved and should contain a certain value, such as 1111b.
P[15] is similar to W of the first prefix 4701(A) and second prefix 4711(B) and may serve as an opcode extension bit or operand size promotion.
P[18:16] specify the index of a register in the opmask (writemask) registers (e.g., writemask/predicate registers 4615). In one example, the specific value aaa=000 has a special behavior implying no opmask is used for the particular instruction (this may be implemented in a variety of ways including the use of an opmask hardwired to all ones or hardware that bypasses the masking hardware). When merging, vector masks allow any set of elements in the destination to be protected from updates during the execution of any operation (specified by the base operation and the augmentation operation); in other one example, preserving the old value of each element of the destination where the corresponding mask bit has a 0. In contrast, when zeroing vector masks allow any set of elements in the destination to be zeroed during the execution of any operation (specified by the base operation and the augmentation operation); in one example, an element of the destination is set to 0 when the corresponding mask bit has a 0 value. A subset of this functionality is the ability to control the vector length of the operation being performed (that is, the span of elements being modified, from the first to the last one); however, it is not necessary that the elements that are modified be consecutive. Thus, the opmask field allows for partial vector operations, including loads, stores, arithmetic, logical, etc. While examples are described in which the opmask field's content selects one of a number of opmask registers that contains the opmask to be used (and thus the opmask field's content indirectly identifies that masking to be performed), alternative examples instead or additional allow the mask write field's content to directly specify the masking to be performed.
P[19] can be combined with P[14:11] to encode a second source vector register in a nondestructive source syntax which can access an upper 16 vector registers using P[19]. P[20] encodes multiple functionalities, which differs across different classes of instructions and can affect the meaning of the vector length/rounding control specifier field (P[22:21]). P[23] indicates support for merging-writemasking (e.g., when set to 0) or support for zeroing and merging-writemasking (e.g., when set to 1).
Example examples of encoding of registers in instructions using the third prefix 4701(C) are detailed in the following tables.
Program code may be applied to input information to perform the functions described herein and generate output information. The output information may be applied to one or more output devices, in known fashion. For purposes of this application, a processing system includes any system that has a processor, such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a microprocessor, or any combination thereof.
The program code may be implemented in a high-level procedural or object-oriented programming language to communicate with a processing system. The program code may also be implemented in assembly or machine language, if desired. In fact, the mechanisms described herein are not limited in scope to any particular programming language. In any case, the language may be a compiled or interpreted language.
Examples of the mechanisms disclosed herein may be implemented in hardware, software, firmware, or a combination of such implementation approaches. Examples may be implemented as computer programs or program code executing on programmable systems comprising at least one processor, a storage system (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device.
One or more aspects of at least one example may be implemented by representative instructions stored on a machine-readable medium which represents various logic within the processor, which when read by a machine causes the machine to fabricate logic to perform the techniques described herein. Such representations, known as “intellectual property (IP) cores” may be stored on a tangible, machine readable medium and supplied to various customers or manufacturing facilities to load into the fabrication machines that make the logic or processor.
Such machine-readable storage media may include, without limitation, non-transitory, tangible arrangements of articles manufactured or formed by a machine or device, including storage media such as hard disks, any other type of disk including floppy disks, optical disks, compact disk read-only memories (CD-ROMs), compact disk rewritables (CD-RWs), and magneto-optical disks, semiconductor devices such as read-only memories (ROMs), random access memories (RAMs) such as dynamic random access memories (DRAMs), static random access memories (SRAMs), erasable programmable read-only memories (EPROMs), flash memories, electrically erasable programmable read-only memories (EEPROMs), phase change memory (PCM), magnetic or optical cards, or any other type of media suitable for storing electronic instructions.
Accordingly, examples also include non-transitory, tangible machine-readable media containing instructions or containing design data, such as Hardware Description Language (HDL), which defines structures, circuits, apparatuses, processors and/or system features described herein. Such examples may also be referred to as program products.
In some cases, an instruction converter may be used to convert an instruction from a source instruction set architecture to a target instruction set architecture. For example, the instruction converter may translate (e.g., using static binary translation, dynamic binary translation including dynamic compilation), morph, emulate, or otherwise convert an instruction to one or more other instructions to be processed by the core. The instruction converter may be implemented in software, hardware, firmware, or a combination thereof. The instruction converter may be on processor, off processor, or part on and part off processor.
References to “one example,” “an example,” etc., indicate that the example described may include a particular feature, structure, or characteristic, but every example may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same example. Further, when a particular feature, structure, or characteristic is described in connection with an example, it is submitted that it is within the knowledge of one skilled in the art to affect such feature, structure, or characteristic in connection with other examples whether or not explicitly described.
Moreover, in the various examples described above, unless specifically noted otherwise, disjunctive language such as the phrase “at least one of A, B, or C” or “A, B, and/or C” is intended to be understood to mean either A, B, or C, or any combination thereof (i.e., A and B, A and C, B and C, and A, B and C).
The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense. It will, however, be evident that various modifications and changes may be made thereunto without departing from the broader spirit and scope of the disclosure as set forth in the claims.