Sub-vector support instructions for scalable vector instruction set architecture
By supporting sub-vector operations in the scalable vector ISA, the problem of vectorization software porting and optimization on processors with different maximum vector lengths is solved, software development is simplified, performance efficiency is improved, and the widespread adoption of the vector ISA is achieved.
Patent Information
- Application Number
- CN202280093265.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-03-11
- Filing Date
- 2022-12-15
- Publication Date
- 2024-10-22
AI Technical Summary
The existing technology is difficult to effectively port and optimize vectorization software on processors with different maximum vector lengths, resulting in low performance efficiency, and the process of remapping traditional instructions to scalable vector ISA is complex, hindering the widespread adoption of scalable vector ISA .
By supporting subvector operations, allowing a given vector to be treated as multiple subvectors, each of equal length, the instruction decoding circuitry and processing circuitry perform operations at subvector granularity, enabling flexible mapping and manipulation of vector elements, simplifying software development and improved performance.
It reduces the software development workload, improves the platform independence and average performance of vector ISA, allows larger components of software to be efficiently executed on devices that support scalable vector ISA, and uses longer vector lengths to improve performance.
Smart Images

Figure CN118829969A_ABST
Abstract
Description
[0001] The present technology relates to the field of data processing.
[0002] An instruction set architecture (ISA) defines the set of instructions available to software developers or compilers when developing a particular software program, and in a corresponding manner defines the set of instructions that need to be supported by a processor implementation of hardware to allow the hardware to be compatible with software written according to the ISA. For example, an ISA may define, for each instruction, the encoding of the instruction, the representation of its input operands and result values, and the functions used to map the input operands of the instruction to the result.
[0003] The vector ISA supports at least one vector instruction that operates on a vector operand including two or more independent vector elements represented in a single register and / or produces a vector result including two or more independent vector elements. The vector instruction can be processed in a SIMD (single instruction, multiple data) manner to allow multiple independent calculations to be performed on different data values in response to a single instruction. The vector instruction can be used, for example, to allow scalar loops of instructions written in high-level code to be vectorized so that processing corresponding to multiple loop iterations can be performed in response to a single iteration of the vectorized loop. This helps to improve performance by reducing the number of instructions that need to be extracted, decoded and executed to perform a specific amount of data processing.
[0004] At least some examples provide a device comprising: a processing circuit for performing data processing; and an instruction decoding circuit for performing the data processing in response to decoding of a program instruction defined according to a scalable vector instruction set architecture, the scalable vector instruction set architecture supporting vector instructions that operate on vectors of scalable vector lengths so that the same instruction sequence can be executed on a device having hardware supporting different maximum vector lengths; wherein: the instruction decoding circuit and the processing circuit are configured to support sub-vector support instructions that treat a given vector as including multiple sub-vectors, each sub-vector including multiple vector elements, each sub-vector having an equal sub-vector length; and the instruction decoding circuit is configured to control the processing circuit to perform operations on the given vector at a sub-vector granularity in response to the sub-vector support instruction.
[0005] At least some examples provide a method comprising: using instruction decoding circuitry to decode program instructions defined according to a scalable vector instruction set architecture, the scalable vector instruction set architecture supporting vector instructions that operate on vectors of scalable vector lengths to enable the same instruction sequence to be executed on a device having hardware supporting different maximum vector lengths; and controlling processing circuitry to perform data processing in response to the decoding of the program instructions; wherein: the instruction decoding circuitry and the processing circuitry support sub-vector support instructions to treat a given vector as comprising a plurality of sub-vectors, wherein each sub-vector comprises a plurality of vector elements, each sub-vector having an equal sub-vector length; and in response to the sub-vector support instructions, the instruction decoding circuitry controls the processing circuitry to perform operations on the given vector at a sub-vector granularity.
[0006] At least some examples provide a computer program for controlling a host data processing device to provide an instruction execution environment for executing a target code; the computer program includes: instruction decoding program logic, the instruction decoding program logic is used to decode the instruction of the target code to control the host data processing device to perform data processing in response to the instruction of the target code; wherein: the instruction decoding program logic supports decoding of program instructions defined according to a scalable vector instruction set architecture, the scalable vector instruction set architecture supports vector instructions operating on vectors of scalable vector lengths so that the same instruction sequence can be executed on a device with hardware supporting different maximum vector lengths; the instruction decoding program logic includes sub-vector support instruction decoding program logic, which is used to decode sub-vector support instructions that treat a given vector as including multiple sub-vectors, each sub-vector including multiple vector elements, and each sub-vector has an equal sub-vector length; and the instruction decoding program logic is configured to control the host data processing device to perform operations on the given vector at a sub-vector granularity in response to the sub-vector support instruction.
[0007] The computer program may be stored on a storage medium. The storage medium may be a non-transitory storage medium.
[0008] Further aspects, features and advantages of the present technology will be apparent from the following description of examples read in conjunction with the accompanying drawings, in which:
[0009] Figure 1 An example of a data processing device supporting a vector ISA is illustrated;
[0010] Figure 2 An example of registers for a scalable vector ISA is shown;
[0011] Figure 3 Examples showing prediction and variable vector element sizes;
[0012] Figure 4An example of a scalable vector ISA that enables different hardware implementations supporting different maximum vector lengths to execute the same instruction sequence is illustrated;
[0013] Figure 5 An example of a vector showing a vector that is considered as a sub-vector;
[0014] Figure 6 A method of processing sub-vector support instructions is shown;
[0015] Figures 7 to 11 Several examples of sub-vector-supporting permute instructions are illustrated;
[0016] Fig.12 and Fig.13 An example of a subvector supported reduction instruction is illustrated;
[0017] Fig.14 and Fig.15 An example of subvector support for load / store instructions is illustrated;
[0018] Fig.16 and Fig.17 An example of a subvector support prediction setup instruction is illustrated;
[0019] Fig.18 An example of a subvector supporting increment / decrement instructions is illustrated; and
[0020] Fig.19 A simulator implementation is illustrated.
[0021] The device has: processing circuitry for performing data processing; and instruction decoding circuitry for performing the data processing in response to decoding of a program instruction defined according to a scalable vector instruction set architecture (ISA). The scalable vector ISA (also referred to as a "vector length agnostic" vector ISA) supports vector instructions that operate on vectors of scalable vector lengths so that the same instruction sequence can operate on a device with hardware that supports different maximum vector lengths. This is useful because it allows different hardware designers of processor implementations to select different maximum vector lengths depending on their design priorities for high performance or reduced circuit area and power consumption, while software developers do not need to tailor their software for a specific hardware platform, because software written according to the scalable vector ISA can be executed across any hardware platform that supports the scalable vector ISA regardless of the specific maximum vector length supported by the specific hardware platform. Therefore, the vector length of a specific vector instruction to be used for the scalable vector ISA is unknown at compile time (the ISA itself is not defined as fixed, nor is it specified by parameters of the software itself). The operations performed in response to a given vector instruction of a scalable vector ISA may differ depending on the vector length selected for a particular hardware implementation (e.g., hardware supporting a larger maximum vector length may process a greater number of vector elements for a given vector instruction than hardware supporting a smaller maximum vector length). Thus, an implementation with a shorter vector length may require a greater number of loop iterations to perform a particular function than an implementation with a longer vector length.
[0022] Although scalable vector ISAs may be very useful for the development of platform-independent program code that can be easily ported between processor implementations with different maximum vector lengths, there may be a significant amount of traditional code that is compiled by assuming known vector lengths. Redeveloping traditional software for use with scalable vector ISAs may require considerable software development effort. This is particularly true because some software techniques that are generally used to improve the performance of vectorized code (such as software pipelining or loop unrolling) may rely on the vector length for instructions being known at compile time. Therefore, since some techniques used in traditional code may not be available in scalable vector ISAs, it may not be possible to directly remap instructions of non-scalable vector ISAs to instructions of scalable vector ISAs. This can be a significant disincentive to adopting a scalable vector ISA, and can cause some software developers to choose not to use a scalable vector ISA, such that: even on a processor implementation that supports the large maximum vector length using a scalable vector ISA (which may also support a non-scalable vector ISA for backward compatibility reasons), there may be a significant amount of software executing on newer processors that support a scalable vector ISA that still uses the less performance-efficient non-scalable vector ISA (which uses a relatively short maximum vector length). This means that the full performance capabilities of the hardware may not be used by many programs.
[0023] In the example discussed below, the instruction decoding circuit and the processing circuit support the sub-vector support instruction of considering a given vector as including a plurality of sub-vectors in the scalable vector ISA, wherein each sub-vector includes a plurality of vector elements and each sub-vector has an equal sub-vector length. In response to the sub-vector support instruction, the instruction decoding circuit controls the processing circuit to perform operations for the given vector under the sub-vector granularity. Since each vector of the non-scalable vector ISA can be mapped to a sub-vector in the sub-vector of the vector in the scalable ISA, this helps to reduce the required software development workload of the adoption of the scalable vector ISA. This makes it simpler to map non-scalable software to scalable software, and therefore reduces the obstruction of using the scalable vector ISA, so that the code executed on the device supporting the scalable vector ISA of the larger component is more likely to actually use the scalable vector ISA, which will usually improve the average performance of the specific implementation across a series of processors, because the high-end processor supporting a longer vector length can be more likely to utilize these longer vector lengths to improve performance.
[0024] Each sub-vector may have a sub-vector length that is known at compile time for a given instruction sequence to be executed using sub-vector support instructions. This is helpful because it allows a vector operand or result of a scalable vector ISA to be defined as a "vector of vectors" (which includes several smaller sub-vectors, each with a known vector length), so that multiple vectors defined in software written using a non-scalable vector ISA can be combined into a larger vector in accordance with the scalable vector ISA. Since the length of each sub-vector is known at compile time, any performance improvement software techniques that rely on knowledge of vector length at compile time can be applied at the granularity of the sub-vector, thereby making it easier for software developers to map code written in accordance with a non-scalable vector ISA to code defined in accordance with a scalable vector ISA while maintaining the software techniques.
[0025] At compile time of a given instruction sequence to be executed using sub-vector support instructions, it is unknown how many sub-vectors a given vector includes. In other words, the overall vector length of a given vector may be a scalable vector length as allowed by a scalable vector ISA (which may define various maximum vector lengths allowed by different processor implementations). This means that while supporting a range of different performance / power points, sub-vector support instructions may still benefit from the platform-independent nature of a scalable vector ISA. However, software optimizations that rely on knowledge of the vector length to be used as a granularity for vectorization may still be used, since software optimizations may be applied with reference to sub-vectors with known sub-vector lengths before a variable number of sub-vectors may be accommodated in a larger given vector of a scalable vector length using sub-vector support instructions. For example, a variable number of iterations of a vectorization loop that has previously been implemented in a vectorized form using a non-scalable vector ISA may be mapped into a vectorization loop in a scalable vector ISA, where each iteration of the original vectorization loop corresponds to one of the sub-vectors of the vector processed by the sub-vector support instructions of the scalable vector ISA. This makes compilation of code and software development much simpler because it can eliminate the need to revert to scalar loops from vectorized non-scalable code before converting the scalar loops back to vectorized scalable code according to the ISA; instead, it can be much simpler to map the vector instructions of the non-scalable ISA directly to the scalable vector instructions of the scalable ISA without the need for an intervening devectorization step (other compilers can compile directly against a scalable ISA that includes sub-vector processing instructions without the need to base the compilation on previous code compiled against a non-scalable ISA). The sub-vector length known at compile time can be independent of the vector length used for a given vector, so that the sub-vector length is the same for a given instruction of a given software regardless of the actual vector length used for a given vector as a whole by a given hardware implementation.
[0026] In response to the subvector support instruction, the instruction decoding circuitry may control the processing circuitry to process each subvector in the subvector in response to the same instance of executing the subvector support instruction. For example, each of the operations performed at the subvector granularity may be processed in parallel. Alternatively, the operations performed at the subvector granularity may be processed sequentially, or partially sequentially and partially in parallel, or in a pipelined manner. Regardless of the exact timing of the various operations performed at the subvector granularity, each of the operations performed at the subvector granularity is performed in response to a single execution instance of the subvector support instruction, so that the SIMD benefits of the vector ISA can be achieved.
[0027] There are several ways to make the sub-vector length known at compile time. For some specific implementations of a scalable vector ISA, the ISA may define the sub-vector length as a variable software-defined parameter that can be specified by the software code itself to allow the software to select between two or more different sub-vector sizes. For example, this may help provide support for remapping code from two or more different non-scalable vector ISAs with different non-scalable vector lengths.
[0028] However, in one example, each sub-vector may have a sub-vector length of an architecturally defined fixed size that is independent of the vector length for a given vector. This may simplify the architecture and avoid any need for software to specify sub-vector lengths. Alternatively, the sub-vector lengths may be fixed in the architectural definition of the sub-vector support instructions defined in the scalable vector ISA.
[0029] The architecturally defined fixed size may correspond to an architecturally defined maximum vector length that specifies vector instructions for processing according to a predetermined non-scalable vector ISA. For example, the predetermined non-scalable vector ISA may be a vector instruction defined by Cambridge, England. Limited provides the "Advanced SIMD" architecture (also known as Neon TM architecture).
[0030] For example, the architecture-defined fixed size of the sub-vector length may be 128 bits. This is useful for compatibility with advanced SIMD architectures that define a maximum vector length of 128 bits.
[0031] It is also feasible to implement sub-vector support instructions targeting other non-scalable vector ISAs, in which case the sub-vector length may vary depending on the specific ISA being targeted.
[0032] Furthermore, it is feasible to implement sub-vector support instructions without intending to target any particular non-scalable vector ISA, but only for the purpose of selecting a given fixed sub-vector length without any attempt to emulate the length used in a particular non-scalable vector ISA. Even if a particular non-scalable vector ISA is not targeted, it is still useful to define sub-vectors with sub-vector lengths of an architecturally defined fixed size so that software developers and compilers can exploit software performance optimizations that depend on compile time knowledge of this fixed size.
[0033] Subvector support instructions can support variable element sizes so that each vector element of each subvector has a variable element size selected from two or more different sizes supported by a scalable vector ISA. The subvector length can be independent of which element size is used for each vector element in each subvector. Therefore, no matter the selected element size is a larger element size or a smaller element size, the same subvector length can be used. The number of vector elements defines that each subvector can correspond to the ratio between the subvector length and the selected element size. The selected element size can be defined by software-specified parameters of the instruction sequence including the subvector support instruction, and is therefore known at compile time. Therefore, since both the subvector length and the element size can be known at compile time, the number of vector elements provided by each subvector may also be known at compile time, but the total number of vector elements in a given vector as a whole may be unknown at compile time, because: according to the scalable vector ISA, the overall vector length of a given vector is unknown at compile time.
[0034] The operations performed at the sub-vector granularity may vary.Several different sub-vector support instructions may be defined as part of the scalable vector ISA to perform several different operations at the sub-vector granularity depending on the choice of the programmer or compiler.
[0035] In some examples, for at least one sub-vector support instruction, the operation performed at the sub-vector granularity is an operation performed on vector elements within the sub-vector for each sub-vector, independent of elements in other sub-vectors. Thus, this may allow an operation to be performed in a single sub-vector support instruction that may have been performed in a non-scalable vector ISA using several separate vector instructions (each operating on a respective vector having a non-scalable vector length known at compile time) (e.g., the separate vector instructions may correspond to different iterations of a loop written in code of the non-scalable vector ISA).
[0036] In some examples, for at least one sub-vector support instruction, the operation performed at the sub-vector granularity is, for each element position within the sub-vector, an operation performed on a corresponding vector element at that element position within each of the plurality of sub-vectors. This instruction can be used, for example, to replicate processing that would have been performed using a vector instruction sequence within a single loop iteration, where the vector instruction would have combined data values in corresponding element positions within a number of vector operands designated for the vector instruction sequence.
[0037] In some examples, for at least one sub-vector supporting instruction, the operation performed at the sub-vector granularity is an operation to set a selected prediction bit of a prediction value or an operation to perform an operation dependent on the selected prediction bit of the prediction value, wherein the selected prediction bit is a prediction bit corresponding to a sub-vector sized portion of a vector. This may be different from many instructions of a scalable vector ISA that may set or interpret predictions at a granularity of individual vector elements that is less than a sub-vector length. Such sub-vector supporting prediction setting or prediction dependent instructions may be used to allow selective masking of processing of entire sub-vectors in certain circumstances, for example, where the corresponding code of a non-scalable vector ISA masks out an entire iteration of a vectorization loop that has been executed on a vector having a particular vector length known at compile time.
[0038] In some examples, a scalable vector ISA may support at least one variant of a sub-vector support permutation instruction. In response to the sub-vector support permutation instruction, the instruction decoder controls the processing circuit to set the sub-vector to a permutation of one or more vector elements for each sub-vector of the vector result, the one or more vector elements being selected from vector elements within a correspondingly positioned sub-vector of at least one vector operand. The sub-vector support permutation instruction may not be able to set vector elements of a given sub-vector of the vector result based on the bits of vector elements at different non-corresponding sub-vector positions within one of the vector operands. By performing permutations at a sub-vector granularity rather than across the entire vector length of a given vector as a whole, this may allow the behavior of the sub-vector support permutation instruction to reflect the behavior of several separate non-scalable permutation instructions defined in a non-scalable vector ISA assuming a known vector length for permutation, while still making the number of such sub-vector granular permutations performed for a given instruction scalable based on the implemented vector length supported in hardware according to the scalable vector ISA.
[0039] In some examples, the scalable vector ISA may support at least one variant of a sub-vector support reduction instruction. In response to the sub-vector support reduction instruction, the instruction decoder may control the processing circuit to perform at least one reduction operation at the sub-vector granularity, each reduction operation being used to reduce multiple vector elements of the operand vector to a single data value in the result. Since the vector elements in different sub-vectors may not be combined with each other, when performing this reduction operation at the granularity of the individual sub-vectors, different results may be provided for the corresponding reduction operations performed across the entire vector length. This type of reduction may be used to simulate a process that may have been implemented in a sequence of non-scalable vectorized codes by a sequence of multiple instructions within a given loop iteration or a series of loop iterations, each of which includes a single instance of an instruction to combine each element of the vector operand with a corresponding element of an accumulator value that tracks the result of a similar combination in any previous loop iteration.
[0040] Different variants of the subvector-supported reduction instruction are possible, which differ in the way the reduction is performed at the subvector granularity.
[0041] For example, with the sub-vector support reduction instruction in the sub-vector (intra-sub-vector), for each reduction operation, a plurality of vector elements are included in the corresponding vector elements in the corresponding sub-vector of the operand vector. This instruction is included in the ISA to allow software developers to use this instruction to simulate the behavior of non-scalable code that performs reduction across all vector elements of a single vector operand in a scalable architecture with unknown vector length at compile time. The result of each sub-vector granularity reduction can be placed in different sub-vectors of the result value. Alternatively, the variant of the sub-vector support reduction instruction in the sub-vector can place the result of each sub-vector granularity reduction in the corresponding vector elements of one or more sub-vectors of the result value.
[0042] In another variant, with sub-vector support reduction instructions between sub-vectors (inter-sub-vector), for each reduction operation, the plurality of vector elements include vector elements at corresponding element positions within the plurality of sub-vectors of the operand vector. For this type of instruction, the vector elements reduced to a single result are vector elements selected at intervals of the sub-vector length. Including this instruction in the ISA can be used to allow software developers to use the instruction to emulate the behavior of non-scalable code that performs reduction across vector elements at the same element position within the vector being processed in several consecutive loop iterations in a scalable architecture with unknown vector length at compile time.
[0043] A scalable vector ISA may support any one or more of these types of sub-vector support reduction instructions.
[0044] In some examples, the scalable vector ISA may support at least one variant of a sub-vector supported load / store instruction. In response to the sub-vector supported load / store instruction, the instruction decoder may control the processing circuit to perform a load / store operation to transfer one or more sub-vectors between the memory system and at least one vector register at a sub-vector granularity. This may be used to emulate the behavior of a load / store instruction of a non-scalable vector ISA that would have performed a corresponding load / store operation on a vector having a known vector length.
[0045] The sub-vector supported load / store instruction may be a predicate instruction associated with a prediction value. In response to the sub-vector supported load / store instruction, the instruction decoder may control the processing circuit to control execution or masking of each transfer of one or more sub-vectors based on the prediction bits selected from the prediction value at the sub-vector granularity. This may be different from the behavior of other load / store instructions of the scalable vector ISA that may perform load / store operations across the entire (scalable) vector length using a prediction selected at the granularity of the element size of the vector elements of the vector (the element size is smaller than the sub-vector length).
[0046] In some examples, the scalable vector ISA may support at least one variant of a sub-vector supported increment / decrement instruction. In response to the sub-vector supported increment / decrement instruction, the instruction decoder may control the processing circuitry to increment or decrement the operand value based on how many sub-vector size portions in the vector are indicated as valid by bits of the predicted value selected from the predicted value at the sub-vector granularity. This may facilitate loop control so that a loop control variable used by software to decide whether at least one further loop iteration still needs to be performed may be incremented or decremented based on the number of sub-vectors processed in the last iteration of the loop (since the number of sub-vectors processed in a loop iteration may be unknown at compile time, it may be useful to provide instructions that facilitate inferring the number of sub-vectors processed and thus using that number to update the loop control variable).
[0047] The prediction value used by a sub-vector supported increment / decrement instruction to determine how to update an operand value may be one of: a prediction value specified as a prediction operand by the sub-vector supported increment / decrement instruction; and a prediction value represented by a prediction mode identifier specified by the sub-vector supported increment / decrement instruction, the prediction mode identifier specifying a predetermined pattern of prediction bits at a sub-vector granularity.
[0048] In some examples, the scalable vector ISA may support at least one variant of a subvector support prediction setting instruction. In response to the subvector support prediction setting instruction, the instruction decoder may control the processing circuit to perform a prediction setting operation to set the bits of the prediction value at the subvector granularity to indicate which subvectors in the vector are valid. This instruction may be used to control which subvectors are processed by other subvector support prediction instructions. The bits of the prediction value set to a specific value (e.g., 0) may cause the processing of the corresponding subvector to be masked. This prediction setting instruction may be an instruction different from other prediction setting instructions of the scalable vector ISA, which may set the prediction value at a granularity of a vector element size that may be less than the subvector length.
[0049] The prediction setting operation for the subvector support prediction setting instruction may include setting the prediction value based on one of: a prediction mode identifier that specifies a predetermined pattern of prediction bits to be applied at a subvector granularity; and a subvector granularity comparison operation that is based on a comparison of a first operand to a second operand. When this approach is used, the new value of the prediction is not explicitly specified in the subvector support prediction setting instruction, but may be defined according to some general pattern that is scalable for different vector lengths. This is useful because the number of prediction bits to be set may not be known at compile time due to scalable vector lengths.
[0050] Various examples of sub-vector support instructions are described above. It should be understood that any given implementation of a scalable vector ISA does not need to support all of these types of instructions. Any one or more of the instructions described in this application may be implemented.
[0051] The techniques discussed above may be implemented within a data processing device having hardware circuitry provided for implementing the instruction decoder and processing circuitry discussed above.
[0052] However, the same technology can also be implemented in a computer program that is executed on a host data processing device to provide an instruction execution environment for the execution of the target code. Even if the host data processing device itself does not support the architecture, this computer program can control the host data processing device to simulate the architecture environment that will be provided on the hardware device that actually supports the target code according to the scalable vector instruction architecture. The computer program may have an instruction decoding program logic that simulates the function of the instruction decoding circuit discussed above. For example, the instruction decoding program logic generates a corresponding code sequence with the native instruction set of the host data processing device in response to a given instruction of the target code to control the host data processing device to perform the corresponding function of the decoded instruction. The instruction decoding program logic includes a sub-vector support instruction decoding program logic to decode the sub-vector support instruction as discussed above to control the host data processing device to perform operations for a given vector at a sub-vector granularity. For example, when a traditional code written for an instruction set architecture is executed on a host processor that supports different instruction set architectures, this simulation program may be useful. Furthermore, since execution of software on a simulated execution environment enables software testing to be performed in parallel with ongoing development of hardware devices supporting the new architecture, simulation may allow software development for a newer version of an instruction set architecture to begin before processing hardware supporting the new architecture version is ready. The simulation program may be stored on a storage medium, which may be a non-transitory storage medium.
[0053] Specific examples will now be described with reference to the drawings. It is to be understood that the claims are not limited to these specific examples.
[0054] Figure 1An example of a data processing device 2 is schematically illustrated. The data processing device has a processing pipeline 4 including several pipeline stages. In this example, the pipeline stages include an extraction stage 6 for extracting instructions from an instruction cache 8; a decoding stage 10 (an example of instruction decoding circuitry) for decoding the extracted program instructions to produce micro-operations (decoded instructions) to be processed by the remaining stages of the pipeline; an issue stage 12 for checking whether the operands required for the micro-operation are available in registers 14 and issuing the micro-operation for execution once the required operands for a given micro-operation are available; an execution stage 16 (an example of processing circuitry) for executing the data processing operation corresponding to the micro-operation by processing the operands read from the registers 14 to produce a result value; and a write-back stage 18 for writing the result of the processing back to the registers 14. It should be understood that this is only one example of a possible pipeline arrangement, and other systems may have additional stages or different stage configurations. For example, in an out-of-order processor, a register renaming stage may be included for mapping an architectural register specified by a program instruction or micro-operation to a physical register identifier that identifies a physical register in the registers 14. In some examples, there may be a one-to-one relationship between program instructions decoded by decode stage 10 and corresponding micro-operations processed by execute stage 10. There may also be a one-to-many or many-to-one relationship between program instructions and micro-operations, such that, for example, a single program instruction may be split into two or more micro-operations, or two or more program instructions may be fused to be processed as a single micro-operation.
[0055] The execution stage 16 includes several processing units for performing different categories of processing operations. For example, the execution units may include a scalar processing unit 20 (e.g., including a scalar arithmetic / logic unit (ALU) 20 for performing arithmetic or logic operations on scalar operands read from registers 14); a vector processing unit 22 for performing vector operations on vectors including a plurality of vector elements; and a load / store unit 28 for performing load / store operations to access data in the memory system 8, 30, 32, 34. Other examples of processing units that may be provided at the execution stage may include a floating point unit for performing operations involving values represented in a floating point format, or a branch unit for processing branch instructions.
[0056] Registers 14 include scalar registers 25 for storing scalar values, vector registers 26 for storing vector values, and prediction registers 27 for storing prediction values. Prediction values 27 may be used by vector processing unit 22 when processing vector instructions, wherein the prediction value in a given prediction register indicates which vector elements of a corresponding vector operand stored in vector register 26 are valid vector elements or invalid vector elements (where operations corresponding to invalid data elements may be suppressed or may not affect the result value generated by vector processing unit 22 in response to the vector instruction).
[0057] A memory management unit (MMU) 36 controls address translation between virtual addresses (which are specified by instruction fetches from fetch circuitry 6 or load / store requests from load / store unit 28) and physical addresses identifying locations in the memory system based on address mappings defined in page table structures stored in the memory system. The page table structures may also define memory attributes that may specify access permissions for accessing corresponding pages of the address space, such as specifying whether a region of the address space is read-only or read / write, specifying the privilege level that is allowed to access the region, and / or specifying other properties that govern how the corresponding region of the address space may be accessed. Entries from the page table structures may be cached in a translation lookaside buffer (TLB) 38, which is a cache maintained by the MMU 36 for caching page table entries or other information for accelerating access to page table entries from page table structures shown in memory.
[0058] In this example, the memory system includes a level 1 data cache 30, a level 1 instruction cache 8, a shared level 2 cache 32, and a main system memory 34. It will be understood that this is only one example of a possible memory hierarchy, and other arrangements of caches may be provided. The specific type of processing units 20 through 28 shown in the execution stage 16 is only one example, and other implementations may have different groups of processing units or may include multiple instances of the same type of processing unit so that multiple micro-operations of the same type may be processed in parallel. It will be understood that Figure 1 This is only a simplified representation of some components of a possible processor pipeline arrangement, and the processor may include many other elements that are not illustrated for the sake of brevity.
[0059] The processing pipeline 4 supports a scalable vector ISA, which means that the vector instructions of the ISA can be processed without knowing at compile time (the time when the compiler compiles the executed instructions) what the vector length that will be used to execute the vector instruction is. This enables a variety of different processing devices that support different maximum vector lengths to execute the same software code, avoiding the burden on software developers in producing software code suitable for execution across a range of processing platforms. This means that the hardware designer of a given processing device has the freedom to choose the maximum vector length implemented depending on the performance / power requirements preferred by the designer (a system pursuing higher performance may choose a longer maximum vector length than a system pursuing preferred energy efficiency).
[0060] Figure 2An example of an architectural state of a scalable vector ISA is illustrated. The ISA defines a number of scalable vector registers (e.g., 32 vector registers, Z0 to Z31) as vector registers 26, which have an implementation-selected vector length for a given hardware implementation that can be any multiple of a specific unit size up to a specific architecture-defined maximum length. For example, in this example, the unit size is 128 bits, and the architecture supports a maximum vector length of any multiple of 128 bits between 128 bits and 2048 bits (i.e., the vector length for a given processor is LEN*128 bits, where 1≤LEN≤16). For example, this is different from a non-scalable vector architecture where registers can have a fixed architecture-defined vector length of 128 bits (see Figure 2 registers labeled V0 to V31 in the . Figure 2 The example shown is based on a scalable vector ISA that is composed of The Scalable Vector Extension (SVE) provided by Limited and the non-scalable vector ISA are Limited provides the "Advanced SIMD" architecture (Neon TM ). Even if vector lengths greater than 128 bits are supported according to the scalable vector ISA, the instruction decoder 10 and the processing circuit 16 may also support the non-scalable vector ISA for reasons of backward compatibility, and the instructions of the non-scalable vector ISA may refer to registers V0 to V31 of a fixed length (e.g., 128 bits); in practice, these registers may be represented using a portion of a longer register accessible to the instructions of the scalable vector ISA, so that the scalable vector registers Z0 to Z31 and the non-scalable vector registers V0 to V31 may share hardware storage circuitry.
[0061] Of course, other examples may be based on different scalable and non-scalable architectures, and thus the size ranges available for selection of scalable vector lengths and the fixed sizes specified for non-scalable vector lengths may be different. Figure 2 Different than shown.
[0062] In addition to the vector registers 26, a number of prediction registers 27 (labeled P0 to P15) are provided for storing prediction values used to selectively mask operations performed on vector elements of vector operands provided using the vector registers 26. When the maximum vector length supported in hardware is used (this maximum vector length refers to the selected size LEN*128 used by the specific hardware implementation, rather than the maximum vector length allowed by the architecture for any hardware implementation (e.g., 2048 bits)), the prediction registers 27, when defined according to the minimum vector element size supported by the ISA, may have one bit per vector element in the vector registers 26. For example, if the minimum element size is 8 bits, then for the example of LEN*128 bit vector registers, each prediction register may have a size of LEN*16 bits. Figure 3 An example of prediction applied to a vector on an element-by-element basis is shown. Instructions may define variable element sizes, for example, Figure 3 256-bit vectors may be logically divided into 64-bit or 32-bit elements (other element sizes may also be possible, e.g., 16- or 8-bit elements). When using the minimum element size, the prediction register 27 for a given vector stored in the vector register 26 specifies a number of prediction bits sufficient to be able to specify a separate prediction bit for each vector element, but at larger element sizes, not all prediction bits need to be read, and instead, the prediction bits may be read at intervals corresponding to the element size. For example, for 64-bit elements, every eighth prediction bit may be read, e.g., Figure 3 As shown in the top example of , for 32-bit elements, every four prediction bits can be read (with an 8-bit element size, every prediction bit can be read). When a prediction bit is set to 1, the corresponding element is considered valid, while vector elements with corresponding prediction bits set to 0 are considered invalid. Elements of the result vector corresponding to invalid vector elements can be masked out and not updated based on the result of the vector operation (the prediction instruction can include a zeroed prediction variant that sets the masked result elements to 0, or can include a merged prediction variant that sets the masked result elements to the same value as the corresponding element in the destination register before executing the vector instruction).
[0063] like Figure 2As shown, registers 14 may also include some control registers 29 (labeled ZCR) that can be used by higher privileged software to limit the maximum vector length that can be used by software executing in a lower privileged state. For example, in order to save power, a given software may be restricted so that it cannot utilize the full vector length supported in the hardware. However, even if the higher privileged software imposes restrictions on vector length, the vector length used for application software is still unknown at compile time, because there is no way to know whether the actual vector length implemented in a particular processor will be greater or less than the limit defined in the control register 29 (for a specific implementation with a maximum vector length smaller than the limit defined in the control register 29, a vector length smaller than that indicated by the limit will be used).
[0064] The vector length agnostic nature of a scalable vector ISA is useful when considering the wide range of requirements that scale from relatively small energy-efficient microcontrollers to servers and other high-performance computing systems, since it is not feasible to generate different instructions for each different vector length that a processor designer may require within the fixed encoding space of instructions that can be used to encode the ISA. By not having a fixed vector length that is known at compile time, the same ISA can be used to address multiple markets without requiring the software developer to tailor the code for each performance / power / area point.
[0065] To achieve the scalable nature of a scalable vector ISA, the functionality of the vector instructions of the scalable vector ISA is referenced to a parameter indicating the vector length to be used (e.g., Figure 2 The LEN parameter is defined in the architecture (when taking into account the maximum vector length supported in hardware and any software defined limitations using control registers 29), where the parameter LEN is unknown at compile time. Therefore, executing the same vector instruction on different systems may produce different results (which will generally vary in the number of vector elements produced, a subset of which may have the same result value on different platforms, but platforms implementing larger vector lengths may generally produce additional vector elements compared to platforms implementing smaller vector lengths). Predictions can be used to control which elements are produced in a given instance of an instruction, and can be set on the basis of vector length agnosticism, such as by using compare instructions to automatically produce predicted values for a particular loop iteration or applying some generally defined prediction mode that can scale to different vector lengths. Certain instructions may update a loop control parameter (e.g., an element count value) to keep track of how many vector elements have been processed so far, so that overall across a loop, both implementations with wider and narrower vector lengths may ultimately achieve the same result, but at different levels of performance because the implementation with the wider vector length may require fewer loop iterations than the implementation with the narrower vector length.
[0066] Figure 4 Shows a working example of how presenting the same instruction sequence using different vector lengths can be processed differently on different hardware implementations. In this example, the code example is to perform a double-precision floating-point operation 'daxpy' (double-precision Ax plus y) to calculate y[i] = a * x[i] + y[i] for two input value arrays x[i], y[i], where 0 ≤ i < n. This can be implemented in a vectorized loop using a set of instructions from a scalable vector ISA as follows:
[0067]
[0068] Figure 4 Shows the processing of these instructions using a 128-bit vector length for one example and a 256-bit vector length for another example. The variables a and the arrays x[] and y[] are data stored in memory. Registers x0 to x4 are scalar registers. Register p0 is a prediction register. Registers z0 to z2 are vector registers, which are 128-bit registers in the first example and 256-bit registers in the second example (thus, the prediction register p0 is a longer register in the 256-bit example compared to the 128-bit example). Solid-outline boxes indicate valid elements processed or set by a given instruction, while dashed-outline boxes indicate invalid elements masked by the prediction or registers not used at all for a given instruction. It should be noted that the instruction numbers shown in Figure 4 indicate the program order of the decoded instruction sequence executed by the processing circuit 16 (which is different from the numbered compiled code shown above because some instructions can be executed multiple times, and the numbered branch points in the above example are not numbered in Figure 4 . However, Figure 4 shows the same instruction sequence as shown above.
[0069] In both the 128-bit and 256-bit examples, the vector instructions are scaled for the number of vector elements that can fit within the corresponding vector length. In this example, the element size used is 64 bits, such that in the 128-bit example, there are 2 vector elements per vector, and in the 256-bit example, there are 4 vector elements per vector. Thus, only two prediction bits of p0 are used in the 128-bit example, and only four prediction bits of p0 are used in the 256-bit example (in practice, the register p0 can include a larger number of prediction bits to support smaller vector element sizes).
[0070] The whilelt, incd, and b.first instructions are loop control instructions that set predictions and update loop count values according to the supported vector lengths and conditionally branch back to the beginning of the loop depending on the comparison of the loop count values. Other instructions are load / store instructions or vector processing instructions that process a number of vector elements according to the supported vector lengths.
[0071] The increment instruction incd increments a loop counter (e.g., VL / ES, where VL is the vector length and ES is the vector element size) based on the number of vector elements processed in the corresponding loop iteration. The prediction setting instruction whilelt uses a comparison between the loop counter (i, represented by register x4 in the instruction sequence) and the termination limit (n, represented by register x3, which is loaded from memory on line 3 of the above code example by a load instruction) to set the prediction depending on whether the various incremented versions of the loop counter are less than (lt) the limit value. For those elements for which the incremented loop counter is still less than the limit value, the prediction is set to true, and once the incremented loop counter reaches the termination limit, the prediction is set to false (in this example, this occurs on the fourth element processed by instruction 2 in the 256-bit example, but for the 2-element vector in the 128-bit example, this limit has not yet been reached on the first pass and will only be reached by execution to determine that there is still another vector element to be processed (see Figure 4 The 128-bit example shown in the decoded program order is reached by the subsequent prediction setup instruction (the whilelt instruction shown in the 14th line of the above code example), so the branch instruction (instruction 10 in the decoded program order) returns to the loop for another round. On the next round, the whilelt instruction (the 16th instruction in the decoded program order) now determines that all predictions are "false", and therefore the branch instruction does not take the branch at this time, so the loop ends. In contrast, for the 256-bit example, only one round is needed to mask out the effect of the fourth element in each vector register.
[0072] Note that the results produced by the instruction sequence are ultimately the same in both the 128-bit and 256-bit examples (the data stored to memory for array y[] has the same values 3, 50, 41, 32 (from most significant address to least significant address), but the 128-bit example obtains its result in two loop iterations, while the 256-bit example requires only one loop iteration. Therefore, in the 128-bit example, the instructions in lines 8 to 15 in the above code example need to be decoded and executed twice (see Figure 4 Instructions 4 to 17 numbered in decoded program order for the 128-bit example in FIG.
[0073] Although scalable vector ISAs can be very useful for facilitating the development of platform independent code that supports a range of different hardware implementations, many software programs in use have been optimized specifically for non-scalable vector ISAs that support fixed-length vector units, such as those used with FPGAs. Limited Neon TM 128-bit vector units provided by non-scalable vector ISA compatible systems. For backward compatibility, systems supporting scalable vector ISAs can also support instructions from non-scalable vector ISAs to ensure that such legacy software can still execute. However, this means that even if the hardware supports larger vector lengths, non-scalable software still cannot benefit from the additional performance that can be generated in the hardware.
[0074] Redeveloping program code written in a non-scalable vector ISA using instructions of a scalable vector ISA may be desirable because this may open up greater performance opportunities, thereby taking advantage of the longer vector lengths available on many hardware implementations of a scalable vector ISA. However, if an attempt is made to rewrite a program written for a non-scalable vector ISA (where the vector length is known at compile time) into program code written for a scalable vector ISA (where the vector length is unknown at compile time), this may require considerable work for the programmer or compiler writer. Since program code in the form of a non-scalable ISA may often include specific optimizations selected depending on knowledge of a fixed vector length (e.g., 128 bits) known at compile time, the instructions of a non-scalable vector ISA may not be mapped to scalable vector instructions in a simple manner, and if it is not known what vector will be used next at compile time, this may prevent the use of some such optimizations, which in some cases may completely prevent the use of vectorized loops in the form of scalable vectorized code.
[0075] For example, the following C code may implement a partial sum reduction (for example, this might be an operation from a digital signal processing application):
[0076]
[0077] In the above code, the results of the multiply-add operations in each iteration are accumulated in acc and stored in state[biquad].y1. After vectorization, each element of the vector used to store the value of state[biquad].y1 should store the accumulated partial sum (element 0 should store the value of acc in iteration 0, element 1 should store the value of acc after the first two iterations, and so on).
[0078] On a non-scalable vector ISA, this partial sum reduction can be achieved by broadcasting each of the four elements into a new vector register and using the mla (multiply-accumulate) instruction to partially accumulate the four vector registers, as shown below:
[0079] …
[0080] dup v17.4h,v16.h[0]
[0081] dup v18.4h,v16.h[1]
[0082] dup v19.4h,v16.h[2]
[0083] dup v20.4h,v16.h[3]
[0084] add v 6.4h,v6.4h,v17.4h
[0085] mla v 6.4h,v18.4h,v29.4h
[0086] mla v 6.4h,v19.4h,v30.4h
[0087] mla v 6.4h,v20.4h,v31.4h
[0088] …
[0089] Here, the first copy (dup) instruction sets all vector elements of vector register v17 equal to element 0 of vector register v16, the second dup instruction sets all vector elements of vector register v18 equal to element 1 of vector register v16, and so on. There is one dup per vector element of register v16. Since the vector length in a non-scalable vector ISA is known at compile time, the compiler can figure out how many dup instructions to include (four in this example, based on four 32-bit elements per 128-bit vector) given the size of the vector elements.
[0090] However, in a scalable vector ISA, this partial sum reduction cannot be performed in the same way, since the vector length is unknown at compile time, and thus the compiler does not know how many dup instructions should be included. This may hinder the successful vectorization of scalar loops defined in C language code, and may force scalable vector code to use scalar loops, so that the benefits of vectorization cannot be realized.
[0091] This is just one example of a software optimization that may rely on compile-time knowledge of vector length. Other examples may include: loop unrolling, which reduces the number of loop control instructions that need to be executed by mapping a certain number of original loop iterations to a smaller number of loop iterations each including a larger number of instructions, where one iteration of the "unrolled" loop corresponds to multiple iterations of the original loop; and software pipelining, where the compiler reorders the execution of the instructions of a loop so that some instructions of a later loop iteration may be executed before instructions from an earlier loop iteration.
[0092] Figure 5 An example of a technique that can help with this problem is schematically illustrated. A vector with a scalable vector length (unknown at compile time) is logically treated as comprising a scalable number of sub-vectors, each with an equal sub-vector length. The sub-vector lengths are known at compile time. For example, each sub-vector may have a length corresponding to a non-scalable vector architecture (e.g., Neon TM ), or may simply be an arbitrary fixed size defined in the scalable vector ISA (regardless of any correspondence with an existing non-scalable vector ISA). Alternatively, in some implementations of the scalable vector ISA, software may have the ability to specify a sub-vector length from two or more options, such that the sub-vector length is known at compile time (defined by software), but may vary for different instances of instructions utilizing this sub-vector method. Since the sub-vector length is known at compile time, but the overall vector length is not, the total number of sub-vectors that fit within the vector is also unknown at compile time and may be scalable depending on the specific vector length selected for executing a specific hardware implementation of instructions designed to support the sub-vector method. Each sub-vector has a variable number of vector elements, and the size of each vector element may be variable and selected by software from a number of options (e.g., 8, 16, 32, or 64 bits). Thus, while the size and number of vector elements per sub-vector may be known at compile time, the number of effect elements in the entire vector may be variable and unknown at compile time. The sub-vector length may be independent of both the overall vector length used by the hardware and the vector element size specified for a given instruction.
[0093] When this approach is used, since the sub-vector length is known, it becomes much simpler to convert code compiled for use with a non-scalable vector ISA (assuming a fixed vector length) to code compiled for use with a scalable vector ISA (using sub-vector support instructions for sub-vectors assuming known sub-vector lengths, but allowing for scalable overall vector lengths). Furthermore, even if compiling directly for a scalable vector ISA that supports sub-vector support instructions (not starting from non-scalable vectorized code), the sub-vector support instructions may be used to allow the application of software performance improvement techniques (such as those discussed above) that would otherwise not be possible for scalable vector instructions that operate at an element-by-element or overall vector granularity in vectors of scalable length rather than at a fixed-size sub-vector granularity.
[0094] Thus, as discussed in the following examples, and the number of sub-vector support instructions that control processing circuitry 16 (e.g., vector processing unit 22 and / or load / store unit 28) to perform operations at the granularity of sub-vectors rather than at the granularity of individual elements or the granularity of the entire vector) may be defined. Operations performed at the granularity of sub-vectors may be performed in parallel, sequentially, partially in parallel and partially sequentially, or in a pipelined manner in response to executing a single instance of a sub-vector support instruction (thus, there is no need to partition a vector into sub-vectors using prediction values set between respective instances of executing a sub-vector support instruction, with each sub-vector being processed in a separate round via the sub-vector support instruction).
[0095] It is not necessary to provide sub-vector support instructions corresponding to all vector operations that may be desired to be performed on vector operands. Many operations (e.g., addition or multiplication) can be applied at an element-by-element granularity, and thus even when applied to vectors designed to support Figure 5 In the embodiment of the present invention, the vector method (vector-of-vectors approach) of the vector shown in the figure can also provide correct results.Therefore, for some types of processing operations, sub-vector granularity instructions may be infeasible.However, for some types of processing operations (such as generally across the permutation or reduction implemented by the entire vector), it may be useful to define the sub-vector support instructions that apply corresponding operations under the granularity of the sub-vector to provide different processing results.Similarly, it may be useful to implement some types of load / store instructions and loop control or prediction setting instructions (such as, by setting or reading the prediction bit under the granularity of the sub-vector rather than under the granularity of the individual element) operating under the sub-vector granularity.By including such instructions in the scalable vector ISA, this can make the redevelopment of the program code previously optimized for the non-scalable vector ISA to use the scalable vector ISA become more direct, and then when using the higher-end processor of the larger vector length supported by the scalable vector ISA to be specifically implemented, the code is achieved to achieve preferred performance.
[0096] Figure 6 A flow chart illustrating the processing of a subvector support instruction is shown. In step 100, an instruction decoder 10 supporting a scalable vector ISA decodes the next instruction of the program being executed. In step 102, the instruction decoder 10 determines whether the decoded instruction is a subvector support instruction. If not, then in step 104, the instruction decoder 10 controls the processing circuit 16 to perform the processing operation as indicated by other types of instructions. If the instruction decoded by the instruction decoder 10 is a subvector support instruction, then in step 106, the instruction decoder 10 controls the processing circuit 16 to perform an operation for a given vector considered to include two or more subvectors under the subvector granularity, and the two or more subvectors each include a certain number of vector elements, wherein each subvector has an equal subvector length. The subvector length is known at compile time. However, the overall vector length is unknown at compile time, so the number of subvectors processed by the instruction is unknown at compile time.
[0097] Figures 7 to 11 Various examples of sub-vector support permutation instructions for applying permutation operation to each sub-vector of vector operands are shown. In each case, the (multiple) input operands and results for instructions are considered to be vectors logically divided into several sub-vectors, each of which has a sub-vector length (e.g., 128 bits) that is fixed in the architecture or otherwise known at compile time. The overall length of vector operands and results is scalable and unknown at compile time. For ease of explanation, all examples discussed below show examples with 32-bit elements so that each sub-vector has four vector elements, but it should be understood that other examples can use different element sizes. For each permutation instruction, all elements in a given sub-vector of the result are set to the permutation of the position selected from the corresponding sub-vector of one or more operand vectors. It is impossible to set a given element in a given sub-vector of the result depending on the position selected from the elements in other sub-vectors of the operand vector, and the element is at a different relative sub-vector position compared to the given sub-vector of the result. Therefore, the corresponding permutation operation is performed repeatedly under the sub-vector granularity.
[0098] Figure 7 A first example of a copy permute instruction DUPQ is shown, where the permute applied in a given sub-vector of the result Zd is to copy selected elements of the corresponding sub-vector of the operand vector Zn to each of the vector elements of the given sub-vector of the result. Which element is to be copied is indicated by an immediate index value #imm defining the position of the element relative to the beginning of the sub-vector. For example, in Figure 7In, the immediate value has a value of 1, which indicates that the element 1 of each sub-vector of the operand Zn will be copied to all vector element positions in the corresponding sub-vector of the result Zd. Therefore, the value A1 is copied to the first four element positions of Zd, the value B1 is copied to the second four element positions, the value C1 is copied to the second four element positions, and so on (because each sub-vector includes four vector elements in this example). The number of sub-vectors processed using the permutation operation will depend on the specific vector length used by hardware as allowed by the scalable vector ISA. However, since the number of examples of the given vector elements to be copied is known at compile time (for example, 4 in this case), code optimization (for example, the one for partial sum reduction shown above) can still be used to make it easier to adopt the scalable vector ISA, while still allowing the code optimization that relies on the knowledge of the (sub) vector length at compile time.
[0099] Figure 7 The bottom portion of shows the corresponding copy permutation if applied at the granularity of the entire vector, as might be expected with a conventional vector instruction. In this case, the immediate index value will define a vector element position relative to the start of the vector operand Zn, and the vector element at this position of the vector operand Zn will be copied to each element of the result vector Zd. This clearly shows the difference in the results achieved using the sub-vector support variant of the permute instruction compared to the entire vector permute instruction.
[0100] Figure 8Another example of a sub-vector support permutation instruction EXTQ is shown. In this example, the permutation applied to each sub-vector is an extraction permutation to set the lower portion of each sub-vector of the result Zdn' to the higher bits of the corresponding sub-vector of the first vector operand Zdn, and the upper portion of each sub-vector is set to the lower bits of the corresponding sub-vector of the second vector operand Zm. In this example, the encoding is destructive so that the result is written to the same register Zdn used to provide the first vector operand. Other examples may use constructive encoding, which defines another vector register to provide a first vector operand different from the destination register used to store the result. The immediate index value defines the size of the portion extracted from the two operand vectors (e.g., the index may define a position relative to the beginning of the sub-vector, the upper portion of the first operand for the lower bits of the corresponding sub-vector to be copied to the result is extracted at this position, and the remaining bits of the corresponding sub-vector of the result may be filled with bits selected from the least significant end of the second operand). In this particular example, the immediate values select bit positions at a byte granularity (in units of 8 bits) such that bits [127-(imm*8):0] of a given result subvector are set equal to bits [127:imm*8] of the corresponding subvector in the first operand Zdn, and bits [127:128-(imm*8)] of a given result subvector are set equal to bits [(imm*8)-1:0] of the second operand Zm. It should be understood that other examples may define immediate values to be selected at increments other than 8 bits. This permutation is applied separately at a subvector granularity, but each subvector permutation uses the same immediate value representing the boundary between portions extracted from the corresponding subvectors of the two operands. Similarly, Figure 8 Shows how applying this operation at a sub-vector granularity differs from a global vector permutation.
[0101] Fig. 9Another example of a sub-vector support permutation instruction TBLQ is shown if the table lookup permutation is applied on a sub-vector by sub-vector basis. In this example, the first vector operand Zm defines a set of index values, which indicates which elements of a given sub-vector of the second vector operand Zn are to be copied to the corresponding element position in the corresponding sub-vector of the result vector Zd. The index value is defined relative to the beginning of the corresponding sub-vector rather than relative to the entire vector. Therefore, for the second sub-vector (corresponding to the values B0, B1, B2, B3 in the second operand Zn), the element index 3, 3, 1, 2 selects values B3, B3, B1, B2 (B3 is placed in the least significant element of the sub-vector, and B2 is placed in the most significant element) for the corresponding vector element of the corresponding sub-vector in the result. If a particular index value has a value greater than the largest vector element index in a given sub-vector, then a zero is written to the corresponding position in the result vector Zd (e.g., see the example of index value 6 for the most significant vector element position in the third sub-vector, which is greater than the most significant index 3 of the 4 elements (labeled 0 to 3) in the given sub-vector, so a 0 is written to the corresponding position in the result Zd). Likewise, this method of per-sub-vector permutation differs from global vector permutation, where the index values will be defined relative to the global vector, and thus the global vector permutation will be applied to the sub-vector. Fig. 9 The two identical operands Zm and Zn shown in FIG. 1 will provide different results to the operation performed at the sub-vector granularity, such as Fig. 9 as shown in the lower part of .
[0102] Fig.10 Another example of a sub-vector supported permute instruction ZIPQ1 is shown, where in this case the permute applied in a given sub-vector is to interleave elements from the lower halves of corresponding sub-vectors of two vector operands Zn, Zm within the given sub-vector of the result vector Zd. This permute is performed for each of the sub-vectors and similarly provides different results than if a similar permute were performed at the whole vector granularity, such as Fig.10 As shown in the lower part of Fig.10 An example is shown in which elements from the lower half of each sub-vector are interleaved, but a corresponding instruction ZIPQ2 may be additionally defined to interleave elements from the upper half of each sub-vector.
[0103] Fig.11Another example of a sub-vector supported permutation instruction UZPQ1 is shown, where in this case the permutation applied in a given sub-vector is to concatenate the even numbered vector elements of corresponding sub-vectors of the two vector operands Zn, Zm within corresponding sub-vectors of the result vector Zd. Again, this produces a result having elements in a different order than would be achieved if a similar permutation were applied at the granularity of the whole vector. An alternative version of this instruction, UZPQ2, may concatenate odd numbered elements instead of even numbered elements.
[0104] Fig.12 The example of the reduction instruction between the sub-vectors that implements the reduction operation under the sub-vector granularity is shown, and each reduction operation is used to reduce the multiple elements of the operand vector to the single data value in the result vector. This example shows a prediction instruction, wherein the instruction specifies the prediction value Pg associated with the operand vector Zn to indicate which elements are shielded. The shielded element will not contribute to the reduction result. For this example, the reduction is to execute across the corresponding numbered elements in each sub-vector, and the reduction operator applied in this example is addition. Therefore, the element 0 of the result vector Zd is set to the sum of any unshielded elements at the position 0 in each sub-vector in the sub-vector of the vector operand Zn, and the element 1 of the result vector Zd is set to the sum of any unshielded elements at the position 1 in each sub-vector in the sub-vector of the vector operand Zn, and other element positions are then deduced by analogy (if all elements at the given position in each sub-vector are shielded, the corresponding element of the result is set to 0). Since the reduction operation reduces the total number of elements, the remaining elements of the result vector Zd that are not filled in the reduction result can be filled with zero.
[0105] Although Fig.12 An example with additive reduction is shown, but similar reduction operations at a sub-vector granularity may be performed for other operations, such as AND, exclusive OR (EOR), floating point addition (FADD), floating point maximum (FMAX, which determines the maximum value of a set of floating point numbers), floating point minimum (FMIN, which determines the minimum value of a set of floating point numbers), OR, signed maximum (SMAX, which determines the maximum value of a set of signed integers), signed minimum (SMIN, which determines the minimum value of a set of signed integers), unsigned maximum (UMAX, which determines the maximum value of a set of unsigned integers), and unsigned minimum (UMIN, which determines the minimum value of a set of unsigned integers).
[0106] like Fig.13 As shown, it is also possible to provide a reduction instruction within a sub-vector, which performs a reduction within each sub-vector to reduce all elements of a given sub-vector of the input operand Zm to a single data value of the result vector Zd'. The single element may be sign-extended or zero-extended to fill the corresponding sub-vector of the result vector Zd'. Fig.13 As shown, the reduction operation within a given subvector may also depend on the element extracted from a given element position (e.g., element position 0) in the corresponding subvector of the second vector operand Zd. Similarly, the prediction may be applied based on a prediction value Pg that defines a valid or invalid element of the Zm operand (an additional element taken from Zd may always be considered valid, which may be used as an accumulator value to track the results of a series of previous reductions, so using a prediction value such as Fig.13 The destructive encoding shown may be useful, where the result is written to the same register Zd) used to provide the accumulator value.
[0107] Regardless of the reduction Fig.12 is performed across the corresponding elements of each subvector as shown, or the reduction is as follows Fig.13 As shown, this reduction is performed on elements within a single sub-vector, and is an operation performed at a sub-vector granularity, which is different from the result that would be achieved if the corresponding operation was performed at a full vector granularity (reducing all elements of the vector to a single data value), or if the same reduction operation was performed using an element-wise vector addition instruction (or similar bit-wise instructions for other reduction operations) included in a loop or instruction sequence to add or otherwise reduce elements at corresponding positions within a set of vectors. The sub-vector based approach can be used to simplify the mapping of non-scalable vectorized code (which may have assumed a fixed vector length) to a scalable vectorized code, where the sub-vector corresponds to the fixed vector length, and the overall vector length can be scaled according to the design choices of the hardware designer.
[0108] Fig.14 An example of sub-vector supported load / store instructions is shown that may help support a vector of vectors approach. Fig.14 Continuous load / store instructions are shown, where a block of data loaded from memory to at least one vector register or stored from at least one vector register to memory corresponds to a continuous block of data in the memory address space. Fig.14A load / store instruction for loading / storing a single vector register is shown, but other load / store instructions that support loading / storing of multiple vector registers may be provided. Unlike other forms of vector load / store instructions, subvector support vector load / store treats the subvector length (rather than the individual vector elements within the subvector) as the basic unit of vector load / store operations. Therefore, the prediction value Pg used to indicate which parts of the vector register will be loaded or stored is applied at the subvector granularity rather than at the granularity of the individual elements. The subvector corresponding to the prediction bit of zero may be masked so that for a load instruction, the corresponding subvector of the destination register Zt is not set to the value of the corresponding subvector loaded from the memory, and for a store instruction, the data in the corresponding subvector of the source register Zt is not written to the corresponding addressing position in the memory.
[0109] Similarly, Fig.15 A centralized decentralized form of sub-vector support load / store instructions is shown, which can load or store several sub-vectors from non-contiguous address blocks in memory to or from vector register Zt. In this example, vector register Zm provides index values to determine the address block corresponding to a given sub-vector. Each index indicates a multiple of a data block having a size corresponding to the length of the sub-vector. Likewise, prediction is applied at the sub-vector granularity.
[0110] Should understand Fig.14 and Fig.15 The addressing mode shown is only one example, and other examples may use different techniques to determine the addresses of the sub-vectors to be loaded into or stored from the vector registers. For example, for other gather-scatter instructions, the vector operands used to calculate the addresses for the load / store operations for each sub-vector may be used as a vector of base addresses rather than a vector of offsets. In general, a sub-vector supported load / store instruction may be any load / store instruction that operates at the granularity of a sub-vector.
[0111] Fig.16An example of a prediction setting instruction that can be used to set a prediction corresponding to a given vector at a sub-vector granularity is illustrated. In this example, the prediction setting instruction is a comparison instruction that sets the prediction bit Pi corresponding to sub-vector i to 'true' (1) if a comparison of 'Rn'+i with 'Rm' is true, where 'Rn' is the value stored in a first scalar register Rn, and 'Rm' is the value stored in a second scalar register Rm. Different variants of the instruction corresponding to different comparison conditions may be provided, such as LO (unsigned lower than), LS (unsigned lower than or the same), LT (signed lower than), LE (signed lower than or equal to), HI (unsigned higher than), HS (unsigned higher than or the same as), GT (signed greater than), or GE (signed greater than or equal to). This instruction is similar to the one in Figure 4 The whilelt instruction shown in the scalable code example of , but sets the prediction at a sub-vector granularity instead of a vector element granularity. This can be used to emulate the behavior of code that would mask out the effect of an entire vector in the non-scalable vectorization example.
[0112] Fig.17 A second example of a sub-vector supported prediction setting instruction is shown, where the prediction value is also set at the sub-vector granularity, but in this example, the instruction specifies a particular predefined mode to be applied at the sub-vector granularity (e.g., the prediction bits to be set / cleared depending on the mode to be implemented are the prediction bits corresponding to the start of each sub-vector). This may be different from a corresponding prediction setting instruction that may apply a mode at the granularity of individual vector elements. For example, the prediction mode may be to set a specified number of prediction bits to valid, set one valid one out of every N predictions (where N is a value such as 2, 3, 4, etc.), or set a number of prediction bits to valid corresponding to the largest power of 2 that fits the prediction value, taking into account the implemented vector length of the hardware.
[0113] Fig.18 An example of a sub-vector support increment instruction that specifies a mode identifier that identifies a predetermined prediction mode and, when applied at a sub-vector granularity, controls processing circuitry 16 to increment a scalar operand Xdn by a number corresponding to the number of valid sub-vectors indicated by the specified prediction mode is illustrated. A corresponding instruction may be provided to decrement an operand by the number of valid sub-vectors indicated by the prediction mode instead. A prediction mode may be defined in a corresponding manner for Fig.17 This instruction can be used to control the increment or decrement of a loop count variable, which is used to track whether further loop iterations are still needed or whether the loop may be terminated because the required sub-vectors have been processed.
[0114] All instructions described above can help make it easier to adapt code written for a fixed-length vector architecture to a scalable vector architecture. It should be understood that not all of these instructions need to be implemented in a given implementation. In addition, similar sub-vector granularity instructions can be defined for other operations.
[0115] In general, to enable non-scalable vector length specification architectures (such as Neon TM ) to a scalable vector length agnostic architecture (e.g., SVE) can be converted more directly, the above example adds sub-vector (e.g., quadword (128-bit) sized) elements and treats each sub-vector as an element in the scalable architecture. While doing so, a vector-in-vector style is formed to vectorize each fixed-length vector of the non-scalable architecture using the vector length agnostic style of the scalable architecture. This allows mapping of non-scalable code to scalable code with a coarse 1-to-1 instruction mapping, so that vectorization can take advantage of the longer and flexible vector lengths allowed in the scalable architecture, and still retain code optimizations introduced for the non-scalable architecture that rely on the assumption that the vector length is known at compile time.
[0116] Fig.19 The simulator that can be used is illustrated as being implemented. Although the embodiment described earlier is implemented with the device and method for operating the specific processing hardware of the technology concerned, it is also possible to provide an instruction execution environment according to the embodiment described herein, which is implemented by using a computer program. Such computer programs are often referred to as simulators because they provide a specific implementation based on software of a hardware architecture. The types of simulator computer programs include emulators, virtual machines, models, and binary converters (including dynamic binary converters). In general, the simulator is implemented and can be run on a host processor 330 that optionally runs a host operating system 320 and supports a simulator program 310. In some arrangements, there may be multiple layers of simulation between the hardware and the provided instruction execution environment and / or multiple different instruction execution environments provided on the same host processor. Historically, a powerful processor has been required to provide a simulator for specific implementation, which is executed at a reasonable speed, but this method may be justified in some cases, such as when the code of another processor body needs to be run because of compatibility or reuse reasons. For example, the simulator can be implemented to provide an instruction execution environment with additional functionality that is not supported by the host processor hardware, or to provide an instruction execution environment that is generally associated with different hardware architectures. An overview of simulation is given in "Some Efficient Architecture Simulation Techniques", Robert Bedichek, Winter 1990 USENIX Conference, pages 53-63.
[0117] Where an embodiment has been previously described with reference to a particular hardware architecture or feature, in an analog embodiment, equivalent functionality may be provided by an appropriate software architecture or feature. For example, a particular circuit may be implemented as computer program logic in an analog embodiment. Similarly, memory hardware (e.g., registers or caches) may be implemented in an analog embodiment as software data structures stored in host memory (e.g., memory or registers) of the host processor 330. Where one or more of the hardware elements mentioned in the previously described embodiments are present in an arrangement on host hardware (e.g., host processor 330), some analog embodiments may utilize host hardware (where appropriate).
[0118] The simulator program 310 may be stored on a computer-readable storage medium (which may be a non-transitory medium) and provide a program interface (instruction execution environment) to the target code 300 (which may include an application, an operating system, and a hypervisor), which is the same as the program interface of the hardware architecture modeled by the simulator program 310. Therefore, the program instructions of the target code 300 can be executed from within the instruction execution environment using the simulator program 310, so that a host computer 330 that does not actually have the hardware features of the device 2 discussed above (for example, the instruction decoder 10 and the processing circuit 16 that support the sub-vector support instructions as discussed above) can emulate the features.
[0119] Thus, the simulator program 310 may have an instruction decoding program logic 312 for decoding instructions of the target code 300 and mapping these instructions to corresponding instruction sets in the native instruction set of the host device 330. The instruction decoding program logic 312 includes a sub-vector support instruction decoding program logic 313 for decoding the sub-vector support instructions described above. The register emulation program logic 314 maps register accesses requested by the target code into accesses to corresponding data structures maintained on the host hardware of the host device 330, for example, by accessing data in a register or memory of the host device 330. The memory management program logic 316 implements address translation, page table traversal, and access permission checks in a manner corresponding to the MMU 36 described in the hardware implementation scheme described above to simulate accesses of the target code 300 to the simulated address space. A memory address space emulation program logic 318 is provided to map simulated physical addresses obtained by the memory management program logic 316 based on address translation using page table information maintained by the software of the target program code 300 into host virtual addresses for accessing the host memory of the host processor 330. These host virtual addresses may themselves be converted to host physical addresses using standard address translation mechanisms supported by the host (the conversion of host virtual addresses to host physical addresses is outside the control of the simulator program 310).
[0120] In this application, the phrase "configured to..." is used to mean that the elements of a device have a configuration that enables the defined operation to be performed. 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 to" does not mean that the elements of the device need to be changed in any way to provide the defined operation.
[0121] Although illustrative embodiments of the present invention have been described herein in detail with reference to the accompanying drawings, it should be understood that the invention is not limited to this precise embodiment and that various changes and modifications may be effected therein by those skilled in the art without departing from the scope of the invention as defined by the appended claims.
Claims
1. A device, comprising: A processing circuit, the processing circuit is used to perform data processing; and instruction decoding circuitry to perform said data processing in response to decoding of program instructions defined in accordance with a scalable vector instruction set architecture, said scalable vector instruction set architecture supporting vector instructions operating on vectors of scalable vector lengths to enable the same sequence of instructions to be executed on devices having hardware supporting different maximum vector lengths; wherein: The instruction decoding circuitry and the processing circuitry are configured to support sub-vector support instructions that treat a given vector as comprising a plurality of sub-vectors, wherein each sub-vector comprises a plurality of vector elements, each sub-vector having an equal sub-vector length; and The instruction decoding circuit is configured to control the processing circuit to perform an operation on the given vector at a sub-vector granularity in response to the sub-vector support instruction.
2. The apparatus of claim 1, wherein each sub-vector has a sub-vector length that is known at compile time for a given instruction sequence to be executed using the sub-vector support instructions.
3. The apparatus according to any one of claims 1 and 2, wherein at compile time of the given instruction sequence, it is unknown how many sub-vectors the given vector includes.
4. An apparatus according to any preceding claim, wherein the instruction decoding circuit is configured to, in response to the sub-vector support instruction, control the processing circuit to process each of the sub-vectors in response to executing the same instance of the sub-vector support instruction.
5. An apparatus according to any preceding claim, wherein each sub-vector has a sub-vector length of an architecture-defined fixed size that is independent of the vector length for the given vector.
6. The apparatus of claim 5, wherein the architecture-defined fixed size corresponds to an architecture-defined maximum vector length specified for vector instructions processed according to a predetermined non-scalable vector instruction set architecture.
7. The apparatus according to any one of claims 5 and 6, wherein the architecture-defined fixed size is 128 bits.
8. Apparatus according to any preceding claim, wherein each vector element of each sub-vector has a variable element size, and the sub-vector length is independent of which element size is used for each vector element within each sub-vector.
9. An apparatus according to any preceding claim, wherein for at least one sub-vector supporting instruction, the operation performed at sub-vector granularity is an operation performed on vector elements within the sub-vector for each sub-vector, regardless of elements in other sub-vectors.
10. An apparatus according to any preceding claim, wherein for at least one sub-vector supporting instruction, the operation performed at sub-vector granularity is an operation performed on the corresponding vector elements at the element positions within each of the plurality of sub-vectors for each element position within the sub-vector.
11. An apparatus according to any preceding claim, wherein for at least one sub-vector supporting instruction, the operation performed at sub-vector granularity is an operation to set selected prediction bits of a prediction value or an operation to perform an operation depending on selected prediction bits of the prediction value, wherein the selected prediction bits are prediction bits corresponding to a sub-vector sized portion of a vector.
12. An apparatus according to any preceding claim, wherein the instruction decoder is configured to, in response to a sub-vector supporting permute instruction, control the processing circuitry to set, for each sub-vector of the vector result, the sub-vector to a permute of one or more vector elements, the one or more vector elements being selected from vector elements within a correspondingly located sub-vector of at least one vector operand.
13. An apparatus according to any preceding claim, wherein the instruction decoder is configured to control the processing circuit to perform at least one reduction operation at a sub-vector granularity in response to a sub-vector supported reduction instruction, each reduction operation being used to reduce multiple vector elements of an operand vector into a single data value in a result.
14. The apparatus of claim 13, wherein, in the case of a sub-vector-within-sub-vector supported reduce instruction, for each reduce operation, the plurality of vector elements comprises the respective vector elements within a corresponding sub-vector of the operand vector.
15. The apparatus of any one of claims 13 and 14, wherein in the case of a sub-vector-supported reduction instruction between sub-vectors, for each reduction operation, the plurality of vector elements comprises the vector elements at corresponding element positions within a plurality of sub-vectors of the operand vector.
16. An apparatus according to any preceding claim, wherein the instruction decoder is configured to control the processing circuitry to perform a load / store operation to transfer one or more sub-vectors between a memory system and at least one vector register at a sub-vector granularity in response to a sub-vector supported load / store instruction.
17. The apparatus of claim 16, wherein the sub-vector supported load / store instructions are predicted instructions associated with a prediction value; and The instruction decoder is configured to, in response to the sub-vector supporting a load / store instruction, control the processing circuit to control execution or masking of each transfer of the one or more sub-vectors based on a prediction bit selected from the prediction value at a sub-vector granularity.
18. An apparatus according to any preceding claim, wherein the instruction decoder is configured to, in response to sub-vectors supporting increment / decrement instructions, control the processing circuitry to increment or decrement an operand value based on how many sub-vector sized portions of a vector are indicated as valid by bits of the prediction value selected from the prediction value at the sub-vector granularity.
19. The apparatus of claim 18, wherein the predicted value is one of: a predicted value specified as a predicted operand by the increment / decrement instruction supported by the subvector; and The sub-vector supports prediction values represented by a prediction mode identifier specified by the increment / decrement instructions, the prediction mode identifier specifying a predetermined pattern of prediction bits at a sub-vector granularity.
20. Apparatus according to any preceding claim, wherein the instruction decoder is configured to, in response to a sub-vector supported prediction set instruction, control the processing circuitry to perform a prediction set operation to set bits of a prediction value at a sub-vector granularity to indicate which sub-vectors in a vector are valid.
21. The apparatus of claim 20, wherein the prediction setting operation comprises setting the prediction value based on one of: a prediction mode identifier that specifies a predetermined pattern of prediction bits to be applied at a sub-vector granularity; and A sub-vector granularity comparison operation is based on a comparison of a first operand with a second operand.
22. A method comprising: using instruction decode circuitry to decode program instructions defined in accordance with a scalable vector instruction set architecture that supports vector instructions operating on vectors of scalable vector lengths to enable the same sequence of instructions to be executed on devices having hardware supporting different maximum vector lengths; as well as controlling processing circuitry to perform data processing in response to decoding of said program instructions; wherein: The instruction decoding circuitry and the processing circuitry support sub-vector support instructions that treat a given vector as comprising a plurality of sub-vectors, wherein each sub-vector comprises a plurality of vector elements, each sub-vector having an equal sub-vector length; and In response to the sub-vector support instruction, the instruction decoding circuitry controls the processing circuitry to perform operations on the given vector at a sub-vector granularity.
23. A computer program for controlling a host data processing device to provide an instruction execution environment for the execution of object code; the computer program comprising: Instruction decoding program logic, the instruction decoding program logic is used to decode the instructions of the target code to control the host data processing device to perform data processing in response to the instructions of the target code; wherein: the instruction decode program logic supporting decoding of program instructions defined in accordance with a scalable vector instruction set architecture supporting vector instructions operating on vectors of scalable vector lengths to enable the same instruction sequence to be executed on devices having hardware supporting different maximum vector lengths; The instruction decode program logic includes sub-vector support instruction decode program logic to decode a sub-vector support instruction that treats a given vector as comprising a plurality of sub-vectors, wherein each sub-vector comprises a plurality of vector elements, each sub-vector having an equal sub-vector length; and The instruction decode program logic is configured to, in response to the sub-vector support instruction, control the host data processing device to perform operations on the given vector at a sub-vector granularity.
24. A storage medium storing the computer program according to claim 23.
