RISC-V vector segment write instruction processing method and device

By assembling the metadata in multiple source registers into segments of data and temporarily storing them in temporary architecture registers, and then writing them to memory or cache, the performance reduction and power consumption increase caused by frequent memory access of RISC-V vector segment write instructions is solved. , achieving more efficient CPU performance and lower power consumption.

CN118981337AActive Publication Date: 2024-11-19CHENGDU QUNXIN MICROELECTRONICS TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411116915.9
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

Technical Problem

In the prior art, frequent memory access of RISC-V vector segment write instructions leads to reduced CPU performance and increased power consumption, and there is a lack of effective solutions.

Method used

By assembling the metadata in multiple source registers into segment data, temporarily stored in temporary architecture registers, and then writing segment data into memory or cache, using temporary architecture registers to convert segment data to larger segment data as granularity Memory writes to reduce the number of cache/memory accesses.

Benefits of technology

Improves CPU core performance, reduces power consumption of access cache/memory, and improves the efficiency of data transfer between vector registers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981337A_ABST
    Figure CN118981337A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and particularly discloses an RISC-V vector segment write instruction processing method and device.The method comprises the steps that in response to a vector segment write instruction, metadata in a plurality of source registers are assembled into segment data, and the segment data are temporarily stored in a temporary architecture register; the segment data comprises a plurality of metadata; the temporary architecture register is an architecture register defined in CPU kernel implementation and is only used for temporarily storing data and transmitting data in one instruction; and writing the segment data in the temporary architecture register into a memory or a cache. According to the scheme, the segment data is converted by using the temporary architecture register, the data is written into the memory by taking the segment data instead of metadata as granularity, and the cache / memory access frequency is reduced at the cost of increasing data transmission between vector registers, so that the CPU kernel performance is improved, and the cache / memory access power consumption is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a RISC-V vector segment write 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 class of RISC-V vector data read and write instructions called segment store instructions. The segmentstore instruction supports the above-mentioned address calculation methods, but a block of segment data in memory 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-segmented vector data read and write instruction. NFIELD>1 is a segmentstore instruction. NFIELD is a 3-bit field (nf[2:0]) in the opcode (operation code) of the data read and write instruction.

[0004] The general implementation method for segment store instructions is to write each metadata into the memory as a data unit. Although the function is correct, due to the large number of memory accesses and the small amount of data written to the memory 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 vector segment write instruction processing method and device to solve the problem of reducing CPU system performance and increasing power consumption due to frequent memory access when implementing segment store instructions in the prior art.

[0007] An embodiment of this specification provides a RISC-V vector segment write instruction processing method, including:

[0008] In response to a vector segment write instruction, assembling metadata in a plurality of source registers into segment data, and temporarily storing the 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 a CPU core implementation, and is only used to temporarily store and transfer data within an instruction;

[0009] The segment data in the temporary architectural register is written to the memory or cache.

[0010] In one embodiment, the method further comprises:

[0011] Acquire multiple parameters of a vector segment write instruction; the multiple parameters include: an address calculation mode, 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;

[0012] Decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions include: integer value read microinstructions, segment transpose microinstructions, segment write address calculation microinstructions and segment write data read microinstructions;

[0013] Accordingly, assembling metadata in a plurality of source registers into segment data, and temporarily storing the segment data in a temporary architecture register, includes:

[0014] Executing the segment transpose microinstruction to read metadata from a plurality of source registers and store the read metadata into a second temporary architecture register by segment;

[0015] Accordingly, writing the segment data in the temporary architecture register into the memory or cache includes:

[0016] 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 first temporary architecture register;

[0017] Execute the segment write address calculation microinstruction to read the address information in the first temporary architecture register or the vector register according to the address calculation mode, perform address generation and address translation access according to the read address information, obtain physical address data, and write the physical address data into a first storage queue item in the storage queue;

[0018] executing the segment write data read microinstruction to read segment data from the second temporary architectural register and write into a second storage queue item in the storage queue;

[0019] After the vector segment write instruction is retired, the segment data in the second storage queue entry is written into the memory or cache according to the physical address data in the first storage queue entry.

[0020] In one embodiment, after writing the segment data in the second storage queue item into a memory or a cache according to the physical address data in the first storage queue item, the method further includes:

[0021] A first storage queue entry and a second storage queue entry in the storage queue are released.

[0022] In one embodiment, the vector segment write instruction is decoded based on the multiple parameters to obtain multiple microinstructions, including:

[0023] Determining a first quantity according to an address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions;

[0024] Determine a second number according to the register group length and the number of metadata included in the segment data to generate a second number of segment transposition microinstructions;

[0025] A third quantity is determined based on the address calculation mode of the vector segment write 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 third number of segment write address calculation microinstructions and a third number of segment write data read instructions.

[0026] In one embodiment, the 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 a first quantity according to the address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions includes:

[0028] When the address calculation mode is a unit stride address calculation mode or an index address calculation mode, generating an integer value read microinstruction to read the address base value and store it in a first temporary architecture register;

[0029] When the 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.

[0030] In one embodiment, determining the second quantity according to the register group length and the number of metadata included in the segment data includes:

[0031] If the product of the number of metadata contained in the segment data and the length of the register group is less than or equal to 4, the second number is equal to the product of the number of metadata contained in the segment data and the length of the register group; otherwise, the second number is equal to twice the product of the number of metadata contained in the segment data and the length of the register group.

[0032] In one embodiment, the 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;

[0033] Accordingly, the third quantity is determined based on the address calculation mode of the vector segment write 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:

[0034] When the vector segment write instruction is in a maskless mode and the address calculation mode is a unit stride address calculation mode, the third number is a product of a vector register width supported by the CPU core, a register group length, and a number of metadata included in the segment data divided by a cache read width supported by the CPU core;

[0035] When the vector segment write instruction is in mask mode and the address calculation mode is unit stride address calculation mode, or when the address calculation mode is stride address calculation mode or 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 third 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 third 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.

[0036] In one embodiment, after decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions, the method further includes:

[0037] The first temporary architectural register and the second temporary architectural register are mapped to physical registers; the source register is renamed to a corresponding physical register; the segment write address calculation microinstruction has a data dependency relationship with the integer value read microinstruction through the first temporary architectural register; the segment write data read microinstruction has a data dependency relationship with the segment transpose microinstruction through the second temporary architectural register;

[0038] The integer value reading microinstruction, the segment transposition microinstruction, the segment write address calculation microinstruction and the segment write data reading microinstruction are distributed.

[0039] In one embodiment, when the vector segment write instruction is in mask mode, when executing the segment write address calculation microinstruction, if the mask value of the segment write address calculation microinstruction is zero, the NOP bit in the first storage queue item corresponding to the segment write address calculation microinstruction is set to 1, otherwise it is set to 0;

[0040] In the case where the vector segment write instruction is in mask mode, when executing the segment write data read microinstruction, if the mask value of the segment write data read microinstruction is zero, the segment write data read microinstruction is converted into a null operation, and no data is written to the corresponding second storage queue item.

[0041] The embodiment of this specification also provides a RISC-V vector segment write instruction processing device, including:

[0042] A temporary storage module, configured to assemble metadata in a plurality of source registers into segment data in response to a vector segment write instruction, and temporarily store the 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;

[0043] A writing module is used to write the segment data in the temporary architecture register into a memory or a cache.

[0044] The embodiment of this specification provides a RISC-V vector segment write instruction processing method. In response to the vector segment write instruction, metadata in multiple source registers can be assembled into segment data, and the segment data is temporarily stored 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 then the segment data in the temporary architecture register is written into the memory or cache. The above scheme converts segment data by using temporary architecture registers, writes data to the memory with a larger segment data (rather than multiple metadata in the segment data) as the granularity, and reduces the number of cache / memory accesses at the cost of increasing data transfer between vector registers, thereby improving the CPU core performance and reducing the power consumption of accessing the cache / memory.

[0045] With reference to the following description and drawings, specific embodiments of the present invention are disclosed in detail, indicating the manner in which the principles of the present invention can be adopted. It should be understood that the embodiments of the present invention are not limited in scope. Features described and / or shown for one embodiment can be used in one or more other embodiments in the same or similar manner, combined with features in other embodiments, or replace features in other embodiments.

[0046] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, parts, steps or components, but does not exclude the presence or addition of one or more other features, parts, steps or components. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] 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:

[0048] Figure 1 A schematic diagram showing the format of a RISC-V vector segment write instruction;

[0049] Figure 2 The data corresponding to the RISC-V vector segment write instruction with NFIELD of 3 is shown;

[0050] Figure 3 A flow chart of a RISC-V vector segment write instruction processing method in an embodiment of this specification is shown;

[0051] Figure 4 An example diagram of a RISC-V vector segment write instruction processing method in an embodiment of this specification is shown;

[0052] Figure 5 A schematic diagram showing the data dependency relationship between microinstructions generated by a RISC-V vector segment write instruction in an embodiment of this specification is shown;

[0053] Figure 6 A schematic diagram of a RISC-V vector segment write instruction processing device in one embodiment of the present specification is shown. DETAILED DESCRIPTION

[0054] 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.

[0055] 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.

[0056] 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].

[0057] 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.

[0058] 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.

[0059] RISC-V vector data read / write (load / store) instructions have the following address calculation methods.

[0060] 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.

[0061] 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.

[0062] 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).

[0063] Figure 1 The format of the RISC-V vector store instruction is shown. Figure 1The above figure shows the VS*unit-stride instruction, which is a vector data storage instruction with the address calculation mode of unit-stride. Figure 1 The middle figure shows the VSS*strided instruction, which is a vector data storage instruction with the address calculation mode being strided. Figure 1 The following figure shows the VSX*indexed instruction, that is, the vector data storage instruction with the address calculation mode indexed. Among them, nf is used to indicate that a segment of data in the segment write instruction contains (nf+1) metadata. mew and width jointly determine the data width of the metadata and index data, as shown in Table 1 below. vm is used to indicate whether the instruction is masked, as shown in Table 2 below. The mop field is used to identify the address calculation method. Among them, 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. sumop is used to further subdivide the unit-stride store instruction as follows: wholeregister store is a subclass of unit-stride store, which writes all the values ​​in one or a group of registers to memory, as shown in Table 4 below. rs1 is the base address value (base address). vs3 is used to represent the storage data (store data). rs2 is the stride (stride). vs2 is the address offset value (address offsets).

[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 store with NFIELD of 3 is shown. The RISC-V standard requires LMUL×NFIELD<=8. Segment store instructions may also be masked or maskless, and the mask is performed at the segment granularity. Figure 2The top row in the figure shows the location of the segment data in memory, and the bottom three rows show the corresponding locations of the data written to memory in the source vector register. For segment store instructions, the general implementation method is to write to memory / cache with metadata as the granularity. This will cause too much memory access for a segment store instruction. For example, when the register is 128 bits wide (VLEN=128), a normal unit-stride store instruction with LMUL=3, SEW=16 bits only needs to access the memory three times to write the data of three registers to the memory / cache. The corresponding segment unit-stride store with LMUL=1, NFIELD=3, SEW=16 bits needs to access the memory 24 times (i.e., 128×3 / 16). Compared with the movement of data 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 access will reduce CPU system performance and increase power consumption.

[0074] The embodiments of this specification provide a RISC-V vector segment write instruction processing method. Figure 3 A flowchart of a RISC-V vector segment write instruction processing method in an embodiment of the present specification is shown. Although the present 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 the present specification and shown in the drawings. When the method or module structure described is applied to an actual device or terminal product, it can be connected according to the method or module structure shown in the embodiments 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 vector segment write instruction processing method provided by an embodiment of the present specification may include the following steps.

[0076] Step S301, in response to a vector segment write instruction, assemble metadata in multiple source registers into segment data, and temporarily store the 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.

[0077] Step S302, writing the segment data in the temporary architecture register into a memory or a cache.

[0078] In this embodiment, metadata in multiple source registers are first assembled into segment data, and these segment data are stored in a temporary architectural register (TAR), and then copied from the TAR to the cache / memory. Since this solution replaces multiple memory write microinstructions with register copy microinstructions inside the vector execution unit, 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, and is used to temporarily store and transfer data between its multiple microinstructions, while normal architectural registers need to transfer data between multiple instructions.

[0079] Since a RISC-V instruction needs to read four register values ​​(two source registers, mask, and the initial value of the target register), it is reasonable to 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).

[0080] The vector segment write instruction includes two operations: write address calculation, and obtaining data to be written to the memory from the register. In this solution, these two operations can be used to generate a set of microinstructions: segment write address calculation microinstruction VSTA for calculating the address to be written to the memory, and segment write data read microinstruction VSTD for reading the data to be written to the memory. A pair of VSTA and VSTD microinstructions completes an operation of writing data to the memory. In this embodiment, VSTD sends the segment data from TAR to the store queue to be finally written into the cache / memory.

[0081] For high-performance CPU cores with out-of-order execution, in order to ensure the correctness of program execution, the corresponding data of a vector segment write instruction will not be written to the cache / memory until it retires. In this case, a vector segment write instruction has multiple clock cycles from execution to retirement, during which its address and data are stored in the store queue. Since the vector segment write instruction must write data to the memory / cache in order, the allocation of its store queue items is generally sequential, so a vector segment write instruction is generally allocated one or more store queue items before it enters the distribution phase.

[0082] In the above embodiment, by using temporary architectural registers to convert segment data, data is written to the memory with a larger segment data granularity rather than multiple metadata within the segment data, and the number of cache / memory accesses is reduced at the cost of increasing data transfer between vector registers, thereby improving CPU core performance and reducing power consumption of accessing cache / memory.

[0083] In some embodiments of the present specification, the method may further include: obtaining multiple parameters of a vector segment write instruction; the multiple parameters may include: 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 vector segment write instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions may include: integer value read microinstructions, segment transposition microinstructions, segment write address calculation microinstructions, and segment write data read microinstructions. Accordingly, assembling metadata in multiple source registers into segment data and temporarily storing the segment data in a temporary architecture register may include: executing the segment transposition microinstruction to read metadata from multiple source registers and store the read metadata in a second temporary architecture register by segment. Correspondingly, writing the segment data in the temporary architecture register into the memory or cache may include: 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 it in the first temporary architecture register; executing the segment write address calculation microinstruction to read the address information in the first temporary architecture register or the vector register according to the address calculation mode, and performing address generation and address translation access according to the read address information to obtain physical address data, and writing the physical address data into the first storage queue item in the storage queue; executing the segment write data read microinstruction to read the segment data from the second temporary architecture register and write it into the second storage queue item in the storage queue; after the vector segment write instruction retires, the segment data in the second storage queue item is written into the memory or cache according to the physical address data in the first storage queue item.

[0084] In this embodiment, multiple parameters of the vector segment write instruction can be obtained. The multiple parameters may include: 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. Among them, the address calculation mode refers to the address calculation method of the vector instruction. The 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 (i.e., metadata width SEW) is controlled by the SEW field in the vtype vector VCSR. 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, which is generally less than or equal to VLEN.

[0085] The vector segment write 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 to decode the vector segment write instruction to obtain multiple microinstructions. The multiple microinstructions include: integer value read microinstructions, segment transposition microinstructions, segment write address calculation microinstructions and segment write data read 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 first temporary architecture register. The segment transposition microinstruction is used to read metadata from multiple source registers and store the read metadata in the second temporary architecture register by segment. The segment write address calculation microinstruction is used to read the address information in the first temporary architecture register or the vector register according to the address calculation mode, and perform address generation and address translation access according to the read address information to obtain physical address data, and write the physical address data into the first storage queue item in the storage queue. The segment write data read microinstruction is used to read the segment data from the second temporary architecture register and write it into the second storage queue item in the storage queue.

[0086] 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 store instructions when LMUL×NFIELD is up to 8. It is understandable 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 store instructions. In this case, more conversions and more microinstructions may be required. For another example, 8 TAR registers may be set, where registers TAR0 and TAR1 store addresses to generate the required integer values, and TAR2 to TAR7 are used to support segment store instructions.

[0087] After decoding to obtain a plurality of microinstructions, the integer value read microinstruction may be executed 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 first temporary architecture register. The segment transpose microinstruction may be executed to read metadata from a plurality of source registers and store the read metadata in the second temporary architecture register by segment. The segment write address calculation microinstruction may be executed to read the address information in the first temporary architecture register or the vector register according to the address calculation mode, and perform address generation and address translation access according to the read address information to obtain physical address data, and write the physical address data into the first storage queue item in the storage queue. The segment write data read microinstruction may also be executed to read the segment data from the second temporary architecture register and write it into the second storage queue item in the storage queue. After the vector segment write instruction is retired, the segment data in the second storage queue item is written into the memory or cache according to the physical address data in the first storage queue item. In the above manner, a series of microinstructions are used to assemble metadata in multiple source registers into segment data, and the segment data are saved in TAR and then copied from TAR to cache / memory.

[0088] In some embodiments of the present specification, after writing the segment data in the second storage queue item into the memory or cache according to the physical address data in the first storage queue item, the method may further include: releasing the first storage queue item and the second storage queue item in the storage queue. After the segment data in the second storage queue item is written into the memory or cache, the first storage queue item and the second storage queue item may be released.

[0089] In some embodiments of the present specification, decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions may include: determining a first quantity based on the address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions; determining a second quantity based on the register group length and the number of metadata contained in the segment data to generate a second number of segment transpose microinstructions; determining a third quantity based on the address calculation mode of the vector segment write 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 third number of segment write address calculation microinstructions and a third number of segment write data read instructions.

[0090] 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 address calculation mode. The first quantity can be determined according to the vector read address calculation mode of the vector segment write instruction to generate the first quantity of integer value read microinstructions. The segment transposition microinstruction is used to read metadata from multiple source registers and store the read metadata in the second temporary architecture register by segment. The second quantity can be determined according to the register group length and the number of metadata contained in the segment data to generate the second quantity of segment transposition microinstructions. The segment write address calculation microinstruction and the segment write data read microinstruction are respectively used to write the physical address data into the first storage queue item in the storage queue and read the segment data from the second temporary architecture register and write it into the second storage queue item in the storage queue. The number of segment write address calculation microinstructions and segment write data read microinstructions is the same. The third number can be determined based on the vector read address calculation mode of the vector segment write 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 third number of segment write address calculation microinstructions and segment write data read microinstructions. In the above manner, the number of microinstructions to be generated can be determined.

[0091] In some embodiments of the present specification, the address calculation mode may include 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 address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions may include: when the address calculation mode is a unit stride address calculation mode or an index address calculation mode, generating an integer value read microinstruction to read the address base value and store it in a first temporary architecture register; when the address calculation mode is a stride address calculation mode, generating two integer value read microinstructions to respectively read the address base value and the offset value and store them in two first temporary architecture registers respectively.

[0092] In this embodiment, when the 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 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.

[0093] In some embodiments of the present specification, determining the second quantity according to the register group length and the number of metadata included in the segment data may include: 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, then the second quantity is equal to the product of the number of metadata included in the segment data and the register group length; otherwise, the second quantity is equal to twice the product of the number of metadata included in the segment data and the register group length.

[0094] In this embodiment, a segment transposition microinstruction VSEG copies metadata from up to 4 source registers to a TAR, and the data is stored in the TAR by segment, so that data write operations can use these TARs as source registers and operate with segments as granularity. Regardless of whether it is masked or unmasked mode, the segment transposition microinstruction VSEG ignores the mask, selects metadata from up to 4 source registers, merges the segment data and writes it to a TAR. The mask operation is completed by the subsequent VSTA or VSTD microinstructions. If LMUL×NFIELD<=4, a segment store instruction needs to generate LMUL×NFIELD VSEG microinstructions, each of which writes a TAR register. If LMUL×NFIELD>4, a TAR register requires two segment transposition microinstructions VSEG to fill the metadata, so 2×LMUL×NFIELD segment transposition microinstructions VSEG need to be generated.

[0095] In some embodiments of the present specification, the address calculation mode may include one of the following: a unit stride address calculation mode, a stride address calculation mode, and an index address calculation mode; accordingly, determining the third quantity based on the address calculation mode of the vector segment write 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 may include: when the vector segment write instruction is a maskless mode and the address calculation mode is a unit stride address calculation mode, the third 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 segment write instruction is a maskless mode and the address calculation mode is a unit stride address calculation mode, the third 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; And when the address calculation mode is the unit stride address calculation mode, or when the 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 third 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 third 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.

[0096] In this embodiment, the segment write address calculation microinstruction VSTA reads TAR0, TAR1 or a vector register according to the different address calculation modes of a vector segment write instruction. The number of VSTAs generated is also different according to the different segment store address calculation modes. In the mask calculation mode, the mask register itself is also a source of the VSTA instruction.

[0097] For the Maskless unit-stride segment store instruction (unit-stride vector segment write instruction in non-mask mode), DLEN bits of data are written each time, so (VLEN×LMUL×NFIELD) / DLEN VSTA microinstructions are required.

[0098] For other vector segment write instructions (including masked unit-stride segment store, masked / maskless stride segment store and masked / maskless indexed segment store), each write data shall not exceed min(DLEN,NFIELD×SEW) bits. If min(DLEN,NFIELD×SEW) is a power of 2, no write operation crosses the TAR register, so a total of (VLEN×LMUL×NFIELD) / min(DLEN,NFIELD×SEW) VSTA microinstructions are required. If min(DLEN,NFIELD×SEW) is not a power of 2, then (VLEN×LMUL×NFIELD) / min(DLEN,NFIELD×SEW) VSTA microinstructions are required. The extra LMUL×(NFIELD-1) microinstructions are because some segment data need to be stored in two TAR registers, so they need to be split into two VSTA. The number of segment write data reading microinstructions VSTD is the same as the number of corresponding segment write address calculation microinstructions VSTA. A VSTD reads the corresponding segment data from a TAR register, so it needs to include the data size and its offset in the TAR register.

[0099] In some embodiments of the present specification, after decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions, it can also include: mapping the first temporary architecture register and the second temporary architecture register to physical registers; renaming the source register to the corresponding physical register; the segment write address calculation microinstruction has a data dependency on the integer value read microinstruction through the first temporary architecture register; the segment write data read microinstruction has a data dependency on the segment transpose microinstruction through the second temporary architecture register; and distributing the integer value read microinstruction, the segment transpose microinstruction, the segment write address calculation microinstruction and the segment write data read microinstruction.

[0100] In this embodiment, after decoding, the I2V and VSEG microinstructions have TAR target registers, and these TARs will allocate new physical registers. The source registers of these microinstructions will also be renamed to the corresponding physical registers. The VSTA / VSTD microinstructions have data dependencies on the corresponding I2V / VSEG microinstructions through these TAR registers. Similar to ordinary instructions, when the source registers and other hardware resources (such as execution units and store queues, etc.) are ready, the microinstructions can be distributed and executed. Between the microinstructions generated by the decoding of the same vector segment write instruction, the VSTA / VSTD microinstructions have data dependencies on the corresponding I2V / VSEG microinstructions through these TAR registers, so a VSTA must be executed after the I2V it depends on is executed, and a VSTD must be executed after the VSEG it depends on is executed.

[0101] In some embodiments of the present specification, when the vector segment write instruction is in mask mode, when the segment write address calculation microinstruction is executed, if the mask value of the segment write address calculation microinstruction is zero, then the NOP bit in the first storage queue item corresponding to the segment write address calculation microinstruction is set to 1, otherwise it is set to 0; when the vector segment write instruction is in mask mode, when the segment write data read microinstruction is executed, if the mask value of the segment write data read microinstruction is zero, then the segment write data read microinstruction is converted into a no operation, and no data is written to the corresponding second storage queue item.

[0102] When executing the segment write address calculation microinstruction VSTA, VSTA needs to go through the steps of address generation, address translation (converting virtual address to physical address) access, etc., just like ordinary data address calculation microinstructions. VSTA will write the address part into the corresponding store queue item. If the mask value of VSTA in a mask mode is 0, the VSTA sets the NOP bit of the corresponding store queue item to 1, otherwise its NOP bit is set to 0. When executing the segment write data read microinstruction VSTD, the corresponding data is read from the TAR register and written into the corresponding store queue item. If the mask value of VSTD in a mask mode is 0, the VSTD is converted into a no operation (NOP) and no data is written into its corresponding store queue item.

[0103] The retirement of a vector segment write instruction is the same as other write instructions. Only when a vector segment write instruction is retired, the data in the corresponding store queue item with NOP bit 0 will be written to the cache / memory. Then its store queue item will be released.

[0104] 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.

[0105] 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.

[0106] 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.

[0107] This specific embodiment provides a RISC-V vector segment write instruction processing method. This solution uses a series of microinstructions to assemble metadata in multiple source registers into segment data, and saves these segment data in temporary architectural registers, and then copies them from the temporary architectural registers to the cache / memory. Because this solution replaces multiple memory write microinstructions with register copy microinstructions inside the vector execution unit, performance and power consumption are improved.

[0108] The difference between the temporary architecture register TAR and the normal architecture register is that TAR is only used within an instruction to temporarily store and transfer data between multiple microinstructions, while the normal architecture register needs to transfer data between multiple instructions. In this embodiment, 10 TAR registers are set, of which TAR0 and TAR1 store the integer values ​​required for address generation, and the other 8 TARs (TAR2 to TAR9) support segment store instructions (vector segment write instructions) when LMUL×NFIELD is up to 8.

[0109] Since a RISC-V instruction needs to read four register values ​​(two source registers, mask, and the initial value of the target register), it is reasonable to 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).

[0110] A vector segment write instruction consists of two operations: write address calculation, and get the data to be written to memory from the register. In this solution, these two operations are combined to form a set of microinstructions: VSTA calculates the address to be written to memory, and VSTD reads the data to be written to memory. A pair of VSTA and VSTD microinstructions completes an operation of writing data to memory. In this solution, the VSTD microinstruction sends the segment data from TAR to the store queue for final writing to the cache / memory.

[0111] The base (address base value) in the address calculation of the vector store instruction and the offset (offset value) of the stride store 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 write instruction uses a maximum of two integer registers, this solution reserves two TAR registers to temporarily store integer values.

[0112] For high-performance CPU cores with out-of-order execution, in order to ensure the correctness of program execution, the corresponding data of a vector segment write instruction will not be written to the cache / memory until it is retired. In this case, a vector segment write instruction has multiple clock cycles from execution to retirement, during which its address and data are stored in the store queue. Since the vector segment write instruction must write data to the memory / cache in order, the allocation of its store queue items is generally sequential, so a vector segment write instruction is generally allocated one or more store queue items before it enters the distribution phase.

[0113] Figure 4 FIG. 1 is a schematic diagram showing a method for processing a RISC-V vector segment write instruction in this specific embodiment. Figure 4 The figure shows a maskless segment stride store instruction (stride vector segment write instruction in non-mask mode) with VLEN=128b, NFIELD=3, LMUL=1, SEW=16b. In this optimization scheme, the instruction is decomposed into 3 VSEG microinstructions to copy metadata from the source register to the TAR register organized by segment data, as well as 10 (instead of 24 in the prior art scheme) segment write address calculation microinstructions VSTA and 10 (instead of 24 in the prior art scheme) segment write data read microinstructions VSTD.

[0114] This scheme includes the following steps.

[0115] Decoding step: According to the LMUL, NFIELD, SEW values ​​of a vector segment write instruction and the vector register width VLEN supported by the CPU core, the instruction is decoded into multiple VSEG, VSTA and VSTD microinstructions. The cache read width supported by the CPU core is DLEN, and generally DLEN<=VLEN.

[0116] The integer value read microinstruction I2V reads an integer architectural register and writes the result to a vector TAR. Unit-stride and Indexed store instructions only generate one I2V to read the base value and put it into TAR0. Stridestore instructions need to generate two I2Vs to read the base and offset values ​​and put them into TAR0 and TAR1.

[0117] The segment transposition microinstruction VSEG copies metadata from up to 4 source registers to a TAR. The data is stored in the TAR by segment, so that data write operations can use these TARs as source registers and operate with segments as granularity. Regardless of whether it is masked or unmasked mode, a VSEG microinstruction ignores the mask, selects metadata from up to 4 source registers, merges the segment data, and writes it to a TAR. The mask operation is completed by the subsequent VSTA / VSTD microinstructions. If LMUL×NFIELD<=4, a vector segment write instruction needs to generate LMUL×NFIELD VSEG microinstructions, each of which writes a TAR register. If LMUL×NFIELD>4, a TAR register requires two VSEG microinstructions to fill the metadata, so 2×LMUL×NFIELD VSEG microinstructions need to be generated.

[0118] Depending on the address calculation mode of a segment store, the segment write address calculation microinstruction VSTA reads TAR0, TAR1 or a vector register. Depending on the address calculation mode of a vector segment write instruction, the number of VSTAs generated is also different. In mask mode, the mask register itself is also a source of the VSTA instruction.

[0119] For the Maskless unit-stride segment store instruction (unit-stride vector segment write instruction in non-mask mode), DLEN bits of data are written each time, so (VLEN×LMUL×NFIELD) / DLEN VSTA microinstructions are required.

[0120] For other vector segment write instructions (including masked unit-stride segment store, masked / maskless stride segment store and masked / maskless indexed segment store), each write data shall not exceed min(DLEN,NFIELD×SEW) bits. If min(DLEN,NFIELD×SEW) is a power of 2, no store operation crosses the TAR register, so a total of (VLEN×LMUL×NFIELD) / min(DLEN,NFIELD×SEW) VSTA microinstructions are required. If min(DLEN,NFIELD×SEW) is a power of 2, (VLEN×LMUL×NFIELD) / min(DLEN,NFIELD×SEW) VSTA microinstructions are required. The extra LMUL×(NFIELD-1) microinstructions are because some segment data need to be stored in two registers, so they need to be split into two VSTAs.

[0121] The number of segment write data read microinstructions VSTD: is the same as the number of corresponding segment write address calculation microinstructions VSTA. A VSTD reads the corresponding segment data from a TAR register, so it must contain the data size and its offset in the TAR register. In mask mode, the mask register is also a source of the VSTA instruction.

[0122] Register renaming step. In a segment store, I2V and VSEG microinstructions have TAR target registers, and these TARs will be assigned new physical registers. The source registers of these microinstructions will also be renamed to the corresponding physical registers. VSTA / VSTD microinstructions have data dependencies on the corresponding I2V / VSEG microinstructions through these TAR registers.

[0123] Microinstruction distribution steps. Similar to ordinary instructions, microinstructions can be distributed and executed when the source registers and other hardware resources (such as execution units and store queues, etc.) are ready. Between the microinstructions generated by decoding the same vector segment write instruction, the VSTA / VSTD microinstructions have data dependencies on the corresponding I2V / VSEG microinstructions through these TAR registers. Therefore, a VSTA must be executed only after the I2V it depends on is executed, and a VSTD must be executed only after the VSEG it depends on is executed.

[0124] Microinstruction execution steps. I2V copies the base / offset values ​​from the integer physical registers to TAR0 / TAR1. VSEG copies all relevant data (regardless of mask = 0 or 1) from the source register to TAR. Similar to ordinary data address calculation microinstruction instructions, VSTA needs to go through address generation, address translation (converting virtual addresses to physical addresses) access and other steps. VSTA will write the address part to the corresponding store queue item. If the mask value of a VSTA in mask mode is 0, the VSTA sets the NOP bit of the corresponding store queue item to 1, otherwise its NOP bit is set to 0. VSTD reads the corresponding data from the TAR register and writes it to the corresponding store queue item. If the mask value of a VSTD in mask mode is 0, the VSTD is converted into a no operation (NOP) and no data is written into its corresponding store queue item.

[0125] Vector segment write instruction retirement steps. Similar to other write instructions, only when a vector segment write instruction is retired, the data in the corresponding store queue item with NOP bit 0 will be written to the cache / memory. Then its multiple storequeue items will be released.

[0126] Figure 5 The figure shows the data dependencies between the microinstructions generated by a vector segment write instruction and how they are established through the TAR register. Due to these dependencies, a VSTA must be executed after the I2V it depends on is executed, and a VSTD must be executed after the VSEG it depends on is executed. 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.

[0127] 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 (valid bits) in addition to the VLEN bits of data. Each valid bit corresponds to a byte of data for the item. For a masked segment store instruction, its VSEG microinstruction will write all read metadata into the TAR physical register and set the corresponding valid bits. A vector microinstruction will only be distributed and executed after all valid bits of its source registers are set.

[0128] 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.

[0129] For RISC-V vector segment write instructions, this technical solution uses temporary architectural registers to convert and save segment data. Memory write operations use larger segment data (rather than multiple metadata within the segment data) as the granularity, at the cost of increasing data transfer between vector registers, reducing the number of cache / memory writes, thereby improving CPU core performance and reducing power consumption of accessing cache / memory.

[0130] 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.

[0131] In this embodiment, 8 TARs are reserved for temporarily storing segment data. A possible solution may be to reserve 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 VSTD microinstructions may need to be generated.

[0132] Based on the same inventive concept, a RISC-V vector segment write 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 vector segment write instruction processing device is similar to that of the RISC-V vector segment write instruction processing method, the implementation of the RISC-V vector segment write instruction processing device can refer to the implementation of the RISC-V vector segment write instruction processing method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived. Figure 6 is a structural block diagram of a RISC-V vector segment write instruction processing device according to an embodiment of this specification, such as Figure 6 As shown, it includes: a temporary storage module 601 and a writing module 602. The structure is described below.

[0133] The temporary storage module 601 is used to respond to a vector segment write instruction, assemble metadata in multiple source registers into segment data, and temporarily store the 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.

[0134] The writing module 602 is used to write the segment data in the temporary architecture register into the memory or cache.

[0135] In some embodiments of the present specification, the device further includes a decoding module, which is specifically used to: obtain multiple parameters of a vector segment write instruction; the multiple parameters include: an address calculation mode, 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; based on the multiple parameters, the vector segment write instruction is decoded to obtain multiple microinstructions; the multiple microinstructions include: an integer value read microinstruction, a segment transposition microinstruction, a segment write address calculation microinstruction, and a segment write data read microinstruction; accordingly, the temporary storage module is specifically used to: execute the segment transposition microinstruction to read metadata from multiple source registers and store the read metadata in a second temporary architecture register by segment; accordingly, the write module is specifically used to: Used to: execute 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 first temporary architecture register; execute the segment write address calculation microinstruction to read the address information in the first temporary architecture register or the vector register according to the address calculation mode, and perform address generation and address translation access according to the read address information to obtain physical address data, and write the physical address data into the first storage queue item in the storage queue; execute the segment write data read microinstruction to read the segment data from the second temporary architecture register and write it into the second storage queue item in the storage queue; after the vector segment write instruction retires, write the segment data in the second storage queue item into the memory or cache according to the physical address data in the first storage queue item.

[0136] In some embodiments of the present specification, the device also includes a release module, which is specifically used to release the first storage queue item and the second storage queue item in the storage queue after the write module writes the segment data in the second storage queue item into the memory or cache according to the physical address data in the first storage queue item.

[0137] In some embodiments of the present specification, the decoding module is specifically used to: determine a first quantity according to the address calculation mode of the vector segment write instruction to generate a first number of integer value read microinstructions; determine a second quantity according to the register group length and the number of metadata contained in the segment data to generate a second number of segment transpose microinstructions; determine a third quantity based on the address calculation mode of the vector segment write 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 third number of segment write address calculation microinstructions and a third number of segment write data read instructions.

[0138] In some embodiments of the present specification, the 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 address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions, including: when the 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 address calculation mode is a stride address calculation mode, two integer value read microinstructions are generated to respectively read the address base value and the offset value and store them in two first temporary architecture registers respectively.

[0139] In some embodiments of the present specification, determining the second quantity according to the register group length and the number of metadata included in the segment data includes: 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, then the second quantity is equal to the product of the number of metadata included in the segment data and the register group length; otherwise, the second quantity is equal to twice the product of the number of metadata included in the segment data and the register group length.

[0140] In some embodiments of the present specification, the 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 third quantity is determined based on the address calculation mode of the vector segment write 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 segment write instruction is a maskless mode and the address calculation mode is a unit stride address calculation mode, the third 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 segment write instruction is a maskless mode and the address calculation mode is a unit stride address calculation mode, the third 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 address calculation mode is the unit stride address calculation mode, or when the 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 third 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 third 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.

[0141] In some embodiments of the present specification, the device also includes a distribution module, which is specifically used to: map the first temporary architecture register and the second temporary architecture register to physical registers; rename the source register to the corresponding physical register; the segment write address calculation microinstruction has a data dependency on the integer value reading microinstruction through the first temporary architecture register; the segment write data read microinstruction has a data dependency on the segment transposition microinstruction through the second temporary architecture register; and distribute the integer value reading microinstruction, the segment transposition microinstruction, the segment write address calculation microinstruction and the segment write data read microinstruction.

[0142] In some embodiments of the present specification, when the vector segment write instruction is in mask mode, when the segment write address calculation microinstruction is executed, if the mask value of the segment write address calculation microinstruction is zero, then the NOP bit in the first storage queue item corresponding to the segment write address calculation microinstruction is set to 1, otherwise it is set to 0; when the vector segment write instruction is in mask mode, when the segment write data read microinstruction is executed, if the mask value of the segment write data read microinstruction is zero, then the segment write data read microinstruction is converted into a no operation, and no data is written to the corresponding second storage queue item.

[0143] 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.

[0144] 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.

[0145] 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 vector segment write instruction processing method, characterized in that: include: In response to a vector segment write instruction, assembling metadata in a plurality of source registers into segment data, and temporarily storing the 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 a CPU core implementation, and is only used to temporarily store and transfer data within an instruction; The segment data in the temporary architectural register is written to the memory or cache.

2. The RISC-V vector segment write instruction processing method according to claim 1, characterized in that: Also includes: Acquire multiple parameters of a vector segment write instruction; the multiple parameters include: an address calculation mode, 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; Decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions; the multiple microinstructions include: integer value read microinstructions, segment transpose microinstructions, segment write address calculation microinstructions and segment write data read microinstructions; Accordingly, assembling metadata in a plurality of source registers into segment data and temporarily storing the segment data in a temporary architecture register includes: Executing the segment transpose microinstruction to read metadata from a plurality of source registers and store the read metadata into a second temporary architecture register by segment; Accordingly, writing the segment data in the temporary architecture register into the memory or cache includes: 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 first temporary architecture register; Execute the segment write address calculation microinstruction to read the address information in the first temporary architecture register or the vector register according to the address calculation mode, perform address generation and address translation access according to the read address information, obtain physical address data, and write the physical address data into a first storage queue item in the storage queue; executing the segment write data read microinstruction to read segment data from the second temporary architectural register and write into a second storage queue item in the storage queue; After the vector segment write instruction is retired, the segment data in the second storage queue entry is written into the memory or cache according to the physical address data in the first storage queue entry.

3. The RISC-V vector segment write instruction processing method according to claim 2, characterized in that: After writing the segment data in the second storage queue item into the memory or cache according to the physical address data in the first storage queue item, the method further includes: A first storage queue entry and a second storage queue entry in the storage queue are released.

4. The RISC-V vector segment write instruction processing method according to claim 2, characterized in that: Decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions, including: Determining a first quantity according to an address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions; Determine a second number according to the register group length and the number of metadata included in the segment data to generate a second number of segment transposition microinstructions; A third quantity is determined based on the address calculation mode of the vector segment write 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 third number of segment write address calculation microinstructions and a third number of segment write data read instructions.

5. The RISC-V vector segment write instruction processing method according to claim 4, characterized in that: The 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 address calculation mode of the vector segment write instruction to generate a first quantity of integer value read microinstructions includes: When the address calculation mode is a unit stride address calculation mode or an index address calculation mode, generating an integer value read microinstruction to read the address base value and store it in a first temporary architecture register; When the 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.

6. The RISC-V vector segment write instruction processing method according to claim 4, characterized in that: Determining the second quantity according to the register group length and the number of metadata included in the segment data includes: If the product of the number of metadata contained in the segment data and the length of the register group is less than or equal to 4, the second number is equal to the product of the number of metadata contained in the segment data and the length of the register group; otherwise, the second number is equal to twice the product of the number of metadata contained in the segment data and the length of the register group.

7. The RISC-V vector segment write instruction processing method according to claim 4, characterized in that: The 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 third quantity is determined based on the address calculation mode of the vector segment write 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 segment write instruction is in a maskless mode and the address calculation mode is a unit stride address calculation mode, the third number is a product of a vector register width supported by the CPU core, a register group length, and a number of metadata included in the segment data divided by a cache read width supported by the CPU core; When the vector segment write instruction is in mask mode and the address calculation mode is unit stride address calculation mode, or when the address calculation mode is stride address calculation mode or 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 third 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 third 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.

8. The RISC-V vector segment write instruction processing method according to claim 4, characterized in that: After decoding the vector segment write instruction based on the multiple parameters to obtain multiple microinstructions, the method further includes: The first temporary architectural register and the second temporary architectural register are mapped to physical registers; the source register is renamed to a corresponding physical register; the segment write address calculation microinstruction has a data dependency relationship with the integer value read microinstruction through the first temporary architectural register; the segment write data read microinstruction has a data dependency relationship with the segment transpose microinstruction through the second temporary architectural register; The integer value reading microinstruction, the segment transposition microinstruction, the segment write address calculation microinstruction and the segment write data reading microinstruction are distributed.

9. The RISC-V vector segment write instruction processing method according to claim 4, characterized in that: In the case where the vector segment write instruction is in mask mode, when executing the segment write address calculation microinstruction, if the mask value of the segment write address calculation microinstruction is zero, then the NOP bit in the first storage queue item corresponding to the segment write address calculation microinstruction is set to 1, otherwise it is set to 0; In the case where the vector segment write instruction is in mask mode, when executing the segment write data read microinstruction, if the mask value of the segment write data read microinstruction is zero, the segment write data read microinstruction is converted into a no operation.

10. A RISC-V vector segment write instruction processing device, characterized in that: include: A temporary storage module, configured to assemble metadata in a plurality of source registers into segment data in response to a vector segment write instruction, and temporarily store the 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; A writing module is used to write the segment data in the temporary architecture register into a memory or a cache.

Citation Information

Patent Citations

  • AIoT scene-oriented operating system supporting RISC-V processor

    CN114416031A

  • Memory system and operating method of memory system

    CN115481056A

  • Memory access method and device, electronic equipment and readable storage medium

    CN116909946A

  • Rapid transmission method of IPMI protocol and related equipment

    CN118413583A

  • Efficient data compression by grouping similar data within a data segment

    US20210109682A1

Cited By

  • Performing register-memory operations

    EP4776124A1