RISC-V segment data reading vector instruction processing method and device
By using temporary architecture registers in the RISC-V system to temporarily store segment data and copy them to the target register, the CPU performance reduction and power consumption increase caused by frequent memory or cache access is solved, and more efficient data transfer and performance improvement is achieved.
Patent Information
- Application Number
- CN202411114126.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-14
AI Technical Summary
The frequent memory or cache access of existing RISC-V segment data read instructions leads to problems such as degraded CPU performance and increased power consumption.
By using temporary architecture registers to temporarily store segment data and copy it to the target register, reducing the number of memory or cache accesses, multiple micro-instructions are used to process segment data reading tasks.
Improves CPU performance, reduces power consumption of memory or cache access, and improves data transfer efficiency between vector registers.
Smart Images

Figure CN118981336A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a RISC-V segment data reading vector instruction processing method and device. Background Art
[0002] The RISC-V vector instruction set is one of the many standard instruction set extensions of RISC-V, which is used to support the single instruction multiple data (SIMD) computing mode to improve the computing power and efficiency of the corresponding CPU. The register width used by SIMD instructions is generally 128 bits or wider, and each vector register contains multiple integer metadata with a width of 8 / 16 / 32 / 64 bits or 16 / 32 / 64-bit floating-point metadata. In the common SIMD instruction set, the register and data width corresponding to each instruction is fixed. A RISC-V vector instruction can be used for different registers and data widths. The advantage of this is that an application using RISC-V vector instructions can run on multiple CPU implementations with different register widths without making any modifications.
[0003] There is a type of RISC-V vector data read and write instructions called segment load / store instructions. Segment load / store instructions support the above-mentioned address calculation methods, but a block of segment data in memory or cache corresponds to metadata from the same position of multiple registers. A block of segment data contains NFIELD block metadata, where NFIELD can select an integer between 1 and 8. NFIELD=1 is a normal, non-segment vector data read and write instruction. NFIELD>1 is a segment load / store instruction. NFIELD is a 3-bit field in the opcode (operation code) of the data read and write instruction.
[0004] For the segment load instruction, the general implementation method is to use each of its metadata as a data reading unit to access the memory or cache. Although the function is correct, due to the large number of memory or cache accesses and the small amount of data read each time, it will affect the overall performance of the CPU and increase the power consumption of the CPU.
[0005] To address the above problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of this specification provide a RISC-V segment data read vector instruction processing method and device to solve the problem of reducing CPU system performance and increasing power consumption due to frequent memory or cache access when implementing segment load instructions in the prior art.
[0007] The embodiment of this specification provides a RISC-V segment data read vector instruction processing method, including:
[0008] In response to a segment data read vector instruction, segment data is read from a memory or a cache, and the read segment data is temporarily stored in a temporary architecture register; the segment data includes a plurality of metadata; the temporary architecture register is an architecture register defined in the CPU core implementation, and is only used to temporarily store and transfer data within an instruction;
[0009] The plurality of metadata in the segment data in the temporary architecture register are written into the plurality of target registers respectively.
[0010] In one embodiment, the method further comprises:
[0011] Acquire multiple parameters of the segment data read vector instruction; the multiple parameters include: vector read address calculation mode, register group length, number of metadata contained in the segment data, metadata width, vector register width supported by the CPU core, and cache read width supported by the CPU core;
[0012] Decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions include: integer value read microinstructions, memory read microinstructions and data move microinstructions;
[0013] Accordingly, in response to the segment data read vector instruction, the segment data is read from the memory or cache, and the read segment data is temporarily stored in the temporary architecture register, including:
[0014] Executing the integer value read microinstruction to read the address base value or the address base value and the offset value from the integer architecture register and store them in the corresponding first temporary architecture register;
[0015] Execute the memory read microinstruction to read the address base value or the address base value and the offset value from the first temporary architectural register, generate address data according to the address base value or the address base value and the offset value, and read segment data from the memory or cache based on the address data and write it into the corresponding second temporary architectural register;
[0016] Accordingly, writing the plurality of metadata in the segment data in the temporary architecture register into the plurality of target registers respectively includes:
[0017] The data move microinstruction is executed to copy a plurality of metadata in the segment data in the second temporary architecture register to a plurality of target registers respectively.
[0018] In one embodiment, the segment data read vector instruction is decoded based on the multiple parameters to obtain multiple microinstructions, including:
[0019] Determine a first quantity according to a vector read address calculation mode of the segment data read vector instruction to generate a first quantity integer value read microinstruction;
[0020] Determine a second number based on a vector read address calculation mode of the segment data read vector instruction, a register group length, a number of metadata contained in the segment data, a metadata width, a vector register width supported by the CPU core, and a cache read width supported by the CPU core, so as to generate a second number of memory read microinstructions;
[0021] A third number is determined according to the register group length and the number of metadata included in the segment data to generate a third number of data movement microinstructions.
[0022] In one embodiment, the vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode, and an index address calculation mode;
[0023] Accordingly, determining a first quantity according to the vector read address calculation mode of the segment data read vector instruction to generate a first quantity integer value read microinstruction includes:
[0024] When the vector read address calculation mode is a unit stride address calculation mode or an index address calculation mode, generating an integer value read microinstruction to read an address base value and store it in a first temporary architecture register;
[0025] When the vector read address calculation mode is the stride address calculation mode, two integer value read microinstructions are generated to read the address base value and the offset value respectively and store them in two first temporary architecture registers respectively.
[0026] In one embodiment, the vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode, and an index address calculation mode;
[0027] Accordingly, determining the second quantity based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core includes:
[0028] When the vector read address calculation mode is the unit stride address calculation mode, the second number is the product of the vector register width supported by the CPU core, the register group length, and the number of metadata included in the segment data divided by the cache read width supported by the CPU core;
[0029] When the vector read address calculation mode is the stride address calculation mode or the index address calculation mode, determine whether the minimum value of the product of the number of metadata contained in the segment data and the metadata width and the cache read width supported by the CPU core is a power of 2. If so, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value; otherwise, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value plus the product of the register group length and the number of metadata contained in the segment data minus 1.
[0030] In one embodiment, determining the third quantity according to the register group length and the number of metadata included in the segment data includes:
[0031] When the segment data read vector instruction is in a maskless mode, if the product of the number of metadata included in the segment data and the register group length is less than or equal to 4, the third number is equal to the number of metadata included in the segment data; otherwise, the third number is equal to twice the number of metadata included in the segment data;
[0032] In the case where the segment data read vector instruction is a mask mode, if the product of the number of metadata contained in the segment data and the register group length is less than or equal to 3, the third number is equal to the number of metadata contained in the segment data; if the product of the number of metadata contained in the segment data and the register group length is greater than 3 and less than or equal to 6, the third number is equal to twice the number of metadata contained in the segment data; if the product of the number of metadata contained in the segment data and the register group length is greater than 6, the third number is equal to three times the number of metadata contained in the segment data.
[0033] In one embodiment, the data move microinstruction includes the location of the first metadata to be copied in the second temporary architectural register and the location of the first metadata in the target register.
[0034] In one embodiment, decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions further includes:
[0035] When the segment data read vector instruction is in mask mode, a fourth number of vector move microinstructions are generated, where the fourth number is the product of the register group length and the number of metadata contained in the segment data; the vector move microinstructions are used to copy the metadata without mask calculation in the source register to the target register.
[0036] In one embodiment, after decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions, the method further includes:
[0037] mapping the first temporary architectural register and the second temporary architectural register to physical registers;
[0038] Allocate physical registers to the target registers corresponding to the integer value read microinstruction, the memory read microinstruction and the data move microinstruction; the source register of the vector move microinstruction uses the physical register of the initial mapping of the target architecture register, and the target register of the vector move microinstruction uses the physical register allocated to the data move microinstruction;
[0039] The integer value read microinstruction, the memory read microinstruction, the data move microinstruction and the vector move microinstruction are distributed; the memory read microinstruction has a data dependency on the integer value read microinstruction; the data move microinstruction has a data dependency on the memory read microinstruction, and the vector move microinstruction has no dependency on the integer value read microinstruction, the memory read microinstruction and the data move microinstruction.
[0040] The embodiment of this specification also provides a RISC-V segment data read vector instruction processing device, including:
[0041] A reading module, configured to read segment data from a memory or a cache in response to a segment data read vector instruction, and temporarily store the read segment data in a temporary architecture register; the segment data includes a plurality of metadata; the temporary architecture register is an architecture register defined in the CPU core implementation, and is only used to temporarily store and transfer data within an instruction;
[0042] The writing module is used to write multiple metadata in the segment data in the temporary architecture register into multiple target registers respectively.
[0043] In an embodiment of the present specification, a RISC-V segment data read vector instruction processing method is provided, which can respond to the segment data read vector instruction, read the segment data from the memory or cache, and temporarily store the read segment data in a temporary architecture register; the segment data includes multiple metadata; the temporary architecture register is an architecture register defined in the CPU core implementation, which is only used to temporarily store data and transfer data within an instruction; and the multiple metadata in the segment data in the temporary architecture register are written into multiple target registers respectively. This scheme uses temporary architecture registers to save segment data, and memory or cache access uses larger segment data (rather than multiple metadata in segment data) as the granularity, at the cost of increasing data transfer between vector registers, reducing the number of cache / memory accesses, thereby improving CPU core performance and reducing power consumption of accessing cache / memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The drawings described herein are used to provide a further understanding of this specification, constitute a part of this specification, and do not constitute a limitation of this specification. In the drawings:
[0045] Figure 1 A schematic diagram showing the format of a RISC-V vector data read instruction;
[0046] Figure 2 The data corresponding to the RISC-V segment data read vector instruction with NFIELD of 3 is shown;
[0047] Figure 3 A flow chart of a RISC-V segment data read vector instruction processing method in an embodiment of this specification is shown;
[0048] Figure 4 An example diagram of a RISC-V segment data read vector instruction processing method in an embodiment of this specification is shown;
[0049] Figure 5 A schematic diagram showing the data dependency relationship between microinstructions generated by a RISC-V segment data read vector instruction in an embodiment of this specification is shown;
[0050] Figure 6 A schematic diagram of a RISC-V segment data read vector instruction processing device in one embodiment of the present specification is shown. DETAILED DESCRIPTION
[0051] The principles and spirit of this specification will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement this specification, and are not intended to limit the scope of this specification in any way. On the contrary, these embodiments are provided to make this specification more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art.
[0052] Those skilled in the art will appreciate that the embodiments of this specification may be implemented as a system, device, method, or computer program product. Therefore, this specification may be implemented in the following forms: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0053] In the RISC-V vector instruction set, the metadata width is represented by SEW (selected element width). A feature of the RISC-V vector instruction set is register grouping, whose setting is called LMUL (register group length). LMUL is used to indicate that the RISC-V vector architecture supports one instruction to read and write multiple registers (called register groups) or part of a register. When LMUL>1, one instruction can read and write multiple consecutive vector registers. LMUL is configured by the application at runtime, and the selectable values are [1 / 8, 1 / 4, 1 / 2, 1, 2, 4, 8].
[0054] Most RISC-V vector instructions support masked computing, that is, the instruction only writes the metadata with mask (i.e., the corresponding mask bit is 1) in the target register, while the value of the metadata without mask (i.e., the corresponding mask bit is 0) does not change. For these instructions, the vm bit is used in the opcode to indicate whether masked computing is performed. vm=1 means no masked computing, and all metadata calculation results will be written to the register. vm=0 means masked computing, and the mask value comes from the architectural register v0. At this time, each bit in v0 starting from the low bit identifies a metadata. When v0[i] is 1, the calculation result can be written to the corresponding i-th metadata, otherwise it is not written.
[0055] Many CPU cores implement register renaming, which maps an architectural register to a physical register in the core to avoid false register dependencies such as write-after-read and write-after-write, so as to improve the instruction level parallelism (ILP) and performance of CPU instruction processing. For such CPU cores that implement register renaming, masked instructions need to copy unmasked metadata from the old target physical register A to the new target physical register B of the same architectural register mapping to ensure that the values of these metadata do not change. At this time, a masked instruction needs to read four different physical register values: 2 sources, 1 mask, and a currently mapped target physical register.
[0056] RISC-V vector data read / write (load / store) instructions have the following address calculation methods.
[0057] Unit-stride (unit stride address calculation mode): The memory addresses corresponding to consecutive metadata are also consecutive, that is, the memory address interval between two consecutive metadata is the byte width of one metadata. Unit-stride load / store uses the base from the integer register to identify the address of the first metadata.
[0058] Strided (stridden address calculation mode): The memory addresses of consecutive metadata have a fixed interval (offset). The offset is not equal to the byte width of the corresponding metadata. Strided load / store uses the form of base+N×offset to calculate the address of each metadata. The base and offset values are both from integer registers.
[0059] Indexed (indexed address calculation mode): continuous metadata is not continuous in memory. The offset value corresponding to the metadata of an instruction comes from another (or a group of) vector registers. Indexed data read and write instructions have two subcategories: ordered and unordered. Indexed load / store uses the form of base+V[i] to calculate the address of each metadata. The base value comes from the integer register, and the offset value V[i] comes from the vector register (group).
[0060] Figure 1 The format of the RISC-V vector load instruction is shown. Figure 1The above figure shows the VL*unit-stride instruction, which is a vector data read instruction with the address calculation mode of unit-stride. Figure 1 The middle figure shows the VLS*strided instruction, that is, the vector data read instruction with the address calculation mode being strided. Figure 1 The following figure shows the VLX*indexed instruction, which is a vector data read instruction with the address calculation mode being indexed.
[0061] Among them, nf is used to indicate that a segment of data in a segment read / write instruction contains (nf+1) metadata. mew and width jointly determine the data width of metadata and index data, as shown in Table 1 below.
[0062] vm is used to determine whether the instruction is in mask mode, as shown in Table 2 below. The mop field is used to identify the address calculation method. The correspondence between the value of the mop field and the address calculation mode is shown in Table 3 below. rs1 is the base address value (baseaddress). vd is used to indicate the destination register to be read (destination of load), rs2 is the stride (stride), and vs2 is the address offset value (address offsets). The mop field is used to identify the address calculation method.
[0063] Lumop is used to further subdivide unit-stride load instructions as follows: whole register load is a subclass of unit-stride load, which reads the entire value of one or a group of registers from memory or cache, as shown in Table 4 below.
[0064] Table 1
[0065]
[0066] Table 2
[0067] vm describe 0 Vector result, only where vO.mask[i]=1 1 Non-mask
[0068] Table 3
[0069]
[0070] Table 4
[0071]
[0072]
[0073] Figure 2 The data corresponding to the segment strided load with NFIELD of 3 is shown. Figure 2 The top row is the location of the segment data in memory, and the bottom three rows are the corresponding locations of the read data in the target vector register. The RISC-V standard requires LMUL×NFIELD<=8. Segment load instructions may also be masked or maskless, and the mask is performed at the segment granularity. For segment load instructions, the general implementation method is to access memory at the granularity of metadata. This will cause too much memory access for a segment load instruction. For example, when the register is 128 bits wide (VLEN=128), a normal LMUL=3, SEW=16-bit unit-stride load instruction only needs to access the memory three times to read the data of the three registers. The corresponding segment unit-stride load with LMUL=1, NFIELD=3, SEW=16 bits needs to access the memory 24 times (i.e. 128×3 / 16). Compared with data movement between registers, the bandwidth from the CPU core to the cache / memory is limited, the latency is longer, and the power consumption required for access is greater. Therefore, frequent memory accesses will reduce CPU system performance and increase power consumption.
[0074] In order to solve the above problems, an embodiment of the present specification provides a RISC-V segment data read vector instruction processing method. Figure 3 A flowchart of a RISC-V segment data read vector instruction processing method in an embodiment of this specification is shown. Although this specification provides method operation steps or device structures as shown in the following embodiments or drawings, more or fewer operation steps or module units may be included in the method or device based on routine or no creative labor. In the steps or structures where there is no necessary causal relationship logically, the execution order of these steps or the module structure of the device is not limited to the execution order or module structure described in the embodiments of this specification and shown in the drawings. When the method or module structure is applied to an actual device or terminal product, it can be connected according to the method or module structure shown in the embodiment or drawings for sequential execution or parallel execution (for example, a parallel processor or a multi-threaded processing environment, or even a distributed processing environment).
[0075] Specifically, Figure 3 As shown, a RISC-V segment data read vector instruction processing method provided by an embodiment of the present specification may include the following steps.
[0076] Step S301, in response to a segment data read vector instruction, segment data is read from a memory or a cache, and the read segment data is temporarily stored in a temporary architecture register; the segment data includes a plurality of metadata; the temporary architecture register is an architecture register defined in a CPU core implementation, and is only used to temporarily store and transfer data within an instruction.
[0077] Step S302, writing a plurality of metadata in the segment data in the temporary architecture register into a plurality of target registers respectively.
[0078] In this embodiment, a temporary architectural register (TAR) is used to temporarily store segment data obtained from memory or cache, and then a series of microinstructions are used to copy the data from the TAR to the target register. Since this solution replaces the memory read microinstruction with the register copy microinstruction inside the vector execution unit, both performance and power consumption are improved. In this embodiment, the difference between TAR and normal architectural registers is that TAR is only used inside an instruction to temporarily store data and transfer data between its multiple microinstructions. However, normal architectural registers need to transfer data between multiple instructions.
[0079] Since a RISC-V segment data read instruction needs to read four register values (two source registers, mask, and the initial value of the target register), it can be reasonably assumed that in a CPU core, each RISC-V vector instruction execution unit is allocated 4 vector register file read ports (that is, 4 different register values can be read from the vector register file in one clock cycle).
[0080] In this embodiment, by using temporary architectural registers to save segment data, memory or cache access uses larger segment data (rather than multiple metadata within the segment data) as the granularity, at the cost of increasing data transfer between vector registers, thereby reducing the number of cache / memory accesses, thereby improving CPU core performance and reducing power consumption of accessing cache / memory.
[0081] In some embodiments of the present specification, the method further includes: obtaining multiple parameters of the segment data read vector instruction; the multiple parameters include: vector read address calculation mode, register group length, the number of metadata contained in the segment data, metadata width, vector register width supported by the CPU core, and cache read width supported by the CPU core; decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions include: integer value read microinstructions, memory read microinstructions and data move microinstructions; accordingly, in response to the segment data read vector instruction, the segment data is read from the memory or cache, and the read segment data is temporarily stored in the temporary architecture register, including: executing the integer value read microinstruction to read an address base value or an address base value and an offset value from an integer architecture register and store them in a corresponding first temporary architecture register; execute the memory read microinstruction to read the address base value or the address base value and the offset value from the first temporary architecture register, generate address data according to the address base value or the address base value and the offset value, and read segment data from a memory or a cache based on the address data and write them into a corresponding second temporary architecture register; accordingly, write multiple metadata in the segment data in the temporary architecture register into multiple target registers respectively, including: executing the data move microinstruction to copy multiple metadata in the segment data in the second temporary architecture register into multiple target registers respectively.
[0082] In this embodiment, multiple parameters of the segment data read vector instruction can be obtained. The multiple parameters may include: vector read address calculation mode, register group length, the number of metadata contained in the segment data, metadata width, vector register width supported by the CPU core, and cache read width supported by the CPU core. Among them, the vector read address calculation mode refers to the address calculation method of the vector instruction. The vector read address calculation mode includes one of the following: unit stride address calculation mode (Unit-stride), stride address calculation mode (Strided) and index address calculation mode (Indexed). The register group length LMUL means that the RISC-V vector architecture supports one instruction to read and write multiple registers (called register groups) or part of a register. This is controlled by the LMUL field in the vtype vector VCSR, and the optional value of the field is [1 / 8, 1 / 4, 1 / 2, 1, 2, 4, 8]. The metadata contained in the segment data refers to the metadata from the same position in multiple registers included in a segment data. The number of metadata contained in the segment data NFIELD is the number of metadata contained in a segment data. In the RISC-V vector architecture, a vector register contains multiple metadata. The size of each metadata is controlled by the SEW field in the vtype vector VCSR. The metadata width SEW can be an 8 / 16 / 32 / 64-bit integer or a 32 / 64-bit floating point. The vector register width VLEN supported by the CPU core is the number of vector register bits used by a RISC-V CPU core, which needs to be a multiple of 2 and >= 128. The cache read width supported by the CPU core is DLEN, and generally DLEN<=VLEN.
[0083] The segment data read vector instruction can be decoded based on the multiple parameters to obtain multiple microinstructions. Specifically, the type, quantity and parameters of the microinstructions to be generated can be determined according to the multiple parameters, so as to decode the end data read vector instruction to obtain multiple microinstructions. The multiple microinstructions include: integer value read microinstructions, memory read microinstructions and data move microinstructions. Among them, the integer value read microinstruction is used to read the address base value or the address base value and the offset value from the integer architecture register and store it in the corresponding first temporary architecture register. The memory read microinstruction is used to read the address base value or the address base value and the offset value from the first temporary architecture register, generate address data according to the address base value or the address base value and the offset value, and read the segment data from the memory or the cache based on the address data and write it into the corresponding second temporary architecture register. The data move microinstruction is used to copy multiple metadata in the segment data in the second temporary architecture register to multiple target registers respectively.
[0084] In one embodiment, 10 TAR registers may be set, where TAR0 and TAR1 store addresses to generate the required integer values, and the other 8 TARs (TAR2 to TAR9) support segment load instructions when LMUL×NFIELD is up to 8. It is understood that other numbers of TAR registers may also be set. For example, 3 TAR registers may be set, where registers TAR0 and TAR1 store addresses to generate the required integer values, and another TAR2 is used to support segment load instructions. In this case, more conversions and more microinstructions may be required.
[0085] The integer value read microinstruction can be executed to read the address base value or the address base value and the offset value from the integer architecture register and store it in the corresponding first temporary architecture register. The memory read microinstruction can also be executed to read the address base value or the address base value and the offset value from the first temporary architecture register, generate address data according to the address base value or the address base value and the offset value, and read the segment data from the memory or cache based on the address data and write it into the corresponding second temporary architecture register. The data move microinstruction can also be executed to copy multiple metadata in the segment data in the second temporary architecture register to multiple target registers respectively. In the above manner, a temporary architecture register is used to temporarily store the segment data obtained from the memory or cache, and then a series of microinstructions are used to copy the data from the TAR to the target register, and the memory read microinstruction is replaced by the register copy microinstruction inside the vector execution unit, and both performance and power consumption are improved.
[0086] In some embodiments of the present specification, the segment data read vector instruction is decoded based on the multiple parameters to obtain multiple microinstructions, including: determining a first quantity based on the vector read address calculation mode of the segment data read vector instruction to generate a first quantity of integer value read microinstructions; determining a second quantity based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core to generate a second quantity of memory read microinstructions; determining a third quantity based on the register group length and the number of metadata contained in the segment data to generate a third quantity of data move microinstructions.
[0087] Specifically, the integer value read microinstruction is used to read the address base value or the address base value and the offset value, and the address-related parameters are related to the vector read address calculation mode. Therefore, the first quantity can be determined according to the vector read address calculation mode of the segment data read vector instruction to generate the first number of integer value read microinstructions. The memory read microinstruction is used to read the end data from the memory or cache. Therefore, the second quantity can be determined based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core to generate the second number of memory read microinstructions. The data move microinstruction is used to read the metadata in the segment data from the second temporary architecture register. Therefore, the third quantity can be determined according to the register group length and the number of metadata contained in the segment data to generate the third number of data move microinstructions. In the above manner, the number of microinstructions to be generated can be determined.
[0088] In some embodiments of the present specification, the vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode and an index address calculation mode; accordingly, a first quantity is determined according to the vector read address calculation mode of the segment data read vector instruction to generate a first quantity of integer value read microinstructions, including: when the vector read address calculation mode is a unit stride address calculation mode or an index address calculation mode, an integer value read microinstruction is generated to read the address base value and store it in a first temporary architecture register; when the vector read address calculation mode is a stride address calculation mode, two integer value read microinstructions are generated to read the address base value and the offset value respectively and store them in two first temporary architecture registers respectively.
[0089] When the vector read address calculation mode is the unit stride address calculation mode or the index address calculation mode, an integer value read microinstruction is generated to read the address base value and store it in a first temporary architecture register. That is, a first temporary architecture register is used to store the address base value. When the vector read address calculation mode is the stride address calculation mode, two integer value read microinstructions are generated to read the address base value and the offset value respectively and store them in two first temporary architecture registers respectively. That is, one first temporary architecture register is used to store the address base value, and the other first temporary architecture register is used to store the offset value.
[0090] In some embodiments of the present specification, the vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode, and an index address calculation mode. Accordingly, the second quantity is determined based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core, including: when the vector read address calculation mode is the unit stride address calculation mode, the second quantity is the product of the vector register width supported by the CPU core, the register group length, and the number of metadata contained in the segment data divided by the cache read width supported by the CPU core. In the case where the vector read address calculation mode is the stride address calculation mode or the index address calculation mode, determine whether the product of the number of metadata contained in the segment data and the metadata width and the minimum value of the cache read width supported by the CPU core is a power of 2. If so, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value; otherwise, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value plus the product of the register group length and the number of metadata contained in the segment data minus 1. In the above manner, the number of memory read microinstructions to be generated in different address calculation modes can be determined.
[0091] In some embodiments of the present specification, the third quantity is determined according to the register group length and the number of metadata contained in the segment data, including: when the segment data read vector instruction is in the maskless mode, if the product of the number of metadata contained in the segment data and the register group length is less than or equal to 4, then the third quantity is equal to the number of metadata contained in the segment data; otherwise, the third quantity is equal to twice the number of metadata contained in the segment data; when the segment data read vector instruction is in the mask mode, if the product of the number of metadata contained in the segment data and the register group length is less than or equal to 3, then the third quantity is equal to the number of metadata contained in the segment data; if the product of the number of metadata contained in the segment data and the register group length is greater than 3 and less than or equal to 6, then the third quantity is equal to twice the number of metadata contained in the segment data; if the product of the number of metadata contained in the segment data and the register group length is greater than 6, then the third quantity is equal to three times the number of metadata contained in the segment data. In the above manner, the number of data movement microinstructions to be generated in different address calculation modes can be determined.
[0092] In some embodiments of the present specification, the data movement microinstruction includes the position of the first metadata to be copied in the second temporary architectural register and the position of the first metadata in the target register. The data movement microinstruction may also include the position of the first metadata to be copied in the second temporary architectural register and the position of the first metadata in the target register. Based on the above position parameters, the data movement microinstruction can read the metadata from the second temporary architectural register and store it in the target register.
[0093] In some embodiments of the present specification, the segment data read vector instruction is decoded based on the multiple parameters to obtain multiple microinstructions, and also includes: when the segment data read vector instruction is a mask mode, a fourth number of vector move microinstructions is generated, and the fourth number is the product of the register group length and the number of metadata included in the segment data; the vector move microinstruction is used to copy the metadata without mask calculation in the source register to the target register.
[0094] In this embodiment, since the RISC-V vector instruction supports mask calculation. Therefore, when decoding the segment data read vector instruction, when the segment data read vector instruction is in mask mode, a fourth number of vector move microinstructions can also be generated, and the fourth number is the product of the register group length and the number of metadata contained in the segment data. The vector move microinstruction is used to copy the metadata without mask calculation in the source register to the target register. That is, the masked segment load (segment data read in mask mode) instruction will generate VMUL×NFIELD VMV microinstructions (vector move microinstructions) to copy the metadata content of mask=0 of the old target register to the new target register. The Maskless segment load (segment data read in non-mask mode) instruction does not need to generate VMV microinstructions. In the above manner, the masked segment load instruction needs to copy the unmasked (unmasked) metadata from the old target physical register A to the new target physical register mapped by the same architecture register to ensure that the values of these metadata do not change.
[0095] In some embodiments of the present specification, after decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions, it also includes: mapping the first temporary architecture register and the second temporary architecture register to physical registers; allocating physical registers to the integer value read microinstruction, the memory read microinstruction and the target registers corresponding to the data move microinstruction; the source register of the vector move microinstruction uses the physical register of the initial mapping of the target architecture register, and the target register of the vector move microinstruction uses the physical register allocated to the data move microinstruction; distributing the integer value read microinstruction, the memory read microinstruction, the data move microinstruction and the vector move microinstruction; the memory read microinstruction has a data dependency on the integer value read microinstruction; the data move microinstruction has a data dependency on the memory read microinstruction, and the vector move microinstruction has no dependency on the integer value read microinstruction, the memory read microinstruction and the data move microinstruction.
[0096] In this embodiment, after decoding to obtain multiple microinstructions, register renaming can be performed, that is, mapping an architectural register to a physical register in the kernel to avoid false register dependencies such as write-after-read and write-after-write, so as to improve the parallelism (ILP) and performance of CPU instruction processing. For such CPU kernels that implement register renaming, masked instructions need to copy unmasked metadata from the old target physical register A to the new target physical register B mapped by the same architectural register to ensure that the values of these metadata do not change. Specifically, at this stage, architectural registers, including TAR, will be mapped to physical registers. The target registers of the integer value read microinstruction, the memory read microinstruction, and the data move microinstruction will be assigned new physical registers. It should be noted that the target register of the VMV microinstruction does not need to map a new physical register: its source register uses the physical register mapped by the old (i.e., before this segment load instruction) mapping of the target architectural register, and its target register uses the physical register newly mapped by this instruction VCOMPRESS.
[0097] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. For details, please refer to the description of the above-mentioned related processing related embodiments, and no further description is given here.
[0098] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0099] The above method is described below in conjunction with a specific embodiment. However, it should be noted that the specific embodiment is only for better illustrating the present specification and does not constitute an improper limitation on the present specification.
[0100] In this specific embodiment, a RISC-V segment data read vector instruction processing method is proposed. This scheme uses temporary architecture registers to temporarily store segment data obtained from memory or cache, and then uses a series of microinstructions to copy the data from TAR to the target register. Since this scheme replaces the memory read microinstruction with the register copy microinstruction inside the vector execution unit, both performance and power consumption are improved. The difference between TAR and normal architecture registers is that TAR is only used inside an instruction to temporarily store and transfer data between its multiple microinstructions, while normal architecture registers need to transfer data between multiple instructions. This scheme sets 10 TAR registers, of which TAR0 and TAR1 store the integer values required for address generation, and the other 8 TARs (TAR2 to TAR9) support segment load instructions when LMUL×NFIELD is up to 8.
[0101] Since a RISC-V instruction needs to read four register values (two source registers, mask, and the initial value of the target register), we can reasonably assume that in a CPU core, each RISC-V vector instruction execution unit is allocated 4 vector register file read ports (that is, 4 different register values can be read from the vector register file in one clock cycle).
[0102] The base (address base value) in the address calculation of the vector load instruction and the offset (address offset value) of the stride load both come from integer registers. High-performance CPU cores generally have separate physical register files for integer and vector registers. When a vector instruction uses an integer register, a corresponding I2V microinstruction is generated to read the corresponding source register value from the integer register file and write it to the TAR target vector register. Other microinstructions in the same instruction obtain the integer value from the TAR. Since the RISC-V vector load instruction uses at most two integer registers, this solution reserves two TAR registers to temporarily store integer values.
[0103] Figure 4 An example diagram of the RISC-V segment data read vector instruction processing method in this specific embodiment is shown. Figure 4 As shown, it is a schematic diagram of the implementation of a maskless segment strideload with VLEN=128b, NFIELD=3, LMUL=1, SEW=16b. In this scheme, the instruction is decomposed into 10 (instead of 24 in the prior art scheme) VLD data read microinstructions, and the cache / memory data is saved in three TARs. Then, three VCOMPRESS microinstructions write the metadata from the TAR to the three target registers at the required locations.
[0104] The method in this specific embodiment includes the following steps.
[0105] Decoding: According to the LMUL, NFIELD, SEW values of a segment load instruction and the vector register width VLEN supported by the CPU core, the instruction is decoded into multiple VLD, VCOMPRESS and VMV microinstructions. The cache read width supported by the CPU core is DLEN, and generally DLEN<=VLEN.
[0106] Integer value read microinstruction I2V: This microinstruction reads an integer architectural register and writes the result to a vector TAR. Unit-stride and indexed load instructions only generate one I2V to read the base value and put it into TAR0. Stride load instructions need to generate two I2Vs to read the base and offset values and put them into TAR0 and TAR1.
[0107] Memory read microinstruction VLD: Like most CPU core implementations, this solution requires a VLD microinstruction to have only one target TAR register. This microinstruction reads data from the memory / cache and writes it to the entire TAR register or a portion of the TAR register. During the decoding stage, the partially written VLD needs to set the starting offset (offset) and data width (size) of the write data in the register.
[0108] For the unit-stride mode, (VLEN×LMUL×NFIELD / DLEN) VLD microinstructions are generated, each of which reads DLEN-width data from the memory or cache and writes it to a TAR register. The steps for the unit-stride load of the masked / maskless segments are the same, regardless of the mask value.
[0109] For the Stride / Indexed mode, each VLD reads up to min(DLEN, NFIELD×SEW) bits of data from memory or cache. If min(DLEN, NFIELD×SEW) is a power of 2, (VLEN×NFIELD×LMUL) / min(NFIELD×SEW, DLEN) VLD microinstructions are generated. If min(DLEN, NFIELD×SEW) is not a power of 2, (VLEN×NFIELD×LMUL) / min(NFIELD×SEW, DLEN) + LMUL×(NFIELD - 1) VLD microinstructions are generated. The additional LMUL×(NFIELD - 1) microinstructions are due to the fact that some segment data (such as [C2, B2, A2] in the figure above) need to be stored in two registers and thus need to be split into two VLDs.
[0110] Data movement microinstruction VCOMPRESS: This microinstruction copies metadata from the TAR where all data are ready to the destination register according to the segment index generated by the decoder.
[0111] For the maskless mode, since there is no need to occupy a register file read port to read the mask, one maskless VCOMPRESS can read 4 TAR registers. For LMUL×NFIELD <= 4, only one VCOMPRESS is required for each destination register. If LMUL×NFIELD > 4, then two VCOMPRESSs are required for each destination register to process the corresponding segment metadata in TAR[0, 1, 2, 3] and TAR[4, 5, 6, 7] respectively.
[0112] For the masked mode, in the masked mode, one source register needs to be reserved for the mask. Therefore, each masked VCOMPRESS can read at most 3 TARs. For LMUL×NFIELD <= 3, only one masked VCOMPRESS is required for each destination register. When 3 < LMUL×NFIELD <= 6, two masked VCOMPRESSs are required for each destination register. When LMUL×NFIELD > 6, three masked VCOMPRESSs are required for each destination register.
[0113] The metadata at offset in several consecutive TARs and the metadata at offset+NFIELD, offset+2×NFIELD, …, offset+N×NFIELD will be copied to consecutive locations in the destination register. Therefore, VCOMPRESS only needs to provide the position of the first metadata to be copied in TAR, start TAR offset, and its position in the destination register (start Dest offset), and then this metadata and the subsequent metadata of the same destination register can be copied from the given 3 or 4 TAR registers to the destination register.
[0114] In mask mode, before copying to the target register, it is necessary to determine whether the mask corresponding to each metadata is 0. If it is 0, the metadata will not be copied into the target register.
[0115] The masked segment load instruction will generate VMUL×NFIELD VMV microinstructions to copy the metadata content of the old target register with mask=0 to the new target register. The maskless segment load instruction does not need to generate VMV microinstructions.
[0116] During the register renaming phase, architectural registers including TAR are mapped to physical registers. The target registers of I2V / VLD / VCOMPRESS microinstructions are assigned new physical registers. It should be noted that the target register of VMV microinstruction does not need to be mapped to a new physical register: its source register uses the old (i.e. before the current segment load) mapped physical register of the target architectural register, and its target register uses the newly mapped physical register of this instruction VCOMPRESS.
[0117] Like ordinary instructions, microinstructions can be distributed and executed when the source registers and other hardware resources (such as execution units and load queues) are ready. Among the microinstructions generated by the same segment load decoding, VLD has data dependency on I2V, and VCOMPRESS has data dependency on VLD. VMV has no data dependency on VCOMPRESS and VLD, so VMV may be executed before VLD / VCOMPRESS of the same instruction.
[0118] During the microinstruction execution phase, I2V: copies the base / offset value from the integer physical register to TAR0 / TAR1. VLD is the same as the normal data read (load) instruction. VLD needs to go through address generation, address translation (converting virtual address to physical address), data cache access and other steps. VLD is no different from the normal data read operation, and the implementation details are omitted here. For the unmasked mode, VCOMPRESS copies the segment metadata from up to 4 specified source registers according to the segment index, and arranges them in sequence in the target register. For the masked mode, VCOMPRESS copies the segment metadata from up to 3 specified source registers according to the segment index, and arranges them in sequence in the target register. When the mask bit of a metadata is 0, the metadata is not copied to the target register. The VMV instruction is only generated in the masked mode. Each VMV microinstruction reads two source registers: one is the mask, and the other is the old physical register corresponding to the target register. In contrast to other masked microinstructions that use masks, VMV only copies metadata to the target register when the mask corresponding to a metadata is 0.
[0119] The microinstruction retirement for segment load is not much different from the retirement for other microinstructions, so we will not go into details here.
[0120] Please refer to Figure 5 , shows the data dependencies between the microinstructions generated by a segment load instruction, and how they establish this data dependency through the TAR register. Due to these dependencies, a VLD can only be executed after the I2V it depends on is executed, and a VCOMPRESS can only be executed after the VLD it depends on is executed. A VMV does not depend on other microinstructions of the same instruction. Figure 5 TAR[0,1] in the table are first temporary architecture registers TAR0 and TAR1. TAR[2-9] are second temporary architecture registers TAR2 to TAR9.
[0121] Since the size of metadata in vector registers can be changed from 1 byte to 8 bytes. At the same time, different metadata for the same register may be set by different microinstructions. Before a microinstruction is executed, it must ensure that every metadata in every source register it uses has been obtained (ready). Therefore, each vector register file item has VLEN / 8 bits of valid bits in addition to the VLEN-bit data, and each valid bit corresponds to a byte of data for the item. For a masked segment load instruction, its VCOMPRESS microinstruction will write the masked read metadata to the target physical register and set the corresponding valid bit, while the VMV microinstruction will copy the unmasked metadata from the old physical register corresponding to the target register to the newly mapped physical register of the target register and set the corresponding valid bit. In this way, each metadata of the segment load target register has and only has one VCOMPRESS or VMV microinstruction to provide data.
[0122] In addition, in the register renaming unit, since 10 temporary architectural registers (TARs) are added, the corresponding architectural / prediction register mapping table also needs to add 10 entries to include these TARs.
[0123] For RISC-V vector segment load instructions, this solution proposes a solution that uses temporary architectural registers to save segment data and memory accesses at the granularity of larger segment data (rather than multiple metadata within the segment data). This solution reduces the number of cache / memory accesses at the cost of data transfer between vector registers. The specific implementation steps of the solution are described in detail.
[0124] In this solution, the release of the physical register mapped by the temporary architectural register is the same as that of the ordinary architectural register. When an architectural register mapping is written into the architectural mapping table, the physical register corresponding to the replaced item is released and can be used for new mapping. Since the temporary architectural register only transfers data between multiple microinstructions within an instruction, the physical register mapped by it can be released when the instruction retires. In this way, the utilization rate of the physical register can be improved. However, optimizing specifically for the TAR register mapping will increase the logical complexity of register renaming.
[0125] This solution reserves 8 TARs to temporarily store segment data. A possible solution may require only fewer TARs, such as only 4. The advantage of this solution is that fewer register mapping table entries can be used for register renaming, but the disadvantage is that when LMUL×NFIELD is greater than the number of reserved TARs, the renaming of a TAR to a physical register needs to be performed multiple times, and more VCOMPRESS microinstructions may need to be generated.
[0126] Based on the same inventive concept, a RISC-V segment data read vector instruction processing device is also provided in the embodiments of this specification, as described in the following embodiments. Since the principle of solving the problem by the RISC-V segment data read vector instruction processing device is similar to that of the RISC-V segment data read vector instruction processing method, the implementation of the RISC-V segment data read vector instruction processing device can refer to the implementation of the RISC-V segment data read vector instruction processing method, and the repeated parts will not be repeated. Figure 6 is a structural block diagram of a RISC-V segment data read vector instruction processing device according to an embodiment of this specification, such as Figure 6 As shown, it includes: a reading module 601 and a writing module 602, and the structure is described below.
[0127] The reading module 601 is used to respond to the segment data read vector instruction, read the segment data from the memory or cache, and temporarily store the read segment data in a temporary architecture register; the segment data includes multiple metadata; the temporary architecture register is an architecture register defined in the CPU core implementation, and is only used to temporarily store and transfer data within an instruction.
[0128] The writing module 602 is used to write the multiple metadata in the segment data in the temporary architecture register into multiple target registers respectively.
[0129] In some embodiments of the present specification, the device further includes a decoding module, which is specifically used to: obtain multiple parameters of the segment data read vector instruction; the multiple parameters include: vector read address calculation mode, register group length, the number of metadata contained in the segment data, metadata width, vector register width supported by the CPU core, and cache read width supported by the CPU core; decode the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions include: integer value read microinstructions, memory read microinstructions and data move microinstructions; accordingly, the reading module is specifically used to: execute the integer value A read microinstruction is used to read an address base value or an address base value and an offset value from an integer architecture register and store the address base value and the offset value in a corresponding first temporary architecture register; the memory read microinstruction is executed to read an address base value or an address base value and an offset value from the first temporary architecture register, address data is generated according to the address base value or the address base value and the offset value, and segment data is read from a memory or a cache based on the address data and written into a corresponding second temporary architecture register; accordingly, the write module is specifically used to: execute the data move microinstruction to copy multiple metadata in the segment data in the second temporary architecture register to multiple target registers respectively.
[0130] In some embodiments of the present specification, the decoding module is specifically used to: determine a first quantity based on a vector read address calculation mode of the segment data read vector instruction to generate a first quantity of integer value read microinstructions; determine a second quantity based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core to generate a second quantity of memory read microinstructions; determine a third quantity based on the register group length and the number of metadata contained in the segment data to generate a third quantity of data move microinstructions.
[0131] In some embodiments of the present specification, the vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode and an index address calculation mode; accordingly, a first quantity is determined according to the vector read address calculation mode of the segment data read vector instruction to generate a first quantity of integer value read microinstructions, including: when the vector read address calculation mode is a unit stride address calculation mode or an index address calculation mode, an integer value read microinstruction is generated to read the address base value and store it in a first temporary architecture register; when the vector read address calculation mode is a stride address calculation mode, two integer value read microinstructions are generated to read the address base value and the offset value respectively and store them in two first temporary architecture registers respectively.
[0132] In some embodiments of the present specification, the vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode and an index address calculation mode; accordingly, the second quantity is determined based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core, including: when the vector read address calculation mode is the unit stride address calculation mode, the second quantity is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the cache read width supported by the CPU core ; When the vector read address calculation mode is the stride address calculation mode or the index address calculation mode, determine whether the minimum value among the product of the number of metadata contained in the segment data and the metadata width and the cache read width supported by the CPU core is a power of 2, if so, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value; otherwise, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value plus the product of the register group length and the number of metadata contained in the segment data minus 1.
[0133] In some embodiments of the present specification, the third quantity is determined according to the register group length and the number of metadata included in the segment data, including: when the segment data read vector instruction is in the maskless mode, if the product of the number of metadata included in the segment data and the register group length is less than or equal to 4, the third quantity is equal to the number of metadata included in the segment data; otherwise, the third quantity is equal to twice the number of metadata included in the segment data; when the segment data read vector instruction is in the masked mode, if the product of the number of metadata included in the segment data and the register group length is less than or equal to 3, the third quantity is equal to the number of metadata included in the segment data; if the product of the number of metadata included in the segment data and the register group length is greater than 3 and less than or equal to 6, the third quantity is equal to twice the number of metadata included in the segment data; if the product of the number of metadata included in the segment data and the register group length is greater than 6, the third quantity is equal to three times the number of metadata included in the segment data.
[0134] In some embodiments of the present specification, the data movement microinstruction includes the location of the first metadata to be copied in the second temporary architectural register and the location of the first metadata in the target register.
[0135] In some embodiments of the present specification, the segment data read vector instruction is decoded based on the multiple parameters to obtain multiple microinstructions, and also includes: when the segment data read vector instruction is a mask mode, a fourth number of vector move microinstructions is generated, and the fourth number is the product of the register group length and the number of metadata included in the segment data; the vector move microinstruction is used to copy the metadata without mask calculation in the source register to the target register.
[0136] In some embodiments of the present specification, the device also includes a distribution module, which is specifically used to: after the decoding module decodes the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions, map the first temporary architecture register and the second temporary architecture register to physical registers; allocate physical registers to the integer value read microinstruction, the memory read microinstruction and the target registers corresponding to the data move microinstruction; the source register of the vector move microinstruction uses the physical register of the initial mapping of the target architecture register, and the target register of the vector move microinstruction uses the physical register assigned to the data move microinstruction; distribute the integer value read microinstruction, the memory read microinstruction, the data move microinstruction and the vector move microinstruction; the memory read microinstruction has a data dependency on the integer value read microinstruction; the data move microinstruction has a data dependency on the memory read microinstruction, and the vector move microinstruction has no dependency on the integer value read microinstruction, the memory read microinstruction and the data move microinstruction.
[0137] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of this specification can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of this specification are not limited to any specific combination of hardware and software.
[0138] It should be understood that the above description is for illustration and not for limitation. Many embodiments and many applications beyond the examples provided will be apparent to those skilled in the art upon reading the above description. Therefore, the scope of this specification should not be determined with reference to the above description, but should be determined with reference to the preceding claims and the full scope of equivalents to which these claims belong.
[0139] The above description is only the preferred embodiment of this specification and is not intended to limit this specification. For those skilled in the art, the embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the protection scope of this specification.
Claims
1. A RISC-V segment data read vector instruction processing method, characterized in that: include: In response to a segment data read vector instruction, segment data is read from a memory or a cache, and the read segment data is temporarily stored in a temporary architecture register; the segment data includes a plurality of metadata; the temporary architecture register is an architecture register defined in the CPU core implementation, and is only used to temporarily store and transfer data within an instruction; The plurality of metadata in the segment data in the temporary architecture register are written into the plurality of target registers respectively.
2. The RISC-V segment data read vector instruction processing method according to claim 1, characterized in that: Also includes: Get multiple parameters of segment data read vector instruction; The multiple parameters include: vector read address calculation mode, register group length, number of metadata contained in segment data, metadata width, vector register width supported by the CPU core, and cache read width supported by the CPU core; Decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions include: integer value read microinstructions, memory read microinstructions and data move microinstructions; Accordingly, in response to the segment data read vector instruction, the segment data is read from the memory or cache, and the read segment data is temporarily stored in the temporary architecture register, including: Executing the integer value read microinstruction to read the address base value or the address base value and the offset value from the integer architecture register and store them in the corresponding first temporary architecture register; Execute the memory read microinstruction to read the address base value or the address base value and the offset value from the first temporary architectural register, generate address data according to the address base value or the address base value and the offset value, and read segment data from the memory or cache based on the address data and write it into the corresponding second temporary architectural register; Accordingly, writing the plurality of metadata in the segment data in the temporary architecture register into the plurality of target registers respectively includes: The data move microinstruction is executed to copy a plurality of metadata in the segment data in the second temporary architecture register to a plurality of target registers respectively.
3. The RISC-V segment data read vector instruction processing method according to claim 2, characterized in that: The segment data read vector instruction is decoded based on the multiple parameters to obtain multiple microinstructions, including: Determine a first quantity according to a vector read address calculation mode of the segment data read vector instruction to generate a first quantity integer value read microinstruction; Determine a second number based on a vector read address calculation mode of the segment data read vector instruction, a register group length, a number of metadata contained in the segment data, a metadata width, a vector register width supported by the CPU core, and a cache read width supported by the CPU core, so as to generate a second number of memory read microinstructions; A third number is determined according to the register group length and the number of metadata included in the segment data to generate a third number of data movement microinstructions.
4. The RISC-V segment data reading vector instruction processing method according to claim 3, characterized in that: The vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode, and an index address calculation mode; Accordingly, determining a first quantity according to the vector read address calculation mode of the segment data read vector instruction to generate a first quantity integer value read microinstruction includes: When the vector read address calculation mode is a unit stride address calculation mode or an index address calculation mode, generating an integer value read microinstruction to read an address base value and store it in a first temporary architecture register; When the vector read address calculation mode is the stride address calculation mode, two integer value read microinstructions are generated to read the address base value and the offset value respectively and store them in two first temporary architecture registers respectively.
5. The RISC-V segment data read vector instruction processing method according to claim 3, characterized in that: The vector read address calculation mode includes one of the following: a unit stride address calculation mode, a stride address calculation mode, and an index address calculation mode; Accordingly, determining the second quantity based on the vector read address calculation mode of the segment data read vector instruction, the register group length, the number of metadata contained in the segment data, the metadata width, the vector register width supported by the CPU core, and the cache read width supported by the CPU core includes: When the vector read address calculation mode is the unit stride address calculation mode, the second number is the product of the vector register width supported by the CPU core, the register group length, and the number of metadata included in the segment data divided by the cache read width supported by the CPU core; When the vector read address calculation mode is the stride address calculation mode or the index address calculation mode, determine whether the minimum value of the product of the number of metadata contained in the segment data and the metadata width and the cache read width supported by the CPU core is a power of 2. If so, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value; otherwise, the second number is the product of the vector register width supported by the CPU core, the register group length and the number of metadata contained in the segment data divided by the minimum value plus the product of the register group length and the number of metadata contained in the segment data minus 1.
6. The RISC-V segment data read vector instruction processing method according to claim 3, characterized in that: The third quantity is determined according to the length of the register group and the number of metadata included in the segment data, including: When the segment data read vector instruction is in a maskless mode, if the product of the number of metadata included in the segment data and the register group length is less than or equal to 4, the third number is equal to the number of metadata included in the segment data; otherwise, the third number is equal to twice the number of metadata included in the segment data; In the case where the segment data read vector instruction is a mask mode, if the product of the number of metadata contained in the segment data and the register group length is less than or equal to 3, the third number is equal to the number of metadata contained in the segment data; if the product of the number of metadata contained in the segment data and the register group length is greater than 3 and less than or equal to 6, the third number is equal to twice the number of metadata contained in the segment data; if the product of the number of metadata contained in the segment data and the register group length is greater than 6, the third number is equal to three times the number of metadata contained in the segment data.
7. The RISC-V segment data read vector instruction processing method according to claim 6, characterized in that: The data movement microinstruction includes the location of the first metadata to be copied in the second temporary architectural register and the location of the first metadata in the target register.
8. The RISC-V segment data read vector instruction processing method according to claim 3, characterized in that: Decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions also includes: When the segment data read vector instruction is in mask mode, a fourth number of vector move microinstructions are generated, where the fourth number is the product of the register group length and the number of metadata contained in the segment data; the vector move microinstructions are used to copy the metadata without mask calculation in the source register to the target register.
9. The RISC-V segment data read vector instruction processing method according to claim 8, characterized in that: After decoding the segment data read vector instruction based on the multiple parameters to obtain multiple microinstructions, the method further includes: mapping the first temporary architectural register and the second temporary architectural register to physical registers; Allocate physical registers to the target registers corresponding to the integer value read microinstruction, the memory read microinstruction and the data move microinstruction; the source register of the vector move microinstruction uses the physical register of the initial mapping of the target architecture register, and the target register of the vector move microinstruction uses the physical register allocated to the data move microinstruction; The integer value read microinstruction, the memory read microinstruction, the data move microinstruction and the vector move microinstruction are distributed; the memory read microinstruction has a data dependency on the integer value read microinstruction; the data move microinstruction has a data dependency on the memory read microinstruction, and the vector move microinstruction has no dependency on the integer value read microinstruction, the memory read microinstruction and the data move microinstruction.
10. A RISC-V segment data reading vector instruction processing device, characterized in that: include: A reading module, configured to read segment data from a memory or a cache in response to a segment data read vector instruction, and temporarily store the read segment data in a temporary architecture register; the segment data includes a plurality of metadata; the temporary architecture register is an architecture register defined in the CPU core implementation, and is only used to temporarily store and transfer data within an instruction; The writing module is used to write multiple metadata in the segment data in the temporary architecture register into multiple target registers respectively.
Citation Information
Patent Citations
Unblock instruction to reverse page block during paging
CN109960665A
Segmented data storage method and device, storage medium and electronic device
CN114461599A
Instruction operation method and device, electronic device and storage medium
CN115640047A
Renaming grouping device for RISC-V vector register
CN116257350A
Cache data segmentation reading method and device, computer equipment and storage medium
CN117112454A
