Method and apparatus for vector instruction table filling and lookup in processor, and electronic device

By configuring the vector instruction lookup table in the processor and using table filling and table lookup rules, the problem of frequent data access between vector registers and memory is solved, and the performance and efficiency of the processor are improved.

WO2024187629A1PCT designated stage expired Publication Date: 2024-09-19BEIJING VCORE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/102852
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-10
Filing Date
2023-06-27
Publication Date
2024-09-19

AI Technical Summary

Technical Problem

In vector processing technology, frequent data access between vector registers and memory affects pipeline performance, and vector lookup table operations occupy vector register resources and ports, resulting in reduced processor performance.

Method used

By configuring the vector instruction lookup table in the processor, determining the table filling type, using the corresponding table filling rules to write the elements in the vector register into the lookup table, and using the preset table lookup rules to obtain elements from the lookup table, reducing The occupation of vector registers and register ports reduces the number of memory accesses.

Benefits of technology

It improves the performance of the processor, reduces the occupation of vector register space and register ports, and improves the efficiency of table filling and table lookup operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023102852_19092024_PF_FP_ABST
    Figure CN2023102852_19092024_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and apparatus for vector instruction table filling and lookup in a processor, and an electronic device. The method comprises: configuring a vector instruction lookup table in a preset storage space of the processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of bits of storage items; determining table filling types corresponding to candidate vector registers waiting for table filling, wherein the table filling types comprise a first type and a second type, the first type is that the product of the register width and the maximum number of register groups is larger than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is smaller than the storage capacity; and using table filling rules corresponding to the table filling types to write first elements stored in target vector registers among the plurality of candidate vector registers into the vector instruction lookup table, and using a preset table lookup rule to acquire, from the vector instruction lookup table, a second element to be looked up, such that the performance of the processor can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Method, device and electronic device for filling and looking up vector instruction tables in processors

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application is based on the Chinese patent application with application number 202310225470.7 and application date March 10, 2023, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field

[0003] The present disclosure relates to the field of computer technology, and in particular to a method, device, and electronic device for filling and looking up a table of vector instructions in a processor. Background Art

[0004] With the development of big data and artificial intelligence technologies, demands for data analysis applications and the performance of AI algorithms are increasing, placing ever-higher demands on computer processing capabilities. Vector processing technology has become a hot topic of concern in both academia and industry. Vector processing technology is often applied to vector functions, which are all algorithmic functions in a computer program that use vector instructions and vector registers for their internal implementation. By using vector instructions and vector registers, the internal computations of this function are performed in a data-parallel manner.

[0005] Table lookup is an optimization method used during computer program development. It precalculates required numerical results and stores them in a constant array. These results are then retrieved directly from the array at runtime, rather than being temporarily calculated. This reduces computational overhead. Vector table lookup, however, refers to the table lookup method used within vector functions. Table entries in vector lookup tables are used over time. For example, filling and looking up tables in vector registers consumes vector register resources and vector register ports. When vector registers are insufficient, frequent data transfers between vector registers and memory are required, impacting pipeline performance.

[0006] Summary of the Invention

[0007] The present disclosure proposes a method, device and electronic device for filling and looking up a vector instruction table in a processor, aiming to solve one of the technical problems in the related art at least to a certain extent.

[0008] An embodiment of the first aspect of the present disclosure proposes a method for filling and looking up a table of vector instructions in a processor, comprising: configuring a vector instruction lookup table in a storage space preset by the processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of storage item bits; determining a table filling type corresponding to a candidate vector register to be filled in the table, wherein the table filling type includes a first type and a second type, the first type being that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type being that the product of the register width and the maximum number of register groups is less than the storage capacity; using a table filling rule corresponding to the table filling type, writing a first element stored in a target vector register among multiple candidate vector registers into the vector instruction lookup table; and using a preset table lookup rule, obtaining a second element to be queried from the vector instruction lookup table.

[0009] An embodiment of the second aspect of the present disclosure proposes a vector instruction table filling and table lookup device in a processor, including: a configuration module, used to configure a vector instruction lookup table in a storage space preset by the processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of storage item bits; a determination module, used to determine the table filling type corresponding to the candidate vector register to be filled in the table, wherein the table filling type includes a first type and a second type, the first type being that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type being that the product of the register width and the maximum number of register groups is less than the storage capacity; a table filling module, used to write the first element stored in the target vector register among multiple candidate vector registers into the vector instruction lookup table by using the table filling rules corresponding to the table filling type; and a table lookup module, used to obtain the second element to be queried from the vector instruction lookup table by using the preset table lookup rules.

[0010] An embodiment of the third aspect of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the vector instruction table filling and table lookup method in the processor of the embodiment of the present disclosure.

[0011] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the vector instruction table filling and table lookup method in the processor disclosed in the embodiment of the present disclosure.

[0012] The fifth aspect of the present disclosure provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the vector instruction table filling and table lookup method in the processor disclosed in the embodiment of the present disclosure.

[0013] In an embodiment of the present disclosure, a vector instruction lookup table is configured in a storage space preset by a processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of storage item bits, and a table filling type corresponding to a candidate vector register to be filled in the table is determined, wherein the table filling type includes a first type and a second type, wherein the first type is that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is less than the storage capacity, and a table filling rule corresponding to the table filling type is used to write the first element stored in a target vector register in multiple candidate vector registers into the vector instruction lookup table, and a preset table lookup rule is used to obtain the second element to be queried from the vector instruction lookup table, thereby reducing the occupancy of the vector register space and register port, reducing the number of memory accesses, and utilizing the table filling rules and table lookup rules corresponding to the table filling type to quickly perform table filling and table lookup operations, thereby improving processor performance.

[0014] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The above and / or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0016] FIG1 is a flow chart of a method for filling and looking up a table of vector instructions in a processor according to an embodiment of the present disclosure;

[0017] FIG2A is a schematic diagram of the structure of a 256-bit vector register provided according to an embodiment of the present disclosure;

[0018] FIG2B is a schematic diagram of the structure of a vector instruction lookup table corresponding to the vector register in FIG2A ;

[0019] FIG3A is a schematic diagram of the structure of a 128-bit vector register provided according to an embodiment of the present disclosure;

[0020] FIG3B is a schematic diagram of the structure of a vector instruction lookup table corresponding to the vector register in FIG3A ;

[0021] FIG4A is a schematic diagram of the structure of another 256-bit vector register provided according to an embodiment of the present disclosure;

[0022] FIG4B is a schematic diagram of the structure of a vector instruction lookup table corresponding to the vector register in FIG4A ;

[0023] FIG5 is a flow chart of a method for filling and looking up a table of vector instructions in a processor according to another embodiment of the present disclosure;

[0024] FIG6 is a flow chart of a method for filling and looking up a table of vector instructions in a processor according to another embodiment of the present disclosure;

[0025] 7 is a schematic diagram of a vector instruction table filling and table lookup device in a processor according to another embodiment of the present disclosure;

[0026] FIG8 illustrates a block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure. DETAILED DESCRIPTION

[0027] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0029] It should be noted that the executor of the method for filling and looking up a table of vector instructions in the processor of the embodiment of the present disclosure may be a device for filling and looking up a table of vector instructions in the processor, which may be implemented by software and / or hardware, and which may be configured in an electronic device, which may include but is not limited to a terminal, a server, etc.

[0030] FIG1 is a flow chart of a method for filling and looking up a table of vector instructions in a processor according to an embodiment of the present disclosure. As shown in FIG1 , the method includes steps S101 to S103 .

[0031] S101: configuring a vector instruction lookup table in a storage space preset by a processor.

[0032] In an embodiment of the present disclosure, an independent storage space may be set up on a processor chip, and a vector instruction lookup table (also referred to as a lookup table, Table) may be configured in the storage space. The vector instruction lookup table is used to store elements in a vector register.

[0033] [Corrected 29.06.2023 according to Rule 91] The vector instruction lookup table includes M storage items, each storage item is used to store an element of the vector instruction, and each storage item has a corresponding number of storage item bits N. The number of storage items M is equal to the index bit width of the vector lookup table index raised to a power of 2, that is, M = 2 索引位宽The number of storage item bits N is equal to the effective element width (EEW) of the element (destination operand) written into the vector instruction lookup table, i.e., N = destination operand EEW. In the disclosed embodiment, EEW can be configured to be equal to the actual element width SEW of the vector register to be operated. For example, if SEW = 8, then each storage item has a corresponding storage item bit number N of 8 bits. Furthermore, the disclosed embodiment can calculate the product of the number of storage items M and the number of storage items N as the storage capacity of the vector instruction lookup table, i.e., storage capacity = M*N.

[0034] In one embodiment, Figure 2A is a structural diagram of a 256-bit wide vector register provided according to an embodiment of the present disclosure, and Figure 2B is a structural diagram of a vector instruction lookup table corresponding to the vector register in Figure 2A. As shown in Figure 2B, the vector instruction lookup table (Table) configured in the embodiment of the present disclosure is, for example, 256 items (i.e., M = 256), including a0, a1, ..., a255 storage items; each SEW is an 8-bit integer, i.e.: N = 8, then the storage capacity of the vector instruction lookup table = 256*8 = 2048 bits, SEW is other values, and so on.

[0035] S102: Determine the table filling type corresponding to the candidate vector register to be filled.

[0036] Among them, all vector registers supported by the processor can be called candidate vector registers. For example, the 32 vector registers (v0-v31) included in the RISC-V vector instruction set can be called candidate vector registers. That is to say, there are multiple candidate vector registers in the embodiment of the present disclosure.

[0037] In practical applications, the candidate vector registers may be configured with different register widths (VLEN), such as 64 bits, 128 bits, 256 bits, 512 bits, and the like.

[0038] For example, as shown in Figure 2A, the RISC-V vector instruction set includes 32 candidate vector registers (v0-v31), and the register width VLEN of each vector register is 256 bits (0-255), that is, a 256-bit vector register, where each vector register stores 32 elements. For example, v16 stores elements a0-a31, the SEW of each element is 8 bits, and the number of registers in each group LMUL is 8.

[0039] For another example, Figure 3A is a structural diagram of a 128-bit wide vector register provided according to an embodiment of the present disclosure. As shown in Figure 3A, the register width VLEN of each vector register in the 32 candidate vector registers (v0-v31) is 128 bits (0-127), that is: a 128-bit vector register, where each vector register stores 16 elements, for example, v16 stores elements a0-a15, the SEW of each element is 8 bits, and the number of registers in each group LMUL is 8.

[0040] In the embodiment of the present disclosure, for determining candidate vector registers of different register widths VLEN, it is necessary to determine corresponding table filling types, wherein the table filling types of the embodiment of the present disclosure include, for example, a first type and a second type.

[0041] The disclosed embodiments can calculate the product of the register width VLEN of the candidate vector register and the maximum number of register groups (the maximum number of registers in the register group, LMUL), i.e., VLEN * maximum LMUL, and further determine the size relationship between VLEN * maximum LMUL and the storage capacity (M * N) of the vector instruction lookup table. The first type is that the product of the register width VLEN and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width VLEN and the maximum number of register groups is less than the storage capacity. It should be noted that in the RISC-V vector instruction set, the maximum number of register groups, LMUL, is 8.

[0042] For example, the storage capacity (M*N) is 2048 bits, the register width VLEN of the candidate vector register shown in Figure 2A is 256, the maximum number of register groups LMUL is 8, VLEN*maximum LMUL is equal to M*N, then the table filling type corresponding to the 256-bit candidate vector register is the first type; for another example, the register width VLEN of the candidate vector register shown in Figure 3A is 128, the maximum number of register groups LMUL is 8, VLEN*maximum LMUL is less than M*N, then the table filling type corresponding to the 128-bit candidate vector register is the second type.

[0043] After configuring the vector instruction query table as described above, the embodiment of the present disclosure can further determine the table filling type corresponding to the candidate vector register, that is, the first type or the second type.

[0044] S103: Using a table filling rule corresponding to the table filling type, write the first element stored in the target vector register among the plurality of candidate vector registers into the vector instruction lookup table.

[0045] Among them, the table filling rule can also be called a vector table filling instruction (table_fill), which is used to write the first element stored in the target vector register among multiple candidate vector registers into the vector instruction lookup table, that is, to fill the first element into the corresponding item in the vector instruction lookup table.

[0046] The register among the multiple candidate vector registers that needs to be written (filled) into the vector instruction lookup table Table can be called a target vector register. The target vector register can be a single vector register or multiple vector registers (i.e., a group of vector registers). In other words, the embodiment of the present disclosure can determine a single vector register or a group of vector registers as the target vector register for writing into the vector instruction lookup table Table. The target vector register can be determined in any possible manner.

[0047] The element (data) in the target vector register that needs to be written into the vector instruction lookup table Table can be called the first element, that is, the content (element) in the target vector register is filled into the vector instruction lookup table Table. In the case where the target vector register is multiple vector registers, the first element can be all elements stored in the multiple target vector registers; or, in the case where the target vector register is a single vector register, the first element can be all or part of the elements in the target vector register.

[0048] In the disclosed embodiment, different table filling rules can be configured for different table filling types. That is, the first and second types of candidate vector registers correspond to different table filling rules. In this embodiment, the target vector register can be determined using the table filling rule corresponding to the table filling type, and the first element stored in the target vector register can be written into the vector instruction lookup table. The specific content of the table filling rule is not specifically limited here.

[0049] In some embodiments, a preset table lookup rule may be used to obtain a second element to be queried from a vector instruction lookup table, and the second element may be written into a preset vector destination register.

[0050] Among them, the element currently required to be queried in the vector instruction query table Table can be called the second element, that is, the second element belongs to the first element, and the second element can be one element or multiple elements.

[0051] In an embodiment of the present disclosure, a table lookup rule (also referred to as a vector table lookup instruction) can be pre-configured. The table lookup rule is used to obtain the second element from the vector instruction lookup table. That is to say, the embodiment of the present disclosure can read the vector element directly from the vector instruction lookup table without reading the vector element from the vector register, thereby reducing the occupation of the vector register space and register port and reducing the number of memory accesses. The table lookup rule can be an arbitrary rule. In some embodiments, the form of the table lookup rule (i.e., table lookup instruction) can be recorded as: table_find.v vdest, vidx, where table_find.v represents a vector table lookup in the vector instruction set, vidx represents a vector index register, and vdest represents a vector destination register.

[0052] In some embodiments, the table lookup rule may be to first determine a vector index register vidx. For example, a register may be randomly selected from a plurality of candidate vector registers as the vector index register vidx.

[0053] Furthermore, the index bit width is determined according to the number of entries M in the vector instruction lookup table, that is, according to M=2 索引位宽 Determine the index bit width. For example, the number of entries in the vector instruction lookup table of the embodiment of the present disclosure is 256 (ie, M=256), that is: 256=2 8 , that is to say, the index bit width of the vector instruction query table in the embodiment of the present disclosure is 8 bits.

[0054] Furthermore, the ratio of the register width VLEN of the vector index register vidx to the index bit width is calculated as the number of indexes. For example, as shown in Figures 2A and 2B, the register width of a vector index register vidx randomly selected from multiple candidate vector registers is 256 bits, and the number of indexes is 32. That is, the 256-bit vector index register vidx can be divided into 32 8-bit indexes, represented as idx0, idx1, idx2, idx3, ..., idx29, idx30, idx31; for another example, as shown in Figures 3A and 3B, the register width of a vector index register vidx randomly selected from multiple candidate vector registers is 128 bits, and the number of indexes is 16. That is, the 128-bit vector index register vidx is divided into 16 8-bit indexes, represented as idx0, idx1, idx2, idx3, ..., idx29, idx30, idx15.

[0055] Furthermore, the disclosed embodiment performs a parallel lookup of the vector instruction lookup table based on the number of indexes and the target index value to be queried to obtain a second element corresponding to the target index value. Specifically, the first element in the vector instruction lookup table may have a corresponding index value, such as the sequence number of a storage item. For example, if there are 256 storage items, the index values ​​are 0, 1, 2, ..., 255, respectively. The index value corresponding to the element to be queried may be referred to as the target index value, and the element found corresponding to the target index value may be referred to as the second element.

[0056] For example, as shown in Figures 2A and 2B, the 256-bit vector index register vidx in the embodiment of the present disclosure is divided into 32 8-bit indexes idx0, idx1, idx2, idx3, ..., idx29, idx30, idx31, and the target index value is, for example, {254, 251, 250, ..., 7, 5, 3, 2}, totaling 32. Then, the embodiment of the present disclosure can use 32 8-bit indexes to perform parallel lookup on the 32 target index values ​​in the vector instruction lookup table, idx0, idx1, idx2, idx3, ..., idx29, idx30 , idx31 are 2 (binary 00000010), 3 (binary 00000011), 5 (binary 00000101), 7 (binary 00000111), ..., 250 (binary 11111010), 251 (binary 11111011), 254 (binary 11111110), that is, the 32 second elements found in parallel from the vector instruction lookup table Table according to the index vidx are a2, a3, a5, a7, ..., a250, a251, a254, each element is 8 bits.

[0057] For another example, as shown in Figures 3A and 3B, the 128-bit vector index register vidx in the embodiment of the present disclosure is divided into 16 8-bit indexes idx0, idx1, idx2, idx3, ..., idx15, and the target index values ​​are, for example, {254, 251, 122, ..., 7, 5, 3, 2}, totaling 16. Then, the embodiment of the present disclosure can use 16 8-bit indexes to perform parallel lookup on the 16 target index values ​​in the vector instruction lookup table, where idx0, idx1, idx2, idx3, ..., idx15 are 2 (two) respectively. In other words, the 16 second elements found in parallel from the vector instruction lookup table Table according to the index vidx are a2, a3, a5, a7, ..., a250, a251, a254, and each element is 8 bits.

[0058] Furthermore, the embodiment of the present disclosure writes the second element into a preset vector destination register. For example, any one register (e.g., v25) can be selected from multiple candidate vector registers as the vector destination register, which can be represented by vdest. The embodiment of the present disclosure can write the obtained second element into the vector destination register vdest to complete the vector table lookup operation. For example, the 32 second elements a2, a3, a5, a7, ..., a250, a251, a254, etc. found are written back to the vector destination register vdest (for example, v25), and the value of the vector destination register vdest is {a254, a251, a250, ..., a7, a5, a3, a2}; for another example, the 16 second elements a2, a3, a5, a7, ..., a250, a251, a254, etc. are written back to the vector destination register vdest (for example, v25), and the value of the vector destination register vdest is {a254, a251, a250, ..., a7, a5, a3, a2}.

[0059] In some embodiments, the vector index register vidx and the vector destination register vdest need to have the same number of elements, but the element widths may be different. In this case, the EEW and EMUL (the number of registers in the register group when the element width in the register is EEW) of the vector index register vidx and the vector destination register vdest are not equal to SEW and LMUL, but EEW / EMUL=SEW / LMUL, so as to ensure that the number of elements is the same. For example, the EEW of the vector index register vidx is SEW, and EMUL is LMUL, but the EEW of the vector destination register vdest is 2*SEW, and EMUL is 2*LMUL, that is, the element width of the vector index register vidx is different from the element width of the vector destination register vdest. In this case, in the process of writing the second element into the preset vector destination register in the embodiment of the present disclosure, the size relationship between the element width of the vector destination register vdest and the element width of the vector index register vidx can be judged. When the element width of the vector destination register is greater than the element width of the vector index register, and the element width of the vector destination register is the same as the number of storage item bits, the table lookup instruction of the embodiment of the present disclosure is a widening instruction, and the number of vector destination registers is determined according to the above-mentioned EEW / EMUL=SEW / LMUL relationship, that is: a group of multiple vector destination registers vdest, wherein the number of a group of vector destination registers EMUL=EEW*LMUL / SEW; further, the second element is written into multiple vector destination registers.

[0060] For example, Figure 4A is a structural diagram of another 256-bit wide vector register provided according to an embodiment of the present disclosure, and Figure 4B is a structural diagram of a vector instruction lookup table corresponding to the vector register in Figure 4A. As shown in Figure 4B, the vector instruction lookup table (Table) configured in the embodiment of the present disclosure is, for example, 256 items (i.e., M = 256), including a0, a1, ..., a255 storage items; each SEW is a 16-bit integer, i.e.: N = 16, then the storage capacity of the vector instruction lookup table = 256*16 = 4096 bits, SEW is other values, and so on. As shown in Figures 4A and 4B , the register width VLEN of a vector index register vidx (LMUL=1) is 256 bits, the element width EEW=SEW=8 bits for each element, M=256 items, N=16 bits, and the element width EEW=16 for the vector destination register vdest. Therefore, the number of vector destination registers EMUL=EEW*LMUL / SEW=16*1 / 8=2, which means a set of two vector destination registers, for example, v24 and v25. The 32 elements retrieved from the table in parallel according to the index vidx are b2, b3, b5, b7, ..., b250, b251, b254, each 16 bits, and are written back to the vector destination registers v24 and v25. The value of the vector destination register v24 is {…, b7, b5, b3, b2}, and the value of the vector destination register v25 is {b254, b251, b250, …}, completing the vector table lookup. In Figures 4A and 4B, _low and _high represent the low 8 bits and high 8 bits of the element, respectively.

[0061] In practical applications, the table lookup instruction can be recorded as table_find.v vdest,vidx, where vdest represents the vector destination register and vidx represents the vector index register. For example, if vidx is v24 and vdest is v25, the table lookup instruction is table_find.v v25,v24.

[0062] In an embodiment of the present disclosure, a vector instruction lookup table is configured in a storage space preset by a processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of storage item bits, and a table filling type corresponding to a candidate vector register to be filled in the table is determined, wherein the table filling type includes a first type and a second type, wherein the first type is that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is less than the storage capacity, and a table filling rule corresponding to the table filling type is used to write the first element stored in a target vector register in multiple candidate vector registers into the vector instruction lookup table, and a preset table lookup rule is used to obtain the second element to be queried from the vector instruction lookup table, thereby reducing the occupancy of the vector register space and register port, reducing the number of memory accesses, and utilizing the table filling rules and table lookup rules corresponding to the table filling type to quickly perform table filling and table lookup operations, thereby improving processor performance.

[0063] FIG5 is a flow chart of a method for filling and looking up a table of vector instructions in a processor according to an embodiment of the present disclosure. As shown in FIG5 , the method includes steps S501 to S506 .

[0064] S501: configuring a vector instruction lookup table in a storage space preset by a processor.

[0065] S502: Determine the table filling type corresponding to the candidate vector register to be filled.

[0066] The specific description of S501-S502 can be found in the above embodiment and will not be repeated here.

[0067] S503: Calculate a ratio of the storage capacity to the register width of the candidate vector register to serve as a first number of registers in the register group.

[0068] In the embodiment of the present disclosure, the table filling type corresponding to the candidate vector register is the first type. In this case, the table filling rule of the embodiment of the present disclosure is to first calculate the ratio of the storage capacity to the register width (VLEN) of the candidate vector register, and use the ratio as the first number LMUL of the actual registers in the register group, that is, the first number LMUL = M*N / VLEN.

[0069] For example, if the width VLEN of the candidate vector register is 256 bits and M*N=2048, then the first number LMUL is 8, that is, LMUL=2048 / 256=8; for another example, if the width VLEN of the candidate vector register is 512 bits, then the first number LMUL is 4; for another example, if the width VLEN of the candidate vector register is 1024 bits, then the first number LMUL is 2; for another example, if the width VLEN of the candidate vector register is 2048 bits, then the first number LMUL is 1; for another example, if the width VLEN of the candidate vector register is 4096 bits, then the first number LMUL is 1 / 2, that is, 1 / 2 registers are grouped together; for another example, if the width VLEN of the candidate vector register is 8192 bits, then the first number LMUL is 1 / 4, that is, 1 / 4 registers are grouped together; for another example, if the width VLEN of the candidate vector register is 16384 bits, then the first number LMUL is 1 / 8, that is, 1 / 8 registers are grouped together, and so on.

[0070] S504: Determine a first number of registers from a plurality of candidate vector registers as target vector registers.

[0071] That is, a first number LMUL of registers is determined from the 32 candidate vector registers as a group of target vector registers. For example, 8 (LMUL) registers are selected as a group of target vector registers, or 4 registers are selected as a group of target vector registers, or 2 registers are selected as a group of target vector registers, etc. The target vector registers can be determined from the 32 candidate vector registers in any manner, for example, by randomly selecting a group of target vector registers.

[0072] In some embodiments, in order to improve the efficiency of table filling and subsequent table lookup, embodiments of the present disclosure may determine a continuous group of registers as target vector registers.

[0073] The embodiment of the present disclosure can first determine the source register number from the numbers of multiple candidate vector registers, which can be represented by vsrc. For example, the numbers of the 32 candidate vector registers are 0, 1, 2, ..., 31, and the embodiment of the present disclosure can determine a source register number vsrc from the multiple numbers.

[0074] For example, the source register number vsrc may be any one of 0, 1, 2, ..., 31.

[0075] For another example, the source register number can be aligned with the first number LMUL. For example, if LMUL is 8, the source register number vsrc of the vector table fill instruction (table fill rule) can be any one of 0, 8, 16, and 24. If LMUL is 4, the source register number vsrc of the vector table fill instruction can be any one of 0, 4, 8, 12, 16, 20, 24, and 28. If LMUL is 2, the source register number vsrc of the vector table fill instruction can be any one of 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, and 30. If LMUL is 1 / 8, 1 / 4, 1 / 2, or 1, the source register number vsrc of the vector table fill instruction can be any register number.

[0076] Furthermore, a first number of registers consecutively starting from the source register number is determined as the target vector registers.

[0077] For example, as shown in Figures 2A and 2B, the register width VLEN is 256 bits, LMUL is 8, and the source register number vsrc is, for example, 16 (i.e., v16). Then, the eight consecutive registers starting from number 16 can be determined as a group of target vector registers, that is, the target vector registers are v16 to v23.

[0078] S505: Write the first element stored in the target vector register into the vector instruction lookup table.

[0079] In actual applications, the table filling rules (table filling instructions) corresponding to the first type can be pre-configured and recorded as table_fill.v vsrc, where table_fill.v represents the table filling of the vectors in the vector instruction set, and vsrc represents the source register number. For example, if the source register number vsrc is 16, the table filling instruction is table_fill.v v16. Further, the table_fill.v v16 instruction is used to fill the elements a0-a255 (i.e., the first elements) in a group of 8 target vector registers v16 to v23 into the 0th to 255th items of the vector instruction lookup table table. In other words, in the embodiment of the present disclosure, the number of first elements of the target vector register is the same as the number of items in the vector instruction lookup table. Thus, the embodiment of the present disclosure can use the table filling rules to write elements in registers greater than or equal to 256 bits into the vector instruction lookup table.

[0080] S506: Obtain the second element to be queried from the vector instruction query table using a preset table lookup rule.

[0081] The specific description of S506 refers to the above embodiment and will not be repeated here.

[0082] In an embodiment of the present disclosure, a vector instruction lookup table is configured in a storage space preset by a processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of bits of the storage items, and a table filling type corresponding to a candidate vector register to be filled is determined, wherein the table filling type includes a first type and a second type, wherein the first type is that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is less than the storage capacity, and a table filling rule corresponding to the table filling type is used to write the first element stored in a target vector register among multiple candidate vector registers into the vector instruction lookup table, and a preset table lookup rule is used to obtain the second element to be queried from the vector instruction lookup table, thereby reducing the occupation of the vector register space and register ports, reducing the number of memory accesses, and using the table filling rules and table lookup rules corresponding to the table filling type to quickly perform table filling and table lookup operations, thereby improving processor performance. In addition, the embodiment of the present disclosure can use the table filling rules to write elements in registers greater than or equal to 256 bits into the vector instruction lookup table.

[0083] FIG6 is a flow chart of a method for filling and looking up a table of vector instructions in a processor according to an embodiment of the present disclosure. As shown in FIG6 , the method includes steps S601 to S606 .

[0084] S601: configuring a vector instruction lookup table in a storage space preset by a processor.

[0085] S602: Determine the table filling type corresponding to the candidate vector register to be filled.

[0086] The specific description of S601-S602 can be found in the above embodiment and will not be repeated here.

[0087] S603: Calculate the ratio of the storage capacity to the first target value as the number of times to fill in the form.

[0088] The first target value is the product of the register width of the candidate vector register and the maximum number of register groups.

[0089] In the embodiment of the present disclosure, the table filling type corresponding to the candidate vector register is the second type. In this case, the table filling rule of the embodiment of the present disclosure is to first calculate the ratio of the storage capacity (M*N) to the first target value as the number of table fillings, wherein the first target value is the product (VLEN*maximum LMUL) of the register width VLEN of the candidate vector register and the maximum number of register groups (maximum LMUL=8), that is, the number of table fillings = M*N / VLEN*maximum LMUL.

[0090] Among them, the number of table filling times corresponds to the number of table filling instructions. Each table filling instruction can write the first element in a set of target vector registers into the vector instruction lookup table. That is to say, when the table filling type is the second type, multiple table filling instructions are required to perform multiple table filling operations.

[0091] For example, as shown in Figures 3A and 3B, if the storage capacity (M*N) of the vector instruction lookup table is 2048, the register width VLEN is 128, and the maximum LMUL is 8, then the number of table fills (i.e., the number of table fill instructions) is M*N / VLEN*maximum LMUL=2048 / 128*8=2, which means that two table fill instructions are required to fill the table twice; for another example, if the storage capacity (M*N) of the vector instruction lookup table is 2048, the register width VLEN is 64, and the maximum LMUL is 8, then the number of table fills (i.e., the number of table fill instructions) is 2048 / 64*8=4, which means that four table fill instructions are required to fill the table four times.

[0092] S604: Determine, from the plurality of candidate vector registers, a plurality of register groups having the same number of times as the number of times the table is filled.

[0093] Each register group includes a second number of target vector registers. In the embodiment of the present disclosure, the number of registers in each register group may be referred to as a second number (LMUL). The second number LMUL may be a fixed value, for example, LMUL=8, that is, 8 target vector registers are regarded as a register group.

[0094] In the disclosed embodiment, multiple register groups equal to the number of table fills can be determined from multiple candidate vector registers. For example, if the number of table fills is 2, two register groups are determined, each of which includes 8 target vector registers. The multiple register groups can be determined in any manner, for example, by randomly selecting 8 target vector registers as a register group.

[0095] In some embodiments, a plurality of source register numbers equal to the number of times the table is filled are determined from the plurality of candidate vector register numbers, wherein the interval between the source register numbers is at least a second number.

[0096] For example, the number of table filling operations is 2 (i.e., 2 table filling instructions), and the multiple candidate vector registers are numbered 0, 1, 2, ..., 31. Then, the embodiment of the present disclosure can determine 2 numbers from the multiple numbers as source register numbers vsrc, wherein the interval between the two source register numbers vsrc is at least the second number (8), for example, the two source register numbers vsrc are 8 and 16 respectively.

[0097] Furthermore, a second number of registers consecutively starting from each source register number is determined to constitute each register group. In other words, each source register number is used as the starting bit of a register group, and a second number of registers consecutively starting from the starting bit are determined as the target vector registers in the register group.

[0098] For example, the two source register numbers vsrc are 8 and 16 respectively. In this embodiment of the present disclosure, v8 to v15 may be determined as one register group, and v16 to v23 may be determined as another register group.

[0099] S605: Write the first element stored in the target vector register in each register group into the vector instruction lookup table in sequence.

[0100] That is to say, the embodiment of the present disclosure can first write the first element stored in the target vector registers from v8 to v15 (register grouping) into the vector instruction lookup table, and then write the first element stored in the target vector registers from v16 to v23 (register grouping) into the vector instruction lookup table.

[0101] In some embodiments, during the table filling process, the embodiments of the present disclosure may also determine multiple offset numbers (also referred to as offsets) corresponding to multiple register groups, which may be represented by imm. The offset number imm is a non-negative integer, wherein the multiple offset numbers are integers from 0 to n in sequence, where n is the number of table fillings minus one, that is, the offset number imm takes a value from 0 to M*N / VLEN*maximumLMUL-1.

[0102] For example, if VLEN is 128 bits and the value of LMUL is 8, the number of table fills is 2 (two table fill instructions are required to complete), and the offset numbers imm corresponding to the register groups are 0 and 1 respectively. That is, the offset number imm of the first table fill instruction is 0 (binary 00000000), and the offset number imm of the second table fill instruction is 1 (binary 00000001); for another example, if VLEN is 64 bits and the value of LMUL is also 8, the number of table fills is 4 ( Requires 4 table filling instructions to complete), the offset numbers imm corresponding to the register groups are 0, 1, 2, and 3 respectively. That is to say, the offset number imm of the first table filling instruction is 0 (binary 00000000), the offset number imm of the second table filling instruction is 1 (binary 00000001), the offset number imm of the third table filling instruction is 2 (binary 00000010), and the offset number imm of the fourth table filling instruction is 3 (binary 00000011).

[0103] Furthermore, the product of the offset number imm corresponding to each register group and the second target value is calculated as the starting fill bit for each register group in the vector instruction lookup table. The starting fill bit, also called the starting fill item, is used to describe the starting item written to the vector instruction lookup table for each register group. The second target value is the ratio of the first target value (VLEN*maximum LMUL) to the number of storage item bits (N), that is, starting fill bit = imm*VLEN*maximum LMUL / N.

[0104] For example, the number of storage item bits N=8, VLEN is 128 bits, and the offset numbers imm corresponding to the corresponding two register groups are 0 and 1. Then the starting fill bits of the first register group are 0*128*8 / 8=0, and the starting fill bits of the second register group are 1*128*8 / 8=128.

[0105] Furthermore, based on the start fill bit, the first element stored in the target vector register in each register group is sequentially written into the vector instruction lookup table.

[0106] In practice, the table-filling instructions for the second type can be written as: table_fill.v vsrc imm, where table_fill.v represents table-filling for a vector in the vector instruction set, vsrc represents the source register number, and imm represents the offset. For example, if VLEN is 128 bits, LMUL is 8, and the offset imm is 0 and 1, and the source register numbers vsrc are vector registers 8 and 16, respectively, then the two table-filling instructions can be written as table_fill.v v8 0 and table_fill.v v161. This means that the table_fill.v v8 0 instruction fills the first elements a0-a127 of the eight target vector registers v8 to v15 into entries 0 to 127 of the vector instruction lookup table, and the table_fill.v v16,1 instruction fills the elements a128-a255 of the eight registers v16 to v23 into entries 128 to 255 of the vector instruction lookup table. Therefore, the embodiment of the present disclosure can use the table filling rule to write elements in a register smaller than 256 bits into the vector instruction lookup table.

[0107] It should be noted that the table filling process and the table lookup process in the embodiment of the present disclosure can be performed sequentially or separately.

[0108] In an embodiment of the present disclosure, a vector instruction lookup table is configured in a storage space preset by a processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of bits of the storage items, and a table filling type corresponding to a candidate vector register to be filled is determined, wherein the table filling type includes a first type and a second type, wherein the first type is that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is less than the storage capacity, and a table filling rule corresponding to the table filling type is used to write the first element stored in a target vector register among multiple candidate vector registers into the vector instruction lookup table, and a preset table lookup rule is used to obtain the second element to be queried from the vector instruction lookup table, thereby reducing the occupation of the vector register space and register ports, reducing the number of memory accesses, and using the table filling rules and table lookup rules corresponding to the table filling type to quickly perform table filling and table lookup operations, thereby improving processor performance. In addition, the present disclosure embodiment can use the table filling rules to write elements in registers smaller than 256 bits into the vector instruction lookup table.

[0109] In order to implement the above embodiments, the present disclosure further proposes a vector instruction table filling and table lookup device in a processor.

[0110] FIG7 is a schematic diagram of a vector instruction table filling and table lookup device in a processor according to another embodiment of the present disclosure.

[0111] As shown in FIG7 , the vector instruction table filling and table lookup device 70 in the processor includes:

[0112] A configuration module 701 is configured to configure a vector instruction lookup table in a storage space preset by the processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of entries and the number of storage item bits;

[0113] a determination module 702 for determining a table filling type corresponding to a candidate vector register to be filled, wherein the table filling type includes a first type and a second type, wherein the first type is when the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is when the product of the register width and the maximum number of register groups is less than the storage capacity;

[0114] a table filling module 703 configured to write the first element stored in the target vector register among the plurality of candidate vector registers into the vector instruction lookup table using a table filling rule corresponding to the table filling type; and

[0115] The table lookup module 704 is configured to obtain the second element to be looked up from the vector instruction lookup table using a preset table lookup rule.

[0116] In some embodiments, when the table filling type is the first type, the table filling module 703 is specifically used to: calculate the ratio of the storage capacity to the register width of the candidate vector register as the first number of registers in the register group; determine a first number of registers from multiple candidate vector registers as target vector registers; and write the first element stored in the target vector register into the vector instruction lookup table.

[0117] In some embodiments, the table filling module 703 is specifically configured to: determine a source register number from a plurality of candidate vector register numbers; and determine a first number of consecutive registers starting from the source register number as target vector registers.

[0118] In some embodiments, when the table filling type is the second type, the table filling module 703 is specifically used to: calculate the ratio of the storage capacity to the first target value as the number of table fillings, where the first target value is the product of the register width of the candidate vector register and the maximum number of register groups; determine a plurality of register groups with the same number of table fillings from a plurality of candidate vector registers, where each register group includes a second number of target vector registers; and write the first element stored in the target vector register in each register group into the vector instruction lookup table in turn.

[0119] In some embodiments, the table filling module 703 is specifically used to: determine a plurality of source register numbers equal to the number of table filling times from the plurality of candidate vector register numbers, wherein the interval between the source register numbers is at least a second number; and determine that a second number of consecutive registers starting from each source register number constitute each register group.

[0120] In some embodiments, the device 70 also includes: a first calculation module, used to determine multiple offset numbers corresponding to multiple register groups, wherein the multiple offset numbers are integers from 0 to n in sequence, and n is the number of table fillings minus one; a second calculation module, used to calculate the product of the offset number corresponding to each register group and the second target value, as the starting fill bit of each register group in the vector instruction query table, wherein the second target value is the ratio of the first target value to the number of storage item bits; and a table filling module 703, specifically used to: based on the starting fill bit, write the first element stored in the target vector register in each register group into the vector instruction query table in sequence.

[0121] In some embodiments, the table lookup module 704 is specifically used to: determine a vector index register; determine the index bit width based on the number of items in the vector instruction lookup table; calculate the ratio of the register width of the vector index register to the index bit width as the number of indexes; perform a parallel lookup on the vector instruction lookup table based on the number of indexes and the target index value to be queried to obtain a second element corresponding to the target index value; and write the second element into a preset vector destination register.

[0122] In some embodiments, when the element width of the vector destination register is greater than the element width of the vector index register, and the element width of the vector destination register is the same as the number of storage item bits, the table lookup module is specifically used to: determine multiple vector destination registers; and write the second element into the multiple vector destination registers.

[0123] In some embodiments, the form of the table filling rule corresponding to the first type is: table_fill.v vsrc, and the form of the table filling rule corresponding to the second type is: table_fill.v vsrc,imm; wherein, table_fill.v represents the vector table filling in the vector instruction set, vsrc represents the source register number, and imm represents the offset number.

[0124] In some embodiments, the table lookup rule is in the form of: table_find.v vdest, vidx, where table_find.v represents a vector table lookup in a vector instruction set, vidx represents a vector index register, and vdest represents a vector destination register.

[0125] In an embodiment of the present disclosure, a vector instruction lookup table is configured in a storage space preset by a processor, wherein the storage capacity of the vector instruction lookup table is the product of the number of items and the number of storage item bits, and a table filling type corresponding to a candidate vector register to be filled in the table is determined, wherein the table filling type includes a first type and a second type, wherein the first type is that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is less than the storage capacity, and a table filling rule corresponding to the table filling type is used to write the first element stored in a target vector register in multiple candidate vector registers into the vector instruction lookup table, and a preset table lookup rule is used to obtain the second element to be queried from the vector instruction lookup table, thereby reducing the occupancy of the vector register space and register port, reducing the number of memory accesses, and utilizing the table filling rules and table lookup rules corresponding to the table filling type to quickly perform table filling and table lookup operations, thereby improving processor performance.

[0126] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0127] In order to implement the above embodiments, the present disclosure further proposes a computer program product. When an instruction processor in the computer program product executes, the vector instruction table filling and table lookup method in the processor proposed in the above embodiments of the present disclosure is executed.

[0128] Figure 8 shows a block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure. The electronic device 12 shown in Figure 8 is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0129] 8 , the electronic device 12 is implemented as a general-purpose computing device. Components of the electronic device 12 may include, but are not limited to, one or more processors 16 , a system memory 28 , and a bus 18 connecting various system components (including the system memory 28 and the processor 16 ).

[0130] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnection (PCI) bus.

[0131] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0132] Memory 28 may include computer-readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer-readable storage media. By way of example only, storage system 34 may be configured to read and write to non-removable, non-volatile magnetic media (not shown in FIG. 8 , and commonly referred to as a "hard drive").

[0133] Although not shown in FIG8 , a disk drive for reading and writing to a removable non-volatile disk (e.g., a floppy disk) and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a Compact Disc Read Only Memory (CD-ROM), a Digital Video Disc Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data media interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present disclosure.

[0134] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally implement the functions and / or methods of the embodiments described herein.

[0135] The electronic device 12 can also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). This communication can occur via an input / output (I / O) interface 22. Furthermore, the electronic device 12 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that, although not shown, other hardware and / or software modules can be used in conjunction with the electronic device 12, including but not limited to microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0136] The processor 16 executes various functional applications by running programs stored in the system memory 28, such as implementing the vector instruction table filling and table lookup methods in the processor mentioned in the above embodiments.

[0137] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.

[0138] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

[0139] It should be noted that, in the description of this disclosure, the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance. In addition, in the description of this disclosure, unless otherwise specified, the meaning of "plurality" is two or more.

[0140] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.

[0141] It should be understood that various parts of the present disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0142] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0143] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing module, or each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.

[0144] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.

[0145] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with that embodiment or example is included in at least one embodiment or example of the present disclosure. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

[0146] Although the embodiments of the present disclosure have been shown and described above, it is understood that the above embodiments are illustrative and are not to be construed as limitations on the present disclosure. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present disclosure.

Claims

1. A method for filling and looking up a table of vector instructions in a processor, comprising: A vector instruction query table is configured in a storage space preset by the processor, wherein the storage capacity of the vector instruction query table is the product of the number of items and the number of storage item bits; Determine a table filling type corresponding to the candidate vector register to be filled, wherein the table filling type includes a first type and a second type, the first type is that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type is that the product of the register width and the maximum number of register groups is less than the storage capacity; Using a table filling rule corresponding to the table filling type, writing a first element stored in a target vector register among a plurality of candidate vector registers into the vector instruction lookup table; In a case where the table filling type is the first type, using a table filling rule corresponding to the table filling type to write a first element stored in a target vector register among multiple candidate vector registers into the vector instruction lookup table includes: Calculating a ratio of the storage capacity to a register width of the candidate vector register as a first number of registers in a register group; Determine a source register number from the numbers of the plurality of candidate vector registers; and determine a first number of registers starting from the source register number and continuing as the target vector registers; and The first element stored in the target vector register is written into the vector instruction lookup table.

2. The method of claim 1, wherein: When the table filling type is the second type, writing the first element stored in the target vector register among the plurality of candidate vector registers into the vector instruction lookup table by using a table filling rule corresponding to the table filling type includes: Calculating a ratio of the storage capacity to a first target value as the number of table filling times, wherein the first target value is a product of a register width of the candidate vector register and a maximum number of register groups; Determine a plurality of register groups having the same number of table filling times from the plurality of candidate vector registers, wherein each register group includes a second number of target vector registers; and The first element stored in the target vector register in each register group is sequentially written into the vector instruction lookup table.

3. The method of claim 2, wherein: The determining, from the plurality of candidate vector registers, a plurality of register groups having the same number of table filling times comprises: Determine, from the plurality of candidate vector register numbers, a plurality of source register numbers having the same number of table filling times, wherein the interval between the source register numbers is at least the second number; It is determined that a second number of registers starting from each of the source register numbers constitute each register group.

4. The method of claim 3, further comprising: Determine a plurality of offset numbers corresponding to the plurality of register groups, wherein the plurality of offset numbers are integers from 0 to n in sequence, and n is a value obtained by subtracting one from the number of table filling times; Calculate the product of the offset number corresponding to each register group and a second target value as the starting fill bit of each register group in the vector instruction query table, wherein the second target value is the ratio of the first target value to the number of storage item bits; Furthermore, the step of sequentially writing the first element stored in the target vector register in each register group into the vector instruction lookup table comprises: Based on the start filling bit, the first element stored in the target vector register in each register group is written into the vector instruction lookup table in sequence.

5. The method of claim 1, further comprising: Obtaining a second element to be queried from the vector instruction query table using a preset table query rule; as well as The second element is written into a preset vector destination register.

6. The method of claim 5, wherein: The obtaining the second element to be queried from the vector instruction query table by using a preset table query rule includes: Identify a vector index register; Determine the index bit width according to the number of entries in the vector instruction query table; Calculating a ratio of a register width of the vector index register to the index bit width as the number of indexes; The vector instruction query table is looked up in parallel based on the index quantity and the target index value to be queried to obtain the second element corresponding to the target index value.

7. The method of claim 6, wherein: In a case where the element width of the vector destination register is greater than the element width of the vector index register, and the element width of the vector destination register is the same as the number of bits of the storage item, writing the second element into a preset vector destination register comprises: determining a plurality of vector destination registers; and The second element is written to the plurality of vector destination registers.

8. The method of claim 4, wherein: The form of the table filling rule corresponding to the first type is: table_fill.v vsrc, and the form of the table filling rule corresponding to the second type is: table_fill.v vsrc,imm; wherein table_fill.v represents the table filling for vectors in the vector instruction set, vsrc represents the source register number, and imm represents the offset number.

9. The method of claim 6, wherein: The table lookup rule is in the form of: table_find.v vdest, vidx, where table_find.v represents a vector table lookup in a vector instruction set, vidx represents a vector index register, and vdest represents a vector destination register.

10. A vector instruction table filling and table lookup device in a processor, comprising: A configuration module, used to configure a vector instruction query table in a storage space preset by the processor, wherein the storage capacity of the vector instruction query table is the product of the number of items and the number of storage item bits; a determination module, configured to determine a table filling type corresponding to a candidate vector register to be filled in a table, wherein the table filling type includes a first type and a second type, the first type being that the product of the register width and the maximum number of register groups is greater than or equal to the storage capacity, and the second type being that the product of the register width and the maximum number of register groups is less than the storage capacity; a table filling module, configured to write a first element stored in a target vector register among a plurality of candidate vector registers into the vector instruction lookup table by using a table filling rule corresponding to the table filling type; When the form filling type is the first type, The form filling module is used for: Calculating a ratio of the storage capacity to a register width of the candidate vector register as a first number of registers in a register group; determining a first number of registers from the plurality of candidate vector registers as the target vector registers; and Writing the first element stored in the target vector register into the vector instruction lookup table; The form filling module is used for: determining a source register number from the plurality of candidate vector register numbers; and A first number of registers starting from the source register number and continuing from the source register number are determined as the target vector registers.

11. The device of claim 10, wherein: When the form filling type is the second type, the form filling module is used to: Calculating a ratio of the storage capacity to a first target value as the number of table filling times, wherein the first target value is a product of a register width of the candidate vector register and a maximum number of register groups; Determine a plurality of register groups having the same number of table filling times from the plurality of candidate vector registers, wherein each register group includes a second number of target vector registers; and The first element stored in the target vector register in each register group is sequentially written into the vector instruction lookup table.

12. The device of claim 11, wherein: The form filling module is used for: Determine, from the plurality of candidate vector register numbers, a plurality of source register numbers having the same number of table filling times, wherein the interval between the source register numbers is at least the second number; It is determined that a second number of registers starting from each of the source register numbers constitute each register group.

13. The apparatus of claim 12, further comprising: A first calculation module is used to determine a plurality of offset numbers corresponding to a plurality of register groups, wherein the plurality of offset numbers are integers from 0 to n in sequence, and n is a value obtained by subtracting one from the number of table filling times; A second calculation module is used to calculate the product of the offset number corresponding to each register group and a second target value as the starting fill bit of each register group in the vector instruction query table, wherein the second target value is the ratio of the first target value to the number of storage items; Furthermore, the table filling module is used to: based on the start filling bit, write the first element stored in the target vector register in each register group into the vector instruction lookup table in sequence.

14. The apparatus of claim 10, further comprising: A table lookup module, used to obtain a second element to be queried from the vector instruction lookup table using a preset table lookup rule; And writing the second element into a preset vector destination register.

15. The device of claim 14, wherein: The table lookup module is used for: Identify a vector index register; Determine the index bit width according to the number of entries in the vector instruction query table; Calculating a ratio of a register width of the vector index register to the index bit width as the number of indexes; The vector instruction query table is looked up in parallel based on the index quantity and the target index value to be queried to obtain the second element corresponding to the target index value.

16. The device of claim 15, wherein: In the case where the element width of the vector destination register is greater than the element width of the vector index register, and the element width of the vector destination register is the same as the number of storage item bits, the table lookup module is used to: determining a plurality of vector destination registers; and The second element is written to the plurality of vector destination registers.

17. The device of claim 13, wherein: The form of the table filling rule corresponding to the first type is: table_fill.v vsrc, and the form of the table filling rule corresponding to the second type is: table_fill.v vsrc,imm; wherein table_fill.v represents the table filling for vectors in the vector instruction set, vsrc represents the source register number, and imm represents the offset number.

18. The device of claim 15, wherein: The table lookup rule is in the form of: table_find.v vdest, vidx, where table_find.v represents a vector table lookup in a vector instruction set, vidx represents a vector index register, and vdest represents a vector destination register.

19. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.

20. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9.

21. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Vector instruction table filling and table lookup method and device in processor and electronic equipment

    CN115951937A

  • Method for performing random read access to a block of data using parallel LUT read instruction in vector processors

    US20160124651A1

  • Histogram generation with vector operations in SIMD and VLIW processor by consolidating LUTs storing parallel update incremented count values for vector data elements

    US7506135B1