Register addressing information for data transfer instructions
By using base address registers and immediate values to define register addressing information in data transfer instructions, the problem that data transfer instructions in the prior art cannot adapt to scalable data storage sizes and array dimensions is solved, achieving flexibility and performance optimization for efficient processing of 2D data arrays.
Patent Information
- Application Number
- CN202180050192.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-07-30
- Filing Date
- 2021-07-05
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2041-07-05
AI Technical Summary
In the prior art, when data transfer instructions access specific registers in register storage devices, the compiler cannot dynamically adapt to the scalable data storage size, and there is a performance loss when looping is unrolled, making it difficult to efficiently handle the variable dimensions and sizes of 2D data arrays.
It uses base register identifiers and immediate values to define register addressing information, selects target parts by generating index values, supports scalable code and loop unrolling, and optimizes data transfer instructions to adapt to different data storage sizes and array dimensions.
It enables efficient access and processing of variable-dimensional 2D data arrays in a 2D array register storage device, improving processor flexibility and performance, reducing the number of loop iterations, and supporting vector length-independent program code.
Smart Images

Figure CN115956233B_ABST
Abstract
Description
[0001] This technology relates to the field of data processing.
[0002] Data transfer instructions can be used in data processing to control the transfer of data to or from register storage devices.
[0003] At least some examples provide an apparatus comprising: an instruction decoding circuit for decoding an instruction; a register storage device for storing data; and a processing circuit for performing data processing in response to an instruction decoded by the instruction decoding circuit to generate a processing result to be written into at least one register in the register storage device; wherein: in response to a data transfer instruction specifying register addressing information for identifying a target portion of the register storage device, the instruction decoding circuit is configured to control the processing circuit to perform a data transfer operation to transfer data to or from the target portion of the register storage device; and the register addressing information includes at least: a base register identifier identifying a base register in the register storage device for storing a base address value; and an immediate value specified in the encoding of the data transfer instruction, the immediate value representing a value to be added to the base address value to provide an index value for selecting the target portion of the register storage device.
[0004] At least some examples provide a method comprising: decoding an instruction; and, in response to the decoded instruction, controlling processing circuitry to perform data processing to generate a processing result to be written into at least one register in a register storage device; wherein: in response to a data transfer instruction specifying register addressing information for identifying a target portion of the register storage device, controlling the processing circuitry to perform a data transfer operation to transfer data to or from the target portion of the register storage device; and the register addressing information comprising at least: a base register identifier identifying a base register in the register storage device for storing a base address value; and an immediate value specified in the encoding of the data transfer instruction, the immediate value representing a value to be added to the base address value to provide an index value for selecting the target portion of the register storage device.
[0005] A computer program for controlling a host data processing device to provide an instruction execution environment for executing instructions of target code, the computer program comprising: instruction decoding program logic for decoding instructions of the target code to control the host data processing device to execute processing operations corresponding to the decoded instructions; and register emulation program logic for maintaining a register emulation data structure in host memory of the host data processing device to emulate a register memory of a target instruction set architecture associated with the target code; wherein, in response to specifying a register memory for identifying the register memory... A data transfer instruction for register addressing information of a target portion of the device, wherein the instruction decoding program logic is configured to control the host data processing device to perform a data transfer operation to transfer data to or from a location in the register emulation data structure corresponding to the target portion of the register storage device; and the register addressing information includes at least: a base register identifier that identifies a base register in the register storage device for storing a base address value; and an immediate value specified in the encoding of the data transfer instruction, the immediate value representing a value to be added to the base address value to provide an index value used to select the target portion of the register storage device.
[0006] At least some examples provide a storage medium that stores the aforementioned computer program. The storage medium can be a transient or non-transitory storage medium.
[0007] Further aspects, features, and advantages of this technology will become apparent from the following description of an example read in conjunction with the accompanying drawings, in which:
[0008] Figure 1 A first example of a data processing apparatus that supports matrix processing is schematically shown;
[0009] Figures 2A to 2D A second example of a data processing apparatus that supports matrix processing is shown;
[0010] Figure 3 This demonstrates how matrix multiplication can be broken down into outer product operations to produce equivalent results;
[0011] Figure 4 An example of an outer product engine is shown, which is used to perform an outer product operation on a pair of vector operands to generate a two-dimensional (2D) data array as the result;
[0012] Figure 5 An example of the architecture registers of a processing device is shown, which includes a vector register for storing vector operands and an array register for storing 2D data arrays;
[0013] Figure 6 An example of the physical implementation of the array register is shown;
[0014] Figures 7 to 11 This illustrates how the physical storage capacity of an array register can be logically divided into a variable number of architectural array registers;
[0015] Figure 12 An example of the encoding of a load / store data transfer instruction for transferring a portion of a 2D data array between an array register storage device and memory is shown;
[0016] Figure 13 An example is shown where a combination field of instruction encoding of a data transfer instruction is used to encode the array identifier and an immediate value;
[0017] Figure 14 It shows the use of Figure 12 Example of program code for data transfer instructions;
[0018] Figure 15 An example of a register move data transfer instruction is shown for transferring a portion of a 2D data array between an array register and a vector register;
[0019] Figure 16 This is a flowchart illustrating the method of processing instructions; and
[0020] Figure 17 An example of a simulator that can be used is shown.
[0021] The data processing apparatus may include instruction decoding circuitry for decoding instructions and processing circuitry for performing data processing in response to the decoded instructions. A register storage device may be provided to store data. The register storage device may be used to provide operands for processing by the processing circuitry. When the processing circuitry generates a processing result in response to an instruction, the processing result may be written into at least one register in the register storage device.
[0022] A data transfer instruction is provided for transferring data to or from a register storage device. In response to the data transfer instruction, the instruction decoding circuit controls the processing circuit to execute the data transfer operation. The data transfer operation includes transferring data to or from a target portion of the register storage device. The data transfer instruction specifies register addressing information that identifies the target portion of the register storage device.
[0023] In a typical data transfer instruction, the registers used as the target portion of the register storage device can be identified by the register field in the instruction code, where the value in the register field is an identifier of the architecture register to which data is to be transferred.
[0024] However, in the examples discussed below, the register addressing information includes at least a base register identifier and an immediate value. The base register identifier identifies the base register in the register storage device used to store the base address value, and the immediate value is directly specified in the encoding of the data transfer instruction and represents the value to be added to the base address value to provide an index value for selecting the target portion of the register storage device (to which data is to be transferred to or from memory).
[0025] Using base registers and immediate values to define register addressing information would be considered counterintuitive by those skilled in the art of instruction set architecture design. While base register-based and immediate value-based addressing may be known for memory addressing, it seems unnecessary for register addressing because the specific registers expected to be accessed during data transfer can be directly selected by the compiler of the program code to be executed, and therefore there is no need for indirect references to base registers. However, the inventors recognized that using base registers to provide register addressing information for generating indexes to select the target portion of a register storage device could be useful for allowing compilers to generate code that can dynamically adapt to scalable data storage sizes.
[0026] Furthermore, using immediate values when generating index values to provide the offset to be added to the base address value can be useful for enabling the compiler to use a technique called loop unrolling, which can help reduce the overhead of controlling the iterations of a program's loop. Each iteration of a loop can incur a performance penalty when executing loop control instructions (such as instructions for incrementing a loop counter or other variables (such as the base address value in the base register of a data transfer instruction) and when testing whether a loop termination condition is met. By performing loop unrolling, the compiler can map a set of two or more iterations of a loop included in high-level code written by the programmer to a single loop iteration in the compiled code, which performs the same operation as the two or more iterations in the high-level code loop. This reduces the number of loop control instructions that need to be executed for a given number of loop iterations in the high-level code and enables greater instruction-level parallelism because if some instructions from later iterations of the loop in the high-level code are independent of instructions from earlier iterations, they can be executed in parallel. Furthermore, if the loop has been compiled into code that implements a single high-level loop iteration per iteration in the compiled code, the instructions for later iterations of the high-level loop can depend on instructions from earlier iterations, thus reducing the potential amount of parallelism. Using base registers and immediate values to define register addressing information is useful for supporting loop unrolling because immediate values can be used to add different offsets to the value in the base register for different data transfer instructions corresponding to the unrolled versions of the individual iterations of the high-level code loop, which are then combined into a single loop iteration in the compiled code.
[0027] Therefore, in summary, data transfer instructions with register addressing information defined as described above using base register identifiers and immediate values can be particularly useful for supporting scalable code that can be scaled to different data storage sizes and allows the compiler to perform loop unrolling.
[0028] An immediate value represents the index value to be added to the base address value to provide a way to select the target portion of the register storage device. In some implementations of the instruction, the value to be added to the base address value can be the exact value specified as the immediate value. In other examples, the immediate value can have encodings that do not directly specify the value to be added. For example, an immediate value can be specified as a multiple of a given constant Z, such that the product of Z and the immediate value is added to the base address value.
[0029] Furthermore, in some examples, the index value can be equal to the sum of the base value and the value represented by the immediate value. In other examples, the index value may depend on the addition of the base value and the value represented by the immediate value, but may not be exactly equal to the sum of the base value and the value represented by the immediate value. For example, to handle values outside the range of the base value, in some cases, the index value may correspond to: the sum of the base value and the value represented by the immediate value modulo a given value chosen to ensure that the resulting index is within the required range (i.e., the index value is the remainder after dividing the sum by the given value).
[0030] The encoding of register addressing information using base register identifiers and immediate values can be applied to any form of data transfer instruction, including data transfer instructions that use index values to select which integer register, floating-point register, vector register, or other type of register storage device to access during data transfer.
[0031] However, in one example, the register storage device includes a two-dimensional (2D) array register storage device for storing at least one 2D data array, and the target portion of the register storage device includes the target portion of the 2D array register storage device. Therefore, in this example, the data transfer instruction can be an array data transfer instruction for transferring at least a portion of the 2D data array to or from the array register storage device. 2D arrays (such as matrices) are useful for a wide range of processing applications. One example is in the field of machine learning, where matrix multiplication can be the backbone of inference and training algorithms for many types of machine learning models, but other applications also use matrix arithmetic, such as in augmented reality, virtual reality, computer vision, computational photography, scientific simulation, digital signal processing, and other fields. Therefore, support for matrix arithmetic can be an important feature for the advancement of processing applications, and thus, providing 2D array register storage devices designed for storing 2D data arrays can be useful for supporting such applications. In some examples below, the term "tile" is used to refer to a 2D data array.
[0032] Data transfer instructions with register addressing information, including a base register identifier and an immediate value, can be particularly useful for systems supporting 2D array register stores, as applications involving the processing of 2D data arrays may require scalability to handle array sizes varying in both dimensions of the array structure. By specifying register addressing information that identifies the target portion of the register store using a base register identifier and an immediate value, a program loop can be defined that can change which registers are accessed based on the variable array dimensions, which can be useful for processing 2D data arrays.
[0033] In one example, a data transfer operation performed in response to a data transfer instruction may include transferring a sub-section of a target 2D array to or from a target portion of a 2D array register storage device, wherein an index value generated from a base address value and an immediate value can identify which specific sub-section of the target 2D array is to be transferred. For example, the base address value and the immediate value may be used to define a program loop that iterates over the corresponding sub-section of the target 2D array.
[0034] For example, an index value can identify a single group of horizontal elements sharing the same vertical position within the target 2D array as a sub-part. Other implementations may allow a single data transfer instruction to transfer multiple groups of horizontal or vertical elements of the target 2D array. Regardless of the method, this makes it easier for the software to scale to different array dimensions (different numbers of rows or columns) by using a base address register and an immediate value to select which sub-part of the target 2D array to transfer.
[0035] In this application, the terms "horizontal" and "vertical" are used to refer to the "row" and "column" directions of a 2D array as viewed from the perspective of the 2D array register storage device. More precisely, the "horizontal" and "vertical" directions refer to the logical arrangement of elements in the 2D array, in a sense taking into account the logical location of each element within the 2D array in computational instructions or instructions for transferring the 2D array to / from memory. However, it should be understood that the physical layout of the register storage device does not necessarily have to follow a 2D grid arrangement of storage elements. Storage device elements can be physically arranged at any convenient location within the integrated circuit layout.
[0036] The "horizontal" and "vertical" directions associated with a 2D array stored in a 2D array register memory device do not necessarily correspond to the same row / column layout of the matrix data structure stored in memory. Matrix data can be stored in memory in different layouts (e.g., row-major or column-major). In row-major order, adjacent elements of matrix rows are stored in memory at contiguous addresses, but adjacent elements of matrix columns are offset in memory by a stride value. Conversely, in column-major order, adjacent elements of matrix columns are stored in memory at contiguous addresses, but adjacent elements of matrix rows are offset in memory by a stride value.
[0037] Therefore, when reading data from memory, it can be done in row-major order (such that consecutive memory elements read into the register storage device represent rows or a portion of rows of the underlying matrix structure in memory) or column-major order (such that consecutive memory elements read into represent columns or a portion of columns), but in either case, elements can be written into horizontal or vertical groups of elements in the 2D array register storage device.
[0038] Therefore, it should be understood that a horizontal group of elements in a 2D array register storage device can represent a row or column of elements from a matrix structure in memory (or a set of newly computed elements that can subsequently be written back to the rows or columns of elements in the matrix structure in memory). Similarly, a vertical group of elements in a 2D array register storage device can represent a row or column of elements from an underlying matrix structure stored in memory (or can represent a newly computed value to be written back to such a row or column). To avoid confusion, the terms "row" and "column" will be used to refer to the arrangement of matrix elements in memory, and "horizontal group" and "vertical group" can be used to refer to the arrangement of elements in a 2D array stored in a 2D array register storage device.
[0039] In some implementations, data transfer instructions may only support data transfer to / from the 2D array register memory in either the horizontal or vertical direction. For example, some implementations may only support horizontal access to the 2D array register memory. This simplifies the circuit logic used to access the 2D array register memory.
[0040] However, in other examples, the instruction set architecture (ISA) can support reading / writing to 2D array register storage devices in both horizontal and vertical directions. Therefore, data transfer instructions can specify an array orientation identifier that identifies either the horizontal or vertical direction. When the array orientation identifier identifies the horizontal direction, a sub-part of the target 2D array includes at least one horizontal element group of the target 2D array identified by an index value, each horizontal element group including elements sharing the same vertical position within the target 2D array. When the array orientation identifier identifies the vertical direction, a sub-part of the target 2D array includes at least one vertical element group of the target 2D array identified by an index value, each vertical element group including elements sharing the same horizontal position within the target 2D array. This can be useful for implementing instantaneous transposition of matrices when transferring data from memory to or from the 2D array register storage device back to memory. Since such instantaneous transposition can be much faster than executing numerous load / store instructions or vector reorganization instructions to shuffle elements when transferring matrix data between memory and register storage devices, instantaneous transposition helps improve application performance in situations where matrix memory layout and computational requirements are incompatible.
[0041] Data transfer instructions can be used to process implementations of 2D arrays defined by a specific fixed data element size, where the element size refers to the number of bits in a single element of the 2D array.
[0042] However, supporting variable data element sizes can be useful, allowing data transfer instructions to be used in applications that can process matrices defined using data values with different levels of precision. Therefore, a data transfer instruction can be associated with the current data element size E specified for the data transfer instruction, from two or more data element sizes supported by the processing circuitry.
[0043] The current data element size E can be specified for a data transfer instruction in various ways. In some cases, the parameters of the data transfer instruction itself can specify the current data element size E. For example, a portion of the instruction code of the data transfer instruction can specify the current data element size E. Another option is that control information stored in a control register or other memory location can define the current data element size E. In this case, the encoding of the data transfer instruction itself does not need to include any bits identifying the current data element size E. Instructions executed before the data transfer instruction can be used to set values in control memory locations to set the current data element size E to be used for subsequent data transfer instructions. Some methods can also use a modal approach, where the current data element size used depends on the operating mode in which the processing circuit is operating when executing the data transfer instruction. Therefore, it should be understood that there are multiple ways to identify the current data element size E for a given data transfer instruction.
[0044] In specific implementations that support variable data element sizes, a specific number of bits N can be used in the instruction encoding of the data transfer instruction. imm To encode the immediate value of the register addressing information, where N imm The current data element size E is variable, where N is... imm The immediate value increases as E decreases. This method can be particularly useful when the immediate value is used to generate an index identifying which sub-part of the target 2D array to be transmitted in a data transfer performed in response to a data transfer instruction. As the data element size decreases, this means a larger number of data elements can be packed into a register of a given size, thus supporting a 2D array with a larger dimension in the first direction (horizontal / vertical) corresponding to the width of the register. By increasing the size of the immediate value as the element size decreases, this allows for the selection of a larger number of sub-parts of the target 2D array, enabling the 2D array to be scaled in a second dimension in the opposite vertical / horizontal direction in a manner comparable to scaling in the first direction. By using encoding of the immediate value with a variable length, a smaller number of bits are used to encode the immediate value when the data element size is larger compared to when the data element size is smaller. This frees up some extra bits that can be used to encode other parameters at larger element sizes.
[0045] In one example, a 2D array register storage device may include a specific number NR Each vector register includes a specific number of bits (MVL, indicating the “vector length” of a single vector register). Implementing the 2D array register storage device as a set of vector registers simplifies the microarchitecture implementation of the processor, as the techniques used to provide vector registers for storing 1D data arrays as vectors can be reused to implement a 2D array register storage device. For example, a single 2D data array can be represented within a set of vector registers, where each vector register in the set stores a different horizontal (or vertical) group of elements for the 2D array, and the set of vector registers as a whole stores multiple such groups of elements to form a 2D array.
[0046] In some implementations, the ISA, supported by processing and instruction decoding circuitry, can support variable vector length (MVL) vector registers for 2D array register storage devices. This allows microarchitecture designers to vary the size of registers used in a given microarchitecture processor implementation based on design preferences, such as prioritizing higher performance or higher energy efficiency. For example, the ISA can support MVLs from minimum vector length... min Extending to the maximum vector length MVL max The range of vector lengths.
[0047] To simplify software development, it can be useful to design an Interface Separator (ISA) that allows program code to operate correctly on a range of processors using different vector lengths (MVLs) without requiring any modifications to the code to accommodate such differences in vector length. This property can be described as the program code being vector length independent. For example, an ISA could support registers indicating the vector length implemented on the current platform, which may be static for a given implementation but can vary between processor implementations, and the program code could reference these registers while controlling program code loops to change how much data is processed per loop iteration based on the implemented vector length (MVL). Thus, a program with a given amount of data to process can use fewer loop iterations on a microarchitecture implementing a longer vector length than on a microarchitecture implementing a shorter length, but in both cases performs the same functional processing operations to produce the same computational results (albeit with different performance levels).
[0048] An immediate value can indicate which sub-part of the 2D array to transmit. Since the number of elements that can fit in a vector register increases with the vector length MVL, it might be conceivable (to allow for similar scaling in other dimensions of the 2D array) to provide sufficient bits to the immediate value to distinguish it from the maximum vector length MVL. max The number of elements that can be stored in a vector register corresponds to the number of vector registers.
[0049] However, the inventors recognized that in practice, if the number of different codes for immediate values is greater than MVL... min / E (with minimum vector length MVL supported by ISA) min If the number of elements in the vector register is specified, then this means the program code will not be vector length independent, because specifying a value greater than MVL... min The / E indexing instruction cannot be used to implement the minimum vector length MVL. min It operates correctly on the microarchitecture. Therefore, in an ISA designed for vector length-independent computational architectures, it is not worthwhile to spend extra bits in instruction encoding to provide a large immediate value. By limiting the number of bits in the immediate value encoding, the number of different encodings is made less than or equal to MVL. min / E frees up the bit space for encoding other parameters and improves support for vector length independence.
[0050] Of course, if the above data transmission instructions are implemented in an ISA where vector length independence is not a priority, then larger values of immediate values can still be supported.
[0051] In some examples, the index value generated based on the base address value and immediate value of the register addressing information can be a unique register identification information item used to select the target portion of the register storage device to which data transfer is to be performed. For example, the index value can specify the register identifier of each vector register in the aforementioned 2D array register storage device. In this method, although the vector register group can be viewed as a whole to form a 2D data array (such as a matrix), the instruction can reference the element group by specifying a specific register identifier of the vector register used to store a single horizontal / vertical element group of the array.
[0052] However, certain programming techniques require handling multiple 2D arrays, rather than a single horizontal / vertical group of elements. Therefore, another approach is to logically divide the 2D array register storage into at least two array storage regions, each storing a corresponding 2D array. In addition to index values, register addressing information can also include an array identifier that identifies the selected array storage region of the 2D array register storage. In this case, the index value can identify which sub-part of the selected array storage region is the target portion of the register storage. Therefore, a data transfer instruction can specify the array ID of the array to be accessed for data transfer, and the index value defined using a base address register and an immediate value can be used to select a single horizontal / vertical group of elements from that array. This approach allows software to more easily define a program loop that iterates over each horizontal / vertical group of elements in the array to transfer the 2D array to / from the register storage.
[0053] In some specific implementations, the division of a 2D array register storage device into array storage regions can be fixed, such that a given array identifier always corresponds to a specific fixed portion of the 2D array register storage device. For example, when a 2D array register storage device is implemented using a set of vector registers as discussed above, each array storage region can correspond to a fixed block of vector registers.
[0054] However, in the specific implementations discussing above that support variable data element sizes, using a variable mapping that depends on the current data element size can be useful for partitioning a 2D array register memory into array memory regions. The processing circuitry can identify which portion of the 2D array register memory corresponds to a given value of the array identifier based on the variable mapping that depends on the current data element size E specified for the data transfer operation. This can help improve performance by increasing the utilization efficiency of the available register capacity implemented in the hardware.
[0055] As described above, when the data element size E is variable, this means that a single register can store a variable number of data elements. However, it might be desirable for the second dimension of the array to scale in a similar way, such that if a larger number of elements are packed into a vector register (representing the horizontal or vertical direction), the array also spans a larger number of vector registers (representing the other dimension of the array in the horizontal / vertical direction). If a larger number of vector registers are allocated to represent a single 2D array structure, this means that fewer 2D arrays can be accommodated in total within the available register storage capacity of the 2D array register storage device as a whole. On the other hand, as the data element size becomes larger, each vector register can store fewer data elements in the first dimension of the array, thus requiring fewer vector registers to accommodate the other dimension of the array, allowing a larger number of different 2D arrays to be packed within the available hardware storage capacity. If a fixed mapping is used between array identifiers and array storage areas, each storage area would have to be large enough to store a 2D array with the smallest data element size, which would waste storage capacity when using larger element sizes. By using variable mapping between array identifiers and array storage areas as described above, the partitioning can be adjusted to make full use of the available register capacity. This can help improve performance because when more arrays can be loaded into register storage devices, the number of (slower) load / store instructions executed per compute instruction can be reduced.
[0056] In one example, a 2D array register storage device can be logically divided into a specific number N. A There are N array storage areas, and N A It can vary according to the current data element size E, where N AThis relationship increases with increasing E. This can be considered counterintuitive because, typically (in the case of vector processing), the number of partitions is expected to decrease as the data element size increases. However, in the case of 2D array processing, although the number of elements packed into a single register in the first dimension decreases as the element size E increases, in the second dimension where elements are striped across vector registers, each element requires a single vector register (regardless of its element size). Therefore, the number of vector registers used for a single 2D array in the second dimension actually decreases with increasing element size. Thus, the total number of array storage regions (N) that can be packed into a given amount of physical storage... A It can increase as the size of the element increases.
[0057] Because the array storage area distinguished by smaller element sizes is less than that distinguished by larger element sizes, the array identifier encoded by the data transfer instruction can also have a variable number of bits depending on the current element size E. However, unlike the relationship between immediate values and the current data element size discussed earlier, the number of bits required for the array identifier can have an inverse relationship with the current data element size E. The array identifier can have more bits when the data element size is larger than when it is smaller, just as the immediate value can have more bits when the data element size is smaller than when it is larger.
[0058] Therefore, while some implementations of data transfer instructions can utilize two distinct non-shared fields within the instruction code to encode the array identifier and immediate value, a particularly efficient encoding method is to encode both the array identifier and immediate value using a shared portion of the bits in the instruction code of the data transfer instruction. For each given position within this shared portion, the instruction decoding circuitry varies depending on the current data element size E specified for the data transfer instruction, regardless of whether the given position is interpreted as indicating part of the array identifier or part of the immediate value. This helps reduce the total number of bits required to represent both the array identifier and the immediate value, thereby freeing up additional bits in the instruction code for other purposes. This can be highly valuable in ISA design, as the encoding space is typically very limited.
[0059] In some examples, the total number of bits used to encode the array identifier and immediate value in the instruction encoding of the data transfer instruction can be constant, regardless of the current data element size E.
[0060] In some examples, a data transfer instruction can be a load / store instruction that specifies register addressing information and memory addressing information for identifying the target portion of memory. For this instruction, the data transfer operation includes transferring data between the target portion of the register storage device and the target portion of the memory. In this case, the memory addressing information can be defined according to any known memory addressing mode (e.g., using a base register and an offset register, or using a base register and an immediate value to define the memory address to be accessed).
[0061] Furthermore, the data transfer instruction can be a register move instruction specifying register addressing information and additional register addressing information for identifying another part of the register storage device, and the data transfer operation can include transferring data between a target portion of the register storage device and another portion of the register storage device. In this case, although the target portion of the register storage device can be identified using a base register identifier as described above, the additional addressing information does not need to include the base register identifier. For example, the additional addressing information can simply be a register identifier that directly specifies the register to be accessed as another part of the register storage device. For example, in the previously mentioned example where the target portion of the register storage device is part of a 2D array register storage device, the other part of the register storage device could be a vector register.
[0062] Therefore, data transfer instructions can be used to transfer data between register storage devices and memory, or between different parts of a register storage device. Some ISAs may only support one of the load / store instructions and register move instructions using the base register identifier and immediate value as part of the register addressing information (where the other type of instruction does not use addressing based on the base register identifier and immediate value). Other ISAs may support both load / store instructions and register move instructions using register addressing information including the base register identifier and immediate value.
[0063] It should be understood that data transfer instructions, including register addressing information containing a base register identifier and an immediate value, are not necessarily the only type of data transfer instructions supported in the ISA implemented by instruction decoding and processing circuitry. Other types of data transfer instructions may also exist that do not use a base register identifier and an immediate value to define an index for selecting a portion of the register memory to be accessed during the data transfer.
[0064] The base register for the register addressing information identifier can be a scalar register. A scalar register is a register designed to store a single data value (unlike a vector register, which can be divided into multiple independent data elements, each representing a different data value).
[0065] In some specific implementations, scalar registers may be selected from a specific scalar register pool available for instruction selection. For example, a scalar computation instruction may have a K-bit scalar register field, which is used to designate a specific scalar register that is to store an operand for the instruction or a result of the instruction as a source or destination register of the instruction. In the case of a K-bit scalar register field, this may allow the system to support 2 K different scalar registers.
[0066] In some specific implementations, if the number of different scalar registers supported in the ISA is 2 K , the number of bits of the base address register field for register addressing information may be K bits, such that any one of the supported scalar registers can be selected as the base address register.
[0067] However, in other examples, a data transfer instruction may use an L-bit scalar register field to designate the base address register, where L<K, such that at least one scalar register that can be designated as a source or destination register for at least one scalar computation instruction cannot be designated as the base address register for the register addressing information of the data transfer instruction. That is, the base address register field is a compressed field that is shorter than the number of bits that would otherwise be required to allow selection of any scalar register supported in the architecture. This can help free up bits in the instruction encoding for other purposes. In practice, restricting the base address register to be selected from a limited subset of the scalar registers may be sufficient to handle desired use cases for applications such as matrix processing.
[0068] The instruction decoding circuitry can support 2D array generation computation instructions. In response to these instructions, the instruction decoding circuitry controls the processing circuitry to perform computational operations to generate a 2D array of result values to be written to the 2D array register storage device. The 2D result value array can be generated in response to a single instance of the 2D array generation computation instruction. In systems that can support generating 2D value arrays in response to a single instruction, the processing throughput can be significantly greater than that of implementations that process a single 1D data array at a time using vector processing. As discussed above, this can be particularly useful for applications such as machine learning and signal processing. For example, the computational operation can be a matrix multiplication operation, where the input operands for the computation are 2D data arrays, and the result is a 2D array representing the result of multiplying the matrices represented by the 2D array operands. However, in other examples, the computational operation may include an outer product operation performed on a first vector operand and a second vector operand to generate a 2D result value array. Implementing outer product operations in hardware can be simpler than full matrix multiplication. Accumulating the results of a series of outer product operations can produce a result equivalent to matrix multiplication. Therefore, the computation instruction can be an outer product and accumulator instruction that, in addition to generating the outer product of two vectors, adds the resulting element to the accumulator's 2D element array (e.g., stored in a region of the 2D array memory area of the aforementioned register memory device). Data transfer instructions of the type discussed above are particularly useful for systems that support such 2D array generation computation instructions because they allow efficient access to the individual horizontal / vertical element groups of the 2D array registers. The encoding of the data transfer instructions allows such access to be expanded and scheduled by the compiler while still dynamically adapting to the scalable array size.
[0069] The techniques discussed above can be implemented within a data processing device that has hardware circuitry for implementing the instruction decoder and the processing circuitry discussed above.
[0070] However, the same technique can also be implemented within a computer program that executes on a host data processing device to provide an instruction execution environment for executing target code. Such a computer program can control the host data processing device to simulate the architectural environment to be provided on the target data processing device, which actually supports target code according to a specific ISA, even if the host data processing device itself does not support that architecture. For example, such a simulation program is useful when executing legacy code written for one ISA on a host processor that supports different ISAs. Furthermore, simulation can allow software development for a newer version of the ISA to begin before the processing hardware supporting the new architecture version is ready, because execution of the software on the simulated execution environment allows software testing to be performed in parallel with ongoing development of the hardware device supporting the new architecture. The simulation program can be stored on a storage medium, which can be a non-transitory storage medium.
[0071] Therefore, a computer program may include instruction decoding logic that decodes program instructions of the target code to control the host data processing device to perform data processing in response to the program instructions (e.g., mapping each instruction in the target code to a series of one or more instructions in the host's native instruction set to achieve equivalent functionality). Furthermore, the computer program may have register emulation logic that maintains data structures in the host storage of the host data processing device (e.g., in the host's registers or memory) to emulate the register storage of the target ISA being emulated (which is originally expected to be provided in the hardware of the processor that actually supports the target ISA).
[0072] In such implementations, the instruction decoding logic can support data transfer instructions with the same register addressing information as discussed above. However, in this case, the reference to the register storage device based on the register addressing information is mapped from the register emulation data structure to the corresponding location of the register emulation data structure stored in the host device. Therefore, the base register identifier and immediate value can be used to identify which part of the emulation register to access in the data transfer for the data transfer instruction whose execution on the target processing device is being emulated on the host device.
[0073] Figure 1 An example of a data processing apparatus 20 is illustrated schematically. The data processing apparatus has a processing pipeline 24 comprising multiple pipeline stages. In this example, the pipeline includes: a fetch stage 26 for fetching instructions from an instruction cache 28; a decode stage (instruction decoding circuitry) 30 for decoding the fetched program instructions to generate micro-operations to be processed by the remaining stages of the pipeline; an issue stage 32 for checking if the operands required for the micro-operation are available in a register file 34, and issuing the micro-operation for execution once the operands required for a given micro-operation are available; an execution stage 36 (processing circuitry) for performing a data processing operation corresponding to the micro-operation by processing the operands read from the register file 34 to generate a result value; and a write-back stage 38 for writing the processed result back to the register file 34. It should be understood that this is merely one example of a possible pipeline architecture, and other systems may have additional stages or different stage configurations. For example, in an out-of-order processor, a register renaming level may be included, which is used to map the architecture registers specified by program instructions or micro-operations to physical register specifiers in the identifier register file 34.
[0074] Execution level 36 includes multiple processing units for performing different types of processing operations. For example, the execution units may include a scalar arithmetic / logic unit (ALU) 40 for performing arithmetic or logical operations on scalar operands read from register 34; a floating-point unit 42 for operating on floating-point values; a branching unit 44 for evaluating the results of branching operations and adjusting the program counter representing the current execution point accordingly; a matrix processing unit 46 for matrix processing (which will be discussed in more detail below); and a load / store unit 48 for performing load / store operations to access data in memory systems 50, 52, and 54.
[0075] In this example, the memory system includes a Level 1 data cache 50, a shared Level 2 cache 52, and main system memory 54. It should be understood that this is merely one example of a possible memory hierarchy, and other cache arrangements are also possible. The specific type of processing units 40 to 48 shown in execution level 36 is only one example, and other implementations may have a different set of processing units or may include multiple instances of the same type of processing units, allowing multiple micro-operations of the same type to be processed in parallel. It should be understood that... Figure 1 This is merely a simplified representation of some components of a possible processor pipeline architecture, and the processor may include many other elements not shown for the sake of simplicity.
[0076] In some specific implementations, the data processing device 20 may be a multiprocessor device, which includes multiple CPUs (central processing units or processor cores) 60, each CPU having features specific to... Figure 1 The processing pipeline 24 is similar to the processing pipeline shown in one of the CPUs in CPU 60. The device 20 may also include at least one graphics processing unit (GPU) 62 and / or other master devices 64, which can communicate with each other and with the CPU via interconnects 66 for accessing memory 54.
[0077] One approach to supporting matrix processing operations is to break down the individual multiplications of a given matrix processing operation into separate scalar integer or floating-point instructions, which can be processed on a given CPU 60's processing pipeline 24. However, this can be relatively slow.
[0078] Another approach to accelerate matrix processing could be to provide a hardware accelerator with dedicated hardware, designed for handling matrix operations, as one of the devices 64 connected to interconnect 66. To interact with such a hardware accelerator, CPU 24 would use load / store unit 48 to execute load / store instructions to write configuration data to memory 54 (or to a register mapped to memory within the hardware accelerator). This configuration data defines the matrix operands to be read from memory by the hardware accelerator and the processing operations to be applied to the operands. Once the hardware accelerator has performed the matrix processing, CPU 60 can read back the result of the matrix processing from the hardware accelerator using a load instruction specifying the address of a register mapped to within the hardware accelerator. While this approach may be faster than using integer operations within the pipeline, there may still be overhead associated with transferring information between the general-purpose processor 60 and the hardware accelerator 64 using the load / store mechanism. The hardware accelerator approach can also present challenges when different virtual machines running on the same processing system need to share access to the hardware accelerator. Therefore, this approach may not scale well in virtualization implementations with multiple virtual machines.
[0079] Therefore, as Figure 1 As shown, matrix processing circuitry 46 can be provided within the regular processing pipeline 24 of a given CPU 60. This matrix processing circuitry can be controlled to perform matrix processing in response to computational program instructions decoded by the pipeline's decoding stage 30 (similar to using ALU 40 or floating-point unit 42 to control regular integer or floating-point arithmetic operations). This avoids the need to transfer data back and forth between the CPU 60 and the hardware accelerator, and makes it simpler to allow multiple different virtual machines to perform matrix operations.
[0080] Although Figure 1 A multiprocessor device 20 with several CPUs 60 is shown, but this is not necessary; the matrix processing circuitry 46 can also be implemented in a single-core system.
[0081] exist Figure 1 In the example, matrix processing functionality is provided within the CPU 60 itself.
[0082] Figures 2A to 2DA second example of a data processing apparatus is shown, wherein each CPU 60 does not have matrix processing capabilities on its own, but matrix processing is supported in a coprocessor 70 connected to the CPU 60 via interconnect 66. This method can be useful for reducing the hardware cost of implementing matrix processing capabilities because the hardware resources used to support matrix processing in the coprocessor 70 can be shared among the CPUs 60. To allow the coprocessor 70 to access memory using address translation data corresponding to the address translation data used by the CPU 60 itself, a memory management unit (MMU) 72 can be provided as a separate block shared between the CPUs 60 and the coprocessor 70 (e.g., ...). Figure 2A (as shown), or each CPU 60 and coprocessor 70 has its own MMU 72 (as shown). Figure 2B (As shown), the MMU can load address translation data from a common set of page tables in memory. Note that, although not shown in [the original text] for simplicity... Figure 1 As shown, but in this example, CPU 60 may also have an internal MMU 72. Furthermore, in some examples, the address translation for coprocessor load / store operations can be performed by the MMU in CPU 60, and the resulting physical address can be passed to coprocessor 70 along with the load / store instruction. MMU 72 translates the virtual address, identified by memory addressing information specified by the program instruction, into a physical address identifying the location to be accessed in memory 54. MMU 72 may also implement permission checks to verify whether program code is permitted to access a given memory address.
[0083] Figure 2C It shows Figure 2A / Figure 2B CPU 60 in the example. Indicated by the same reference numerals as... Figure 1 The same element in the example. Figure 1 The scalar execution units 40, 42, and 44 shown are collectively referred to as scalar processing circuits, which perform operations on scalar operands stored in scalar register 80. Execution stage 36 also includes vector processing circuitry 76, which performs vector processing operations on vector operands stored in vector register 82. Although Figure 1 Vector processing circuitry 76 and vector register 82 are not shown in the figure, but vector processing circuitry and vector register may also be provided in this example.
[0084] exist Figures 2A to 2D In the example, the processing unit supports processing of the program in either a non-matrix processing mode or a matrix processing mode. Instructions processed in the non-matrix processing mode are issued by the issue circuit 85 of the issue stage 32 of the CPU 60 for execution by the processing unit in the execution stage 36.
[0085] However, instructions processed in matrix processing mode are forwarded by the coprocessor interface 87 of the issue stage 32 of CPU 60 to the queue manager 84 in coprocessor 70 (e.g., Figure 2D (As shown). Queue manager 84 passes instructions to the pipeline within coprocessor 70, which is similar to CPU 60, including instruction decoding circuitry 30, issue circuitry 32, execution stage 36, and write-back circuitry 38. However, compared to CPU 60, the pipeline in coprocessor 70 can support a different subset of instructions for the ISA. For example, coprocessor 70 can support a more limited instruction set than CPU 60 to limit the complexity of the coprocessor while supporting operations expected to be useful for matrix processing.
[0086] In this example, CPU 60 does not support any matrix processing computation instructions; instead, matrix processing computation instructions are supported by the matrix processing execution unit 86 in coprocessor 70. The choice of whether a program is currently executing in matrix processing mode or non-matrix processing mode can be made based on specific mode control instructions that enable / disable matrix processing mode.
[0087] To support matrix processing, coprocessor 70 has a matrix register (2D array register) 88 designated for storing 2D data arrays (matrices). Data transfer instructions that transfer portions of the matrix between matrix register 88 and memory 54, or between matrix register 88 and other types of registers (such as vector register 82), are limited to execution in matrix processing mode. Although Figure 1 Not shown, but in an implementation where the CPU itself supports matrix processing, the CPU 60 may similarly have a matrix register 88 within its register 34.
[0088] The vector length of vector register 82 in coprocessor 70 may differ from the vector length of vector register 82 in CPU 60. Since matrix processing operations are more efficient with larger vector lengths (to achieve greater data throughput), in some cases, processor designers may want to select a vector length VL2 for vector register 82 (and the vector register for matrix register 88 used in the coprocessor) that is longer than the vector length VL1 used for vector register 82 in CPU 60. However, the ISA can support variable vector lengths VL1 and VL2 for both non-matrix processing modes and matrix processing modes, where VL1 and VL2 can be selected from a range of vector lengths supported by the ISA for a given hardware implementation (in some cases, the range available as VL1 may differ from the range available as VL2, although the ranges may overlap, and therefore a particular implementation may choose VL1 = VL2). Vector control registers (ZCR, ZCR') 81 and 81' may be provided in CPU 60 to indicate the corresponding vector lengths VL1 and VL2 used in non-matrix processing mode and matrix processing mode, respectively.
[0089] The program code defined by the ISA can be implemented in two specific hardware components. Figure 1 Matrix processing implemented within CPU 60, or Figures 2A to 2D Running in an equivalent manner on a coprocessor example. If on, for example... Figure 1 In the specific implementation shown, the mode selection instruction can be considered a no-operation instruction, and the vector length implemented for any vector register can be the same in both modes (because the same register is used in both modes). If in Figures 2A to 2DIn the specific implementation shown, the mode selection instruction can signal that the instruction should be forwarded to the coprocessor for execution, and supporting different vector lengths VL1, VL2 in the two modes can be useful. Either way, from a software developer's perspective, matrix processing is executed by matrix processing logic 46, 86 in response to regular CPU instructions (calculation / arithmetic instructions), which define register-to-register operations that act on operands stored in registers and produce results written back to registers. This makes the control of matrix processing far more direct than using a hardware processor based on load / store instruction control to execute the specific implementation of matrix processing (which might require a dedicated software driver to implement matrix processing). Of course, even in systems including CPU 60 or coprocessors with an ISA that supports register-to-register computation instructions for implementing matrix processing, a dedicated hardware accelerator can still be provided as a device 64 accessible via interconnect 66 using load / store instructions to provide additional support for matrix processing forms not supported in the ISA's register-to-register computation instructions. However, such a hardware accelerator is not necessary.
[0090] Figure 3 An example of matrix multiplication between a first matrix A and a second matrix B to produce a result matrix C is shown. In this example, the matrices are full square matrices of 4×4 dimensions for a specific example, although this is not necessary. For the matrix multiplication operation, C = AB, where A is an m×n matrix and B is an n×p matrix, then C is an m×p matrix, where the given element at position (i,j) in C corresponds to the sum of the products of pairwise multiplication of the elements of the i-th row of matrix A with the elements of the j-th column of matrix B, such that the given element c of the result matrix... ij Corresponding to
[0091] like Figure 3 As shown on the right, an equivalent result can be generated by performing a series of outer product operations. The outer product operation takes the first vector operand u = (u1, u2, ..., u...). m ) and the second vector operand v = (v1, v2, ..., v n Each vector operand consists of a one-dimensional array of elements, which are combined to form a two-dimensional result matrix W, where Therefore, each element of the outer product result matrix is derived from a single multiplication of an element of the input vector operand with an element of the second vector operand. For example... Figure 3As shown, if the elements of matrix A are read column-wise (instead of row-wise as in matrix multiplication as described above) and the elements of the second matrix B are read row-wise (instead of column-wise as in matrix multiplication), then by performing an outer product operation on the i-th column of matrix A and the i-th row of matrix B, and accumulating the results for i = 1 to n, the result is equivalent to the result of the matrix multiplication operation. Breaking down matrix multiplication into separate outer product operations can be useful for reducing the number of products and additions that need to be calculated in response to a single program instruction. This is a faster operation and can simplify the hardware design when designing circuit logic whose timing matches the pipelined timing of other operations within the processor. In any case, the outer product itself is also an important operation for a particular algorithm and can therefore be used for purposes other than implementing matrix multiplication.
[0092] Therefore, in some examples, the matrix processing units 46 and 88 of the processing circuit (in) Figure 1 and Figures 2A to 2D (In any of the examples) may include, for example Figure 4 The diagram shows an outer product engine for performing outer product operations. The outer product engine takes a first vector operand opa associated with a first predicate value Pa and a second vector operand opb associated with a second predicate value Pb as input. The output of the outer product engine is a 2D array (matrix) C'. The resulting matrix can be stored in a 2D array register storage device (e.g., provided for storing 2D arrays). Figure 2D The matrix register 88 shown is in Figure 1 (In the example, this will also be provided in register 34). Previous values stored in each element C of the resulting array storage device can also be used as input to the operation to perform outer product and accumulation operations, for which a given element C'[i,j] is determined according to... Figure 4 The equation shown is generated where Pa[i].opa[i] indicates that element i of opa is asserted by element i of Pa, and Pb[j].opb[j] indicates that element j of opb is asserted by element j of Pa. For outer product instructions that implement merge assertions, when predicate elements Pa[i] or Pb[j] are indicated as inactive, the corresponding element C'[i,j] retains its previous value. Zero-reset assertions can also be implemented, where the element C'[i,j] corresponding to the inactive predicate element Pa[i] or Pb[j] in the resulting matrix is set to 0, overwriting the previous value C[i,j] for that element's position. For example, assertions can be useful when matrix processing reaches the edge of the matrix structure and the number of elements to be processed is insufficient to fill the entire matrix supported in the hardware. Figure 4The outer product and accumulation operations shown are useful because they simplify the specific implementation of hardware support for matrix multiplication, and accumulation means that it is not necessary to store each outer product result separately and then add them together as the final step. However, Figure 4 The outer product engine shown is merely an example, and in other specific implementations of matrix processing engines 46 and 88, support will be provided for performing a complete matrix processing operation in a single instruction. However, as discussed above, outer product operations can be more easily implemented in practice.
[0093] Figure 5 An example of architecture register 34 for a CPU 60 or coprocessor supporting matrix operations is shown. Architecture registers (as defined in the ISA) may include a set of scalar integer registers that act as general-purpose registers for ALU operations performed by ALU 40 or for other instructions processed in the pipeline. For example, a specific number of general-purpose registers may be provided, such as registers X0 through X30 in this example (the 32nd code of the scalar register field may not correspond to a register provided in the hardware, because, for example, the code may be assumed by default to indicate a zero value, or may be used to indicate a register of a special type that is not a general-purpose register). Scalar registers of different sizes mapped to the same physical memory can be accessed. For example, register labels X0 through X30 may refer to 64-bit registers, but the same registers may also be accessed as 32-bit registers (e.g., using the lower 32 bits of each 64-bit register provided in the hardware), in which case register labels W0 through W30 may be used in the assembler code to reference the same registers.
[0094] Furthermore, the architecture registers available for selection by program instructions in the ISA supported by decoder 30 may include a specific number of vector registers 82 (labeled Z0 to Z31 in this example). Of course, providing... Figure 5 The number of scalar / vector registers shown is not required, and other examples can provide different numbers of registers that can be specified by program instructions. Each vector register can store vector operands comprising a variable number of data elements, where each data element can represent an independent data value. In response to vector processing (SIMD) instructions, processing circuitry can perform vector processing on the vector operands stored in the registers to produce a result. For example, vector processing can include channel-by-channel operations, where a corresponding operation is performed on each channel of the elements in one or more operand vectors to produce a corresponding result for the elements of a result vector. When performing vector processing or SIMD processing, each vector register can have a specific vector length VL, where the vector length refers to the number of bits in a given vector register (e.g., the vector length VL for a vector instruction can be a reference). Figures 2A to 2DThe previously mentioned first vector length VL1). The vector length VL used in vector processing mode can be fixed or variable for a given hardware implementation. The ISA supported by CPU 60 can support variable vector lengths, allowing different processor implementations to choose to implement vector registers of different sizes. However, the ISA can be vector length-independent, allowing instructions to be designed so that the code can run correctly regardless of the specific vector length implemented on the given CPU executing the program. For example, a control register (e.g., ZCR 81) may exist, storing a value indicating a specific vector length VL for vector processing instructions. This register can be read by software to control a loop that iterates by processing a specific number of elements, allowing implementations with longer vector lengths to process a given number of elements in fewer loop iterations than implementations with shorter vector lengths.
[0095] Vector registers Z0 to Z31 can also serve as operand registers for storing vector operands, which are then used for outer product operations performed by the outer product engines 48 and 86 (see above). Figure 4 The vector register provides input (as discussed above). When the vector register is used to provide input for outer product operations or other matrix operations, the vector register has a matrix vector length MVL, which can be the same as the vector length VL used for vector operations, or it can be a different vector length (e.g., VL2 instead of VL1, as discussed above for modal functionality in the implementation using coprocessor 70). By providing architectural support at the ISA level to support different vector lengths for SIMD operations and matrix operations, this provides processor micro-designers with more flexibility to choose different physical implementations, including the option to implement matrix operations using coprocessor 70 as discussed above. The ISA can support mode selection instructions that can select whether the processor operates in matrix processing mode or non-matrix processing mode, and this can be useful for configuring the CPU to offload processing to the coprocessor (if implemented). In this case, among other functions, the mode selection instructions can also trigger a switch of the implemented current vector length, selecting one of VL and MVL according to the current mode. Vector control registers 81, 81' can be provided to indicate the specific vector lengths used for VL and MVL for the corresponding modes.
[0096] Therefore, generally speaking, the vector length MVL discussed in the following examples is the vector length used in matrix processing mode, which may or may not be the same as the vector length VL used in other modes. The control register can store a value indicating the specific implementation of the matrix vector length MVL for the current processor, making this value available to software for controlling program loops.
[0097] like Figure 5 As shown, the architecture registers also include a specific number N A Array registers 88, ZA0 to ZA(N) A -1). Each array register can be viewed as a set of register storage devices used to store a single 2D data array (e.g., the result of an outer product operation as discussed above). However, outer product operations are not the only operations that can be performed using array registers. Array registers can also be used to store arrays when performing row / column transpose of a matrix structure in memory. When a program instruction references an array register 88, it is referenced as a single entity using the array identifier ZAi, but some types of instructions (e.g., data transfer instructions) can also select a sub-section of the array by defining an index value that selects a portion of the array (e.g., a horizontal / vertical group of elements).
[0098] Figure 5 This shows an architectural view of the array registers as seen by software. However, as... Figure 6 As shown, in practice, the physical implementation of the register storage device corresponding to the array register can include a specific number N. R One vector register, ZAR0 to ZAR(N) R -1). The vector register ZAR forming the array register storage device 88 can be a different set of registers than the vector registers Z0 to Z31 used for SIMD processing and the vector input to matrix processing. Each vector register in the vector register ZAR can have a matrix vector length MVL, so each vector register ZAR can store a 1D vector with length MVL, which can be logically divided into a variable number of data elements. For example, if MVL is 512 bits, this could be, for example, a set of 64 8-bit elements, 32 16-bit elements, 16 32-bit elements, 8 64-bit elements, or 4 128-bit elements. It should be understood that not all of these options need to be supported in a given specific implementation. By supporting variable element sizes, this provides flexibility for processing computations involving data structures of varying precision. To represent a 2D data array, the vector register sets ZAR0 to ZAR(N) are... R -1) can be logically considered as the array registers assigned from ZA0 to ZA(N) A -1) identifies a single entity of a given array register, such that the 2D array is formed by elements extending within a single vector register corresponding to one dimension of the array and elements striped across multiple vector registers in another dimension of the array.
[0099] Implementing matrix processing circuits 46 and 86 to store a square array of data in array register ZA can be useful, although not necessary, where the number of elements in the horizontal direction is equal to the number of elements in the vertical direction. Supporting reading / writing to array register 88 in the horizontal or vertical direction helps support on-the-fly transposition of the matrix, where the row / column dimensions of the matrix structure in memory can be switched when transferring the matrix between array register 88 and memory 54. Machine learning algorithms and other applications that process matrix data often represent data stored in memory in either a row-major or column-major format as discussed above, and some algorithms may require processing data in a mixed format. In the prior art, if some processing requires input data to be represented in a format different from its layout in memory, this might require some kind of rearrangement of the data stored in memory using multiple load / store instructions or vector rearrangement instructions before the data can be processed in matrix processing operations to ensure format consistency. These operations can be slow. By providing support for writing / reading data to 2D array registers in the horizontal or vertical direction, this allows data loaded from memory in one direction (e.g., row-by-row) to be written back to memory in the opposite direction (e.g., column-by-column), which can be faster than transferring data between memory and vector registers using multiple aggregate / scatter load / store or reorganization operations.
[0100] Therefore, when the array register ZA 88 is implemented as a set of vector registers ZAR, each storing a horizontal / vertical group of elements corresponding to a 2D array, it may be desirable for the array to span multiple vector registers to ensure that the square matrix constraint is satisfied, with the number of vector registers equal to the number of data elements contained in a single vector register. When variable data element sizes are supported as discussed above, the number of data elements that can be contained in a single vector register is variable, and therefore the number of vector registers grouped together to form a single array register ZA can also be variable.
[0101] One approach is for each array register ZA (accessible by specifying the array register ID as a schema register within an instruction) to correspond to a specific number of vector registers, corresponding to the maximum number of data elements that can fit into a single vector register at the smallest supported data element size. However, in the case of fixed mapping of array registers to physical vector register storage, some vector registers in the fixed vector register group mapped to a specific array register identifier will actually be wasted as the array dimension shrinks when the data element size is large and fewer data elements fit into a single vector register.
[0102] Therefore, a more efficient implementation could be the number of array registers N. AThe physical register storage units ZAR0 to ZAR(NR-1) used to implement the array register ZA can be logically divided into groups of different sizes according to the data element size E, so as to make full use of the available physical storage unit, regardless of the data element size. This means that given array register identifiers ZA0 to ZA(NR-1), the physical register storage units ZAR0 to ZAR(NR-1) can be dynamically adjusted according to the data element size E. A -1) The actual physical storage area referenced is not always the same, but varies depending on the current data element size E used for a given operation.
[0103] Figures 7 to 11 This demonstrates the ability to use array registers ZA0 to ZA(N) A -1) The architecture register specifier is used to classify and reference different ways of physical storage devices. Figures 7 to 11 In this example, the matrix vector length (MVL) is assumed to be 512 bits. However, it should be understood that other implementations may use different matrix vector lengths, and in such cases, the specific number of supported array registers (ZA) or the specific grouping of vector registers (ZAR) mapped to a given array register may vary. Additionally, this example assumes a total of 64 vector registers (ZAR) are provided for array (matrix) register 88, but this may also vary in other implementations of the ISA.
[0104] Figure 7 This illustrates the partitioning of the array register storage when the current data element size E is 32 bits. In this case, with a 512-bit vector register, 16 elements, each 32 bits in size, can be stored in a single vector register. Therefore, to represent a square 2D array, the 16 vector registers can be grouped together to represent the array register identifiers ZA0 to ZA(N). A -1) identifies a single 16×16 2D array. For example, for array register IDZA0, which is mapped to vector registers ZAR0 to ZAR15, these vector registers can store the 0th to 15th horizontal element groups of array ZA0 respectively, and the i-th vertical element group is striped across the element set at position i in each of the vector registers ZAR0 to ZAR15 (alternatively, other implementations may arrange the vertical element groups in a single vector register ZAR and stripe the horizontal element groups across the corresponding element positions of multiple vector registers ZAR).
[0105] Since 16 vector registers ZR are sufficient to represent a 16×16 block of 32-bit elements, and there are a total of 64 vector registers, this means that four separate 16×16 arrays can be stored in the 64 available vector registers. Therefore, for a 32-bit element size, the number of supported array registers N is... AThe value is 4. That is, the physical storage device is divided into 16 vector registers in 4 groups, marked with array identifiers ZA0 to ZA3. These identifiers can be identified by data transfer instructions that transfer data between the array storage registers and the memory.
[0106] like Figure 7 As shown on the left, since four separate 2D arrays ZA0 to ZA3 can be stored simultaneously in array register 88, this allows some of the load / store overhead associated with processing a given amount of matrix data to be amortized. For example, four different output blocks ZA0 to ZA3 can be generated from different combinations of the four vector operands (e.g., as shown on the left). Figure 7 As shown, ZA0 is based on the outer product of opa0 and opb0, ZA1 is based on the outer product of opa0 and opb1, ZA2 is based on the outer product of opa1 and opb0, and ZA3 is based on the outer product of opa1 and opb1. This can be useful because matrix processing algorithms can reuse the same input vector in combination with many other input vectors, thus enabling the computation of multiple outer product results from the same instance of the input vector stored in the vector registers (one of Z0 to Z31). This allows sharing the loading overhead associated with the loaded vector across a large number of computational operations, thereby increasing the effective number of multiplications implemented per load. This can help improve performance compared to loading a pair of input operands opa and opb separately for each individual result block ZA.
[0107] Figure 8 This illustrates an alternative partitioning of the physical register storage when the current data element size E is 16 bits. This means that 32 elements are packed into a 512-bit vector register (MVL size in this example), and therefore the two groups ZAR0 to ZAR31 and ZAR32 to ZAR63 of the 32 vector registers are mapped to array identifiers ZA0 and ZA1, each array identifier representing a 32×32 block of 16-bit elements. Using this method, the array storage device can support performing two separate outer product operations based on the vector operands opa, opb0, and opb1 loaded in a single group in the vector registers, to generate two 32×32 blocks ZA0 and ZA1 based on the outer product of opa and opb0 and the outer product of opa and opb1, respectively. Therefore, with... Figure 7 In comparison, the number of elements within a single block is larger (32×32 instead of 16×16), but fewer blocks can be processed for a given set of loads.
[0108] Figure 9 Another configuration is shown where the data element size is 8 bits, and therefore 64 elements are packed into a single vector register, meaning that all 64 vector registers ZAR0 to ZAR63 are grouped together to form a single 2D array ZA0. Figure 9 The diagram illustrates performing a single outer product operation on vectors opa and opb to generate a 64×64 array ZA0 with 8-bit elements. However, in some specific implementations, the 8-bit element result may not be supported for computational operations, but may instead be limited to array load / store data transfer or register move data transfer instructions, which transfer data between array registers and memory or vector registers for transposing row / column directions relative to data structures in memory.
[0109] Similarly, Figure 10 and Figure 11 The partitioning of array storage devices for 64-bit and 128-bit data element sizes is shown respectively.
[0110] It should be understood that other matrix vector lengths MVL or other quantities N provided in the array storage device 88 can be used. R Each vector register performs a similar partitioning.
[0111] The outer product instruction executed by the control processing circuit can specify vector register identifiers, which indicate which vector registers Z0 to Z31 store the two vector operands used for the outer product operation, and can specify target array register identifiers ZA0 to ZA(N). A -1), which identifies the block to be updated using the result of the outer product operation. The processor's matrix processing hardware 48, 86 can determine which physical vector registers ZAR to be updated based on the outer product result based on the current data element size E and the specified array register identifier ZAi, depending on the variable mapping discussed above.
[0112] The ISA can also define array data transfer instructions for transferring a portion of a 2D array to or from a selected array register ZAi. To simplify the implementation of the hardware circuitry and reduce the amount of data that needs to be transferred for any single instruction, it is simpler to act on a single horizontal / vertical group of elements within the selected array register ZAi for a given data transfer instruction than to transfer the entire 2D array in a single instruction. This also helps support the just-in-time transpose functionality discussed earlier, as the instruction can select whether to read or write in the horizontal or vertical direction based on the parameters of the data transfer instruction. Therefore, in addition to the selected array register, the data transfer instruction can also identify an index that identifies which horizontal / vertical group of elements to transfer.
[0113] Figure 12An exemplary encoding of an array data transfer instruction is shown. In this example, the instruction is a storage instruction for transferring data from a 2D array register storage device ZA 88 to memory 54. An array data transfer instruction may also be provided, which is a load instruction for loading data from memory 54 to array register storage device 88, the load instruction being compatible with… Figure 12 The memory addressing information and register addressing information are specified in the same way as those for storage instructions.
[0114] Figure 12 The upper part shows an exemplary syntax for array data transfer instructions when written in assembly code, while Figure 12 The lower part shows the binary encoding of instructions with various bit fields assigned to represent different parameters specified in the assembly representation.
[0115] like Figure 12 As shown in the upper part, the data transfer instruction specifies multiple parameters, including:
[0116] ● Register addressing information (operands), used to identify the portion of the array register storage device 88 to be used for data transfer.
[0117] ● Memory addressing information (operands), which is used to identify the target area in memory from which data is to be loaded or to which data is to be stored.
[0118] ● Predicate operands provide predicate values for controlling data transfer, allowing some data elements in the array to be disabled for the element positions corresponding to inactive elements indicated by the predicate to prevent updates to memory (in the case of a store instruction) or to register storage (in the case of a load instruction). Two predicate values, Ph and Pv, exist respectively, corresponding to the horizontal and vertical groups of elements in the array.
[0119] Memory addressing operands can identify the address to be updated in memory based on any known addressing scheme. For example, memory addressing operands can include one or more register identifiers for scalar registers used to derive the address of a load / store operation and zero or more immediate values. For example, a first scalar register can provide the base address. The offset value can be represented by a value stored in a second scalar register, or by an immediate value directly encoded in the instruction code, wherein the offset is added to the value in the base register to generate the address for the data transfer. In some cases, memory addressing operands can also include additional operands for specifying other information about the addressing mode, such as an operand indicating whether the value in the base register is incremented before or after the address of the current load / store instruction is computed. Operands can also include parameters specifying a shift amount to be applied to the offset before the offset represented by the second register or the immediate value is added to the base register value. Generally, various memory addressing modes are known in the art, wherein any of these known addressing modes can be used to define memory addressing operands for array data transfer instructions.
[0120] For store instructions, the register addressing operands for array data transfer instructions are used to identify which portion of the array register storage device 88 should be transferred to memory (for load instructions, the register addressing operands will identify which portion of the array register storage device 88 is to be updated with the loaded data). The register addressing operands include an array identifier (ID) ZAi (or "zai" in the assembly representation used by software), where i represents the number of the specific architecture array registers ZA0 to ZA(NA-1) selected for the current load / store instruction. The register addressing operands also include a direction identifier d, which indicates whether the identified array register ZAi should be accessed horizontally or vertically. The register addressing operands also include an indication of an element size E, which can be selected from several different element sizes as discussed earlier, and is the current element size used for the current operation. Furthermore, the register addressing operands include a base address register Wx for generating a row / column index J and an immediate value #y, which indicates the location of the horizontal / vertical element group within the selected array register ZAi to which data is to be transferred. The base register identifier Wx identifies a scalar register that provides the base address value, which is added to the offset represented by the immediate value #y, encoded directly within the instruction encoding of the data transfer instruction, to generate the index J. In this example, to ensure that the index J is within the range of element positions supported for a given vector length MVL and element size E, the index value J is set to (the value in Wx + #y)MODULO(MVL / E). The modulo operation refers to determining the remainder when (the value in Wx + #y) is divided by (MVL / E). Although in practice, since both MVL and E are powers of 2, the modulo operation can be simply implemented by returning the lower-order bits of the sum, because if dim = MVL / E, then J is the least significant log2(dim) bit of (the value in Wx + #y). Using a combination of base registers and immediate values to represent row / column indices is useful for supporting software code that can scale to different dimensions of matrix structures and supports loop unrolling, which will be discussed further below.
[0121] In this example, the index value J is represented in the same way, regardless of whether the selected access direction of the array register ZAi is horizontal or vertical. The direction identifier d selects which specific elements in the vector register group ZAR corresponding to the selected array register ZAi are read / written. For example, if the direction identifier is horizontal, the transferred element is read from the J-th vector register ZAR in the group corresponding to ZAi (or, for a load instruction, the transferred element is written to that vector register), and if the direction identifier is vertical, the transferred element is read from the J-th element in each vector register of the vector register ZAR in the group corresponding to ZAi (or, for a load instruction, the transferred element is written to that J-th element) (or vice versa if the horizontal / vertical direction is transposed relative to the layout in the vector register ZAR).
[0122] like Figure 12 As shown in the lower part, the binary encoding of an instruction may include an opcode identifying the instruction as an array load / store data transfer instruction, and multiple fields corresponding to various parameters specified in the assembly representation of the instruction, as described above. For example, fields may be assigned to the instruction encoding to represent the direction identifier D, the current data element size E, the base register identifier Wx identifying the base register used to generate the row / column index of the register addressing operand, the predicate registers Ph and Pv used to provide horizontal and vertical predicate values, and various memory addressing operands.
[0123] In this example, the scalar register field Wx of the base register used to identify the register-addressed operand has a specific bit length L, which is less than the bit length K of the scalar register field used in at least one other instruction supported by the decoder 30 and the processor (e.g., an integer ALU instruction may specify a K-bit register field for its source / destination register). For example, in Figure 5 In the example, K = 5. However, in order to reduce the size of the base address register field in array load / store data transfer instructions, such as Figure 12As shown, the Wx field may have L bits (L<K), such that there are some scalar registers that are not allowed to be designated as the base address registers for generating row / column indices for array data transfer instructions. For example, if L=2, the data transfer instruction may be restricted to select from a limited subset of 4 scalar registers (e.g., W12 to W15). This recognizes that instructions already have a large number of parameters to specify, and for the desired use case when controlling matrix processing loops, it may be sufficient to define only a few different base address registers for register addressing within a single program loop. Therefore, by limiting the size of the scalar register field for identifying the base address register used to generate index J, this makes the instruction encoding more efficient and frees up other bit space for representing other parameters. Of course, this is not required, and other specific implementations may provide the scalar register field Wx, which supports any scalar register to be identified as the base address register for register addressing operands.
[0124] Although Figure 12 shows an example in which the current data element size E is directly encoded within the encoding of the instruction using a specific bit field, another option may be that the current data element size can be stored in a control register, which can be set by an earlier instruction and referenced when processing the array data transfer instruction to identify the current data element size, such that it is not necessary to represent the current data element size E within the instruction encoding itself.
[0125] In this example, the array ID i and the immediate value #y for generating the row / column indices of the register addressing information are represented by a combined field within the instruction encoding of the data transfer instruction. This is shown in Figure 13 in more detail. This combined encoding takes advantage of the fact that for a variable data element size E, as the data element size increases, the number of distinct 2D arrays that can fit within the available physical array storage increases, while the dimensions of a single array decrease. Therefore, both the array ID and the immediate value depend on the data element size, but have an inverse scaling relationship, which means that these two parameters can be efficiently represented in a combined field, where the constant number of bits of the combined field is variably mapped to part of the array ID for some data element sizes and variably mapped to part of the immediate value for other data element sizes.
[0126] Furthermore, it should be recognized that in order to support vector-length-agnostic code that can operate correctly on a range of processor-specific implementations that may have implemented different sizes for the matrix vector length MVL, it is desirable that the specific immediate value specified for the register addressing operand should be set by the code to the same value, regardless of the specific matrix vector length MVL implemented. In practice, this means that at the minimum supported matrix vector length MVL minIn the specific implementation of the operation on the processor, providing an encoding space for #y to support multiple encodings is not advantageous, as #y is greater than the maximum number of data elements that can fit into a single vector register ZAR. This is because, even in implementations with vector lengths greater than the minimum vector length, allowing reference to a larger number of elements per vector register, the code cannot directly reference those additional data elements with the immediate value #y, because otherwise the code would no longer be vector length independent, as it would not be able to achieve the minimum vector length MVL. min In its specific implementation, it works correctly. This means that the size of the combined array ID / immediate value field can be selected such that the number of distinct values supported for the immediate value #y is less than or equal to MVL. min / E (In other words, for an N-bit immediate value, 2 N ≤MVL min / E). For example, if the minimum vector length MVL supported by the ISA min If the value is 128 bits, then when the current data element size E is 8, 4 bits will be sufficient to represent the immediate value, because 128 / 8 = 16, which can be represented by 4 bits (i.e., 0 to 15).
[0127] Therefore, as Figure 13 As shown in the example, the 4-bit combined field of a data transfer instruction can represent both the array ID i (defining which array register ZAi is accessed) used to generate the horizontal / vertical index J and the immediate value #y. At the smallest supported data element size (e.g., 8 bits), all 4 bits of the combined field can be allocated to represent the immediate value #y, because at that element size, it is not necessary to specify the array ID at all, as... Figure 9 As shown, the entire physical register storage units ZAR0 to ZAR63 corresponding to the array registers are mapped to a single 2D array ZA0. In this case, although there are 64 distinct element positions in the horizontal / vertical direction, the immediate value #y is scaled only in the range of 0 to 15 to support where MVL = MVL min The implementation is 128-bit, where only 16 8-bit elements can be stored in a single vector register. Accessing an element in the range 16 to 63 will require the software code to specify the base address value in register Wx as a value other than 0.
[0128] On the other hand, at larger data element sizes, immediate values require fewer bits because the number of data elements of that size that can be stored in a vector register of the smallest supported vector length is reduced. However, in these examples, additional bits of the combined field are allocated to represent the array ID i.
[0129] Figure 14 An example of program code that can utilize the array data transfer instructions discussed above is shown. Figure 14 The left side shows high-level program code written by a programmer in a high-level programming language to multiply two matrices A[N×K] and B[K×M] to give the result C[N×M]. The programmer can write a program loop designed to step through the corresponding rows / columns of the two matrix structures stored in memory, load rows / columns for processing, perform multiple outer product operations on vector pairs corresponding to rows of one matrix and columns of the other, and write the resulting product of accumulating the multiple outer product results back to memory.
[0130] For example, in Figure 14 The high-level code illustrates a loop where, in each iteration, two columns of matrix A and two rows of matrix B are loaded as the input vector for the outer product operation. Four outer product operations are performed on the corresponding pairs of columns and rows (similar to...). Figure 7 (The example shown) generates four separate 2D output data arrays. The load / compute loop iterates at different row / column positions of the matrix structure in memory, such that ZA0 through ZA3 accumulates the result of multiplying a block from matrix A with a block from matrix B. Subsequent store loops store the corresponding rows / columns of the result blocks ZA0 through ZA3 back into the result matrix structure C in memory. The outer loop iterates on both the load / compute and store loops to iterate over other combinations of blocks from matrices A and B.
[0131] Figure 14 The right side shows Figure 14 The high-level code on the left is a compiled assembly representation. Inside the inner loop (load / compute loop), there are vector load instructions that load vector registers Z4 through Z7 with the corresponding columns or rows of matrices A / B in memory, and an outer product instruction FMOPA that generates the outer product result written to array registers ZA0 through ZA3 from the corresponding pairs of vector operands in vector registers Z4 through Z7. In this example, the element size is 32 bits, and therefore there are 4 blocks that can be generated within a single iteration of the inner loop (given). Figure 7 (Example). In this example, the size of a data element of E = 32 bits is represented by an element size identifier .s within the assembly representation of various load / store instructions and outer product instructions. The outer product instruction is an outer product and accumulation instruction; therefore, for example, the instruction “fmopa za0.s…” adds the previous contents of each element of array register ZA0 to the elements generated in the outer product operation performed on vector operands in vector registers Z4 and Z6.
[0132] exist Figure 14 The loop at the bottom of the assembly code includes array memory data transfer instructions "st1w", which are used to transfer the generated 2D array from array registers ZA0 to ZA3 to memory. These instructions have references Figure 12 The encoding under discussion. In this example, the direction identifier d specifies the horizontal direction (as pointed to by zaih.s in the assembly representation), therefore Figure 14 The example shows a base register W12 and an immediate value #0 used to generate an index value J that identifies a specific set of elements at a selected level in the array registers ZAi (one of ZA0 to ZA3) to be transferred to memory in response to a corresponding store instruction. A loop is constructed that iterates through the value in the base register W12, which is incremented for each iteration of the loop, such that the store instruction steps through each set of elements at a level of the generated 2D array until all elements of each of the generated arrays ZA0 to ZA3 have been stored in memory. At the bottom of the store loop, an "add" instruction increments the base registers x17 and w12, which are used for memory addressing information and register addressing information, respectively, and a comparison instruction "cmp" compares the value in w12 (which also acts as a loop counter in this example) so that a branch instruction "blt" can determine whether to terminate the loop.
[0133] Figure 14 This example illustrates assembly code where the compiler has not yet used loop unrolling when the store loop is generated at the bottom of the code. In this example, the immediate value for each of the four store instructions is #0, such that the index value used to select a specific row / column to store from the given 2D arrays ZA0 to ZA3 is simply identified by the value stored in the base address register W12.
[0134] However, in this specific implementation of the code, there is a certain amount of overhead in each iteration of the stored loop, in the "add" instruction used to increment w12 and the comparison instruction "cmp" and branch instruction "blt" used to determine whether to terminate the loop. The overhead associated with these loop control instructions can be reduced by performing loop unrolling, where multiple iterations of the loop are unrolled into a single iteration of a larger loop that includes explicit instructions corresponding to the multiple iterations in the original loop. For example, Figure 14 The storage loop shown can be replaced with the following code:
[0135] mov w12,#0
[0136] 1:st1w{za0h.s[w12,#0]},p0,p4,[x17,xzr,lsl#2]
[0137] st1w{za1h.s[w12,#0]},p0,p5,[x17,x2,lsl#2]
[0138] st1w{za2h.s[w12,#0]},p1,p4,[x17,x3,lsl#2]
[0139] st1w{za3h.s[w12,#0]},p1,p5,[x17.x4,lsl#2]
[0140] st1w{za0h.s[w12,#1]},p0,p4,[x18,xzr,lsl#2]
[0141] st1w{za1h.s[w12,#1]},p0,p5,[x18,x2,lsl#2]
[0142] st1w{za2h.s[w12,#1]},p1,p4,[x18,x3,lsl#2]
[0143] st1w{za3h.s[w12,#1]},p1,p5,[x18.x4,lsl#2]
[0144] st1w{za0h.s[w12,#2]},p0,p4,[x19,xzr,lsl#2]
[0145] st1w{za1h.s[w12,#2]},p0,p5,[x19,x2,lsl#2]
[0146] st1w{za2h.s[w12,#2]},p1,p4,[x19,x3,lsl#2]
[0147] st1w{za3h.s[w12,#2]},p1,p5,[x19.x4,lsl#2]
[0148] st1w{za0h.s[w12,#3]},p0,p4,[x20,xzr,lsl#2]
[0149] st1w{za1h.s[w12,#3]},p0,p5,[x20,x2,lsl#2]
[0150] st1w{za2h.s[w12,#3]},p1,p4,[x20,x3,lsl#2]
[0151] st1w{za3h.s[w12,#3]},p1,p5,[x20.x4,lsl#2]
[0152] add x17,x17,x2,lsl#3 / / x17+=2*dim
[0153] add x18,x18,x2,lsl#3 / / x18+=2*dim
[0154] add x19,x19,x2,lsl#3 / / x19+=2*dim
[0155] add x20,x20,x2,lsl#3 / / x20+=2*dim
[0156] add w12,w12,#4
[0157] cmp w12,dim
[0158] blt 1b
[0159] [...]
[0160] mstop
[0161] In this example, the four separate iterations of the original loop can be expanded into a single iteration of the new loop, which reduces the number of "add" instructions for incrementing w12, as well as comparison and branch instructions. Further performance improvements can be achieved if the memory addressing information used to generate the memory address uses a base + immediate addressing mode (where an additional immediate offset indicating a multiple of the element size is added to the base value) to generate the target memory address. For example, in this case, different memory instructions can target different addresses for the expanded loop iteration based on a single register x17, further eliminating the three addition instructions used to increment registers x18 through x20 on each loop iteration.
[0162] It should be understood that the code above is merely an example, but it helps illustrate why using the base register and immediate value from register addressing information to represent the horizontal / vertical position index J can be used to support loop unrolling performed by the compiler, and to support scalable code that can operate with different dimensions of data structures (see [link to code]). Figure 14 The variable `dim` shown represents the dimension of the ZA matrix block to be computed in each iteration.
[0163] Figure 12 The example illustrates an array data transfer instruction as a load / store instruction, wherein data is transferred between a target portion of array register storage device 88 and memory 54.
[0164] Figure 15 The image shows another example of a data transfer instruction that uses register addressing information to access array register 88. Figure 15 This illustrates register move instructions for transferring data between array register 88 and vector register 82. The opcode has the same characteristics as... Figure 12 The opcode of the load / store array data transfer instruction has a different value. The register addressing information of the register move instruction is compared with... Figure 12The same encoding method is used in the example above. However, instead of providing memory addressing information that identifies the target region of memory, the register move instruction specifies a vector register identifier Zk, which specifies the selected vector register 82. Different variations of the register move instruction (represented by different opcodes) can be provided. For example, a vector-to-array register move variation may exist, in which the control processing circuitry transfers the element vector from the vector register Zk to the horizontal / vertical element group J of the selected array register ZAi, in accordance with the above example. Figure 12 The same approach discussed in the examples identifies the array register based on array register addressing information, which includes the direction identifier d, array register ID i, element size E, base register Wx, and immediate value #y. Similarly, array-to-vector register move variants exist, where the control processing circuitry moves data from the horizontal / vertical element group J of the selected array register ZAi to the vector register Zk. Both forms of instructions can be used to support specific matrix processing algorithms, where it may sometimes be necessary to perform some manipulation on elements within a single row / column of a matrix before or after performing 2D operations on the matrix as a whole. Register move instructions can support transferring elements to / from vector registers to enable such single row / column manipulations.
[0165] Figure 16 A flowchart illustrating the processing of a data transmission instruction (such as the array data transmission instruction described above) is shown. At step S200, the instruction decoder 30 decodes the next instruction awaiting processing, and at step S202, the instruction decoder 30 identifies the type of the decoded instruction. If the instruction is not an array data transmission instruction, then at step S204, the processing circuitry executes the operation represented by the instruction under the control of the instruction decoder 30, and the method returns to step S200 to decode the next instruction.
[0166] If the instruction decoded by instruction decoder 30 is identified as an array data transfer instruction, then at step S206, instruction decoder 30 and / or execution level 36 of CPU 60 or coprocessor 70 identify the target portion of the register storage device for the data transfer operation, wherein the target portion of the register storage device is identified based on register addressing information of the data transfer instruction. The register addressing information includes a base register identifier and an immediate value. The processing circuit generates an index value J based on the addition of the value represented by the immediate value and the value stored in the base register identified by the base register identifier. The index value J is used to select the target portion of the register storage device for data transfer.
[0167] At step S208, the processing circuit (under the control of the instruction decoder) identifies the type of the decoded array data transmission instruction. Although step S208 is shown after step S206 for simplicity, in other examples, step S208 may also be performed before step S206, where step S206 appears on one of the two alternative branches of the processing following step S208.
[0168] If the data transmission instruction is similar to Figure 12 For example, in a load / store instruction, at step S210, the processing circuitry determines the target memory portion to be used in the data transfer based on the memory addressing information specified by the instruction. This can be done based on any known addressing mode and can be based on a register identified by the instruction or an immediate value identified by the instruction code.
[0169] At step S212, the processing circuitry is then controlled by the instruction decoder 30 to perform a data transfer operation to transfer data between a target portion of the register storage device and a target portion of the memory. If the instruction is a load instruction, the data transfer operation includes loading data from the target portion of the memory and storing the data in the target portion of the register storage device. If the instruction is a store instruction, the data transfer includes storing data from the target portion of the register storage device to the target portion of the memory. The method then returns to step S200 to decode the next instruction.
[0170] If it is determined in step S208 that the array data transfer instruction is a register move instruction (similar to...) Figure 15 If the target portion of the register storage device is identified in step S214 based on additional register addressing information (e.g., based on the register field Zk in the instruction encoding, which identifies which register is the other part of the register storage device), then in step S216, a data transfer operation is performed to transfer data between the target portion of the register storage device identified based on the base address register Wx and the immediate value #y and the other portion of the register storage device (transferring in either direction depending on the specific instruction type being executed). Similarly, the method returns to step S200 to decode the next instruction.
[0171] Figure 12 and Figure 15The example illustrates an array data transfer instruction that includes register addressing information, which uses a base register and an immediate value to represent the index value used to select the target portion of the array register storage device 88 to be used in the data transfer. However, this type of encoding of register addressing information can also be used for other types of instructions that access registers other than the array register 88 used to store 2D data arrays. More generally, in this way, encoding register addressing information can be useful for instructions designed to process data portions that may have variable dimensions while simultaneously supporting loop unrolling.
[0172] Figure 17 A specific implementation of a simulator that can be used is illustrated. While the previously described embodiments implement the invention in terms of means and methods for operating specific processing hardware supporting the technologies involved, it is also possible to provide an instruction execution environment according to the embodiments described herein, which is implemented using a computer program. Such computer programs are generally referred to as simulators, in part because they provide a software-based implementation of a hardware architecture. Types of simulator computer programs include emulators, virtual machines, models, and binary converters, including dynamic binary converters. Typically, the simulator implementation can run on a host processor 330 that supports the simulator program 310, which optionally runs a host operating system 320. In some arrangements, multiple emulation layers may exist between the hardware and the provided instruction execution environment and / or multiple different instruction execution environments provided on the same host processor. Historically, powerful processors were required to provide simulator implementations that execute at a reasonable speed, but this approach may be reasonable in certain situations, such as when it is desirable to run code native to another processor for compatibility or reuse reasons. For example, the simulator implementation may provide additional functionality to the instruction execution environment that is not supported by the host processor hardware, or provide an instruction execution environment that is typically associated with a different hardware architecture. An overview of the simulation is given in the following literature: “Some Efficient Architecture Simulation Techniques”, Robert Bedichek, Winter 1990 USENIX Conference, pp. 53-63.
[0173] With respect to embodiments previously described with reference to specific hardware constructions or features, in simulated embodiments, equivalent functionality may be provided by suitable software constructions or features. For example, a particular circuit system may be implemented as computer program logic in a simulated embodiment. Similarly, memory hardware such as registers or cache memory may be implemented as software data structures in a simulated embodiment. One or more of the hardware elements referenced in the previously described embodiments are present in an arrangement on host hardware (e.g., host processor 330), and where appropriate, some simulated embodiments may utilize the host hardware.
[0174] The emulator program 310 can be stored on a computer-readable storage medium (which may be a non-transitory medium) and provides a program interface (instruction execution environment) to the target code 300 (which may include application programs, operating systems, and management programs), the same as the interface of the hardware architecture modeled by the emulator program 310. Therefore, the emulator program 310 can be used to execute program instructions of the target code 300 (including the aforementioned mixed-element-size instructions) from within the instruction execution environment, enabling a host computer 330, which does not actually possess the hardware characteristics of the devices discussed above, to emulate these characteristics.
[0175] Therefore, one example provides a simulator computer program 310 that, when executed on a host data processing device, controls the host data processing device to provide an instruction execution environment for executing instructions for the target code; the computer program includes: instruction decoding program logic 312 for decoding program instructions to control the host data processing device to perform data processing in response to the program instructions; and register emulation program logic 314 for maintaining data structures in the host storage of the host hardware 330 to emulate architecture registers 80, 82, and 88 defined in an emulation ISA supported by the target code. The computer program may be stored on a computer-readable recording medium. This recording medium may be a non-transitory recording medium.
[0176] For example, instruction decoding logic 312 may include instruction encoding that examines the program instructions of the target code and maps each type of instruction to a corresponding set of one or more program instructions in the native instruction set supported by the host hardware 330, which implement functions corresponding to the functions represented by the decoded instructions. Register emulation logic 314 may include a set of instructions that maintain data structures in the virtual address space of the host data processing device 330 and / or in the registers of the host device 330, wherein the register emulation data structures represent the register contents of registers 80, 82, and 88, which the target code expects to have in hardware, but which may not actually be provided in the hardware of the host device 330. Instructions in the target code 300 (which reference specific registers in the emulation instruction set architecture) may cause register emulation logic 314 to access registers of the host 330 or generate load / store instructions in the host device's native instruction set to request read / write of the corresponding emulation register state.
[0177] The instruction decoding program logic 312 can support data transfer instructions that use register addressing information, which is defined using a base register and an immediate value in the same manner as discussed above for the hardware implementation. Figure 17 In the case of the simulator example, when the instruction processed in the target code is a load / store instruction for data transfer, in response to the load / store data transfer instruction specifying register addressing information for identifying the target portion of the register storage device and memory addressing information for identifying the target portion of the emulated memory, the instruction decoding program logic 312 controls the host 330 to perform a data transfer operation to transfer data between the location of the register emulated data structure mapped to the target portion of the register storage device and the location in the host storage device of the host data processing device mapped to the target portion of the emulated memory.
[0178] In this application, the phrase "configured as..." is used to mean that the elements of the device have a configuration capable of performing the defined operation. In this context, "configuration" means the arrangement or manner of interconnection of hardware or software. For example, the device may have dedicated hardware that provides the defined operation, or a processor or other processing device may be programmed to perform the function. "Configured as" does not mean that the elements of the device need to be changed in any way to provide the defined operation.
[0179] While exemplary embodiments of the invention have been described in detail herein with reference to the accompanying drawings, it should be understood that the invention is not limited to those precise embodiments, and various changes and modifications can be made therein by those skilled in the art without departing from the scope and spirit of the invention as defined in the appended claims.
Claims
1. A data processing apparatus, the apparatus comprising: An instruction decoding circuit, wherein the instruction decoding circuit is used to decode instructions; A register storage device for storing data; and A processing circuit, configured to perform data processing in response to an instruction decoded by the instruction decoding circuit, to generate a processing result to be written into at least one register in the register storage device; wherein: In response to a data transfer instruction specifying register addressing information for identifying a target portion of the register storage device, the instruction decoding circuit is configured to control the processing circuit to perform a data transfer operation to transfer data to or from the target portion of the register storage device; and The register addressing information includes at least: Base register identifier, the base register identifier identifying the base register in the register storage device used to store base address values; and An immediate value, specified in the encoding of the data transfer instruction, represents a value to be added to the base address value to provide an index value used to select the target portion of the register storage device.
2. The apparatus of claim 1, wherein the register storage means comprises a 2D array register storage means for storing at least one two-dimensional (2D) data array; and The target portion of the register storage device includes the target portion of the 2D array register storage device.
3. The apparatus of claim 2, wherein the data transmission operation includes transmitting a sub-part of a target 2D array to or from the target portion of the 2D array register storage device, the index value identifying which sub-part of the target 2D array is to be transmitted.
4. The apparatus of claim 3, wherein the sub-part comprises a single group of horizontal elements sharing the same vertical position within the target 2D array or a single group of vertical elements sharing the same horizontal position within the target 2D array.
5. The apparatus according to any one of claims 3 and 4, wherein the data transmission instruction specifies an array orientation identifier that identifies one of the horizontal and vertical directions; When the array orientation identifier identifies the horizontal direction, the sub-part of the target 2D array includes at least one group of horizontal elements of the target 2D array identified by the index value, each group of horizontal elements including elements sharing the same vertical position within the target 2D array; and When the array orientation identifier identifies the vertical direction, the sub-part of the target 2D array includes at least one vertical element group of the target 2D array identified by the index value, each vertical element group including elements sharing the same horizontal position within the target 2D array.
6. The apparatus of any one of claims 3 and 4, wherein the data transmission instruction is associated with a current data element size E specified for the data transmission instruction from a plurality of data element sizes supported by the processing circuitry, the current data element size E identifying a data element size associated with each element in the target 2D array.
7. The apparatus of claim 6, wherein the N encoded by the data transmission instruction is used. imm The bits are used to encode the immediate value, where N imm The current data element size E is variable, where N imm It increases as E decreases.
8. The apparatus according to any one of claims 3 and 4, wherein the 2D array register storage device comprises N R There are 1 vector register, each vector register including MVL bits; The instruction decoding circuit is configured to: support the N for the 2D array register storage device. R A variable vector length (MVL) instruction set architecture with multiple vector registers is used to decode instructions, wherein the minimum vector length supported by the instruction set architecture is MVL. min ;and For the elements of the target 2D array, for the data transfer instruction having a data element size E, the number of different values that can be encoded as the immediate value in the instruction encoding of the data transfer instruction is less than MVL. min / E.
9. The apparatus according to any one of claims 2 to 4, wherein the 2D array register storage device is logically divisible into at least two array storage regions, each array storage region for storing a corresponding 2D array; and The register addressing information further comprises an array identifier that identifies a selected array storage region of the 2D array register storage device, and the index value identifies which sub-portion of the selected array storage region is the target portion of the register storage device.
10. The apparatus according to claim 9, wherein the processing circuitry is configured to identify which portion of the 2D array register storage device is the array storage region corresponding to a given value of the array identifier based on a variable mapping, the variable mapping being dependent on a current data element size E specified for the data transfer operation.
11. The apparatus of claim 10, wherein the 2D array register storage device is logically divided into N A There are N array storage areas, and N A It varies according to the current data element size E, where N A It increases as E increases.
12. The apparatus according to claim 9, wherein the array identifier and the immediate value are encoded using a shared portion of bits of an instruction encoding of the data transfer instruction, and For a given bit of the shared portion, the instruction decoding circuitry is configured to vary depending on a current data element size E specified for the data transfer instruction, whether the given bit is interpreted as indicating part of the array identifier or as indicating part of the immediate value.
13. The apparatus according to claim 12, wherein the total number of bits of the instruction encoding of the data transfer instruction for encoding the array identifier and the immediate value is constant, independent of the current data element size E.
14. The apparatus according to any one of claims 1 to 4, wherein when the data transfer instruction is a load / store instruction that specifies the register addressing information and memory addressing information for identifying a memory target portion, the data transfer operation comprises transferring data between the target portion of the register storage device and the memory target portion.
15. The apparatus according to any one of claims 1 to 4, wherein when the data transfer instruction is a register move instruction that specifies the register addressing information and further register addressing information for identifying a further portion of the register storage device, the data transfer operation comprises transferring data between the target portion of the register storage device and the further portion of the register storage device.
16. The apparatus according to any one of claims 1 to 4, wherein the base address register is a scalar register.
17. The apparatus according to any one of claims 1 to 4, wherein the instruction decoder is configured to support at least one scalar computation instruction, the at least one scalar computation instruction having a K-bit scalar register field for specifying a source or destination register; and The data transfer instruction uses an L-bit scalar register field to specify the base address register, where L < K, such that at least one scalar register that is specifiable as the source or destination register for the at least one scalar computation instruction cannot be specified as the base address register of the register addressing information for the data transfer instruction.
18. A data processing method, the method comprising: Decode the instructions; as well as In response to the decoded instruction, the control processing circuitry performs data processing to generate a processing result to be written into at least one register in the register storage device; wherein: In response to a data transfer instruction specifying register addressing information for identifying a target portion of the register storage device, the processing circuitry is controlled to perform a data transfer operation to transfer data to or from the target portion of the register storage device; and The register addressing information includes at least: Base register identifier, the base register identifier identifying the base register in the register storage device used to store base address values; and An immediate value, specified in the encoding of the data transfer instruction, represents a value to be added to the base address value to provide an index value used to select the target portion of the register storage device.
19. A computer program product comprising a computer program for controlling a host data processing device to provide an instruction execution environment for executing instructions for object code, the computer program comprising: The instruction decoding program logic is used to decode the instructions of the target code in order to control the host data processing device to perform processing operations corresponding to the decoded instructions; and Register emulation program logic, which is used to maintain a register emulation data structure in the host storage device of the host data processing device to emulate the register storage device of the target instruction set architecture associated with the target code; in In response to a data transfer instruction specifying register addressing information for identifying a target portion of the register storage device, the instruction decoding program logic is configured to control the host data processing device to perform a data transfer operation to transfer data to or from a location in the register emulation data structure corresponding to the target portion of the register storage device; and The register addressing information includes at least: A base address register identifier, which identifies a base address register in the register storage device used to store base address values; and An immediate value, specified in the encoding of the data transfer instruction, represents a value to be added to the base address value to provide an index value used to select the target portion of the register storage device.
20. A storage medium storing a computer program for controlling a host data processing device to provide an instruction execution environment for executing object code, the computer program comprising: The instruction decoding program logic is used to decode the instructions of the target code in order to control the host data processing device to perform processing operations corresponding to the decoded instructions; and Register emulation program logic, which is used to maintain a register emulation data structure in the host storage device of the host data processing device to emulate the register storage device of the target instruction set architecture associated with the target code; in In response to a data transfer instruction specifying register addressing information for identifying a target portion of the register storage device, the instruction decoding program logic is configured to control the host data processing device to perform a data transfer operation to transfer data to or from a location in the register emulation data structure corresponding to the target portion of the register storage device; and The register addressing information includes at least: A base address register identifier, which identifies a base address register in the register storage device used to store base address values; and An immediate value, specified in the encoding of the data transfer instruction, represents a value to be added to the base address value to provide an index value used to select the target portion of the register storage device.
Citation Information
Patent Citations
Vector data transfer instruction
CN108139907A
Index / data register pair for indirect register access
US20070005869A1
