Acceleration device, method, storage medium and computer program product

By introducing a second processor into the data center processor and using the RISC-V instruction set to perform the modular operation of the encryption algorithm, the problem of encryption algorithm speed reduction in the data center is solved and more efficient encryption processing is achieved.

CN118796151APending Publication Date: 2024-10-18CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410520056.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-26
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

Existing encryption algorithms reduce data processing speed due to encryption and decryption operations in data centers, and the large scale of dense data in homomorphic encryption algorithms reduces processing speed. How to speed up encryption algorithms has become an urgent problem to be solved.

Method used

By introducing a second processor into the processor and using the RISC-V instruction set to perform modular operations of the encryption algorithm, the number of instructions and data-related operations performed by the main processor is reduced, and more efficient modular operations are achieved.

Benefits of technology

It improves the execution speed of the encryption algorithm in the data center, improves the operating efficiency of the encryption algorithm, and solves the inefficiency problem of the processor in the fast modular algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796151A_ABST
    Figure CN118796151A_ABST
Patent Text Reader

Abstract

The invention discloses an acceleration device and method, a storage medium and a computer program product. The acceleration device comprises a first processor and a second processor, the first processor is used for sending a to-be-executed instruction and to-be-processed data associated with the to-be-executed instruction to the second processor under the condition that the to-be-executed instruction is associated with modular operation of an encryption algorithm; and the second processor is used for receiving the to-be-executed instruction and the to-be-processed data sent by the first processor, executing modular operation associated with the to-be-executed instruction based on the to-be-executed instruction and the to-be-processed data to obtain an operation result, and sending the operation result to the first processor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to an acceleration device, method, storage medium and computer program product. Background Art

[0002] With the development of cloud services, data centers have become a key infrastructure for enterprises and organizations to store and process large amounts of data. However, data leakage and network security issues have been plaguing enterprises and organizations, and the importance of encryption algorithms in data centers has become increasingly prominent. Compared with directly processing plaintext data, traditional encryption algorithms introduce additional encryption and decryption operations, which inevitably slow down data processing. Although the emerging homomorphic encryption algorithm can keep data in a secret state during the calculation process without the need for additional encryption and decryption operations, the scale of secret data is much larger than plaintext data, which also slows down data processing.

[0003] Therefore, in order to improve the data processing efficiency of data centers, how to accelerate the encryption algorithm (such as accelerating the encryption and decryption process, accelerating the processing speed of confidential data, etc.) has become an urgent problem to be solved. Summary of the invention

[0004] To solve the related technical problems, the embodiments of the present application provide an acceleration device, method, storage medium and computer program product.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] The embodiment of the present application provides an acceleration device, comprising: a first processor and a second processor; wherein:

[0007] The first processor is configured to send the instruction to be executed and the to-be-executed data associated with the instruction to be executed to the second processor when the instruction to be executed is associated with a modular operation of an encryption algorithm;

[0008] The second processor is used to receive the instructions to be executed and the data to be processed sent by the first processor, perform a modulo operation associated with the instructions to be executed based on the instructions to be executed and the data to be processed, obtain an operation result, and send the operation result to the first processor.

[0009] In the above scheme, the instruction to be executed is formed based on the instruction format of the fifth generation reduced instruction set (RISC-V), and the instruction to be executed includes one of the following:

[0010] A first instruction, the first instruction is used to perform a modular multiplication operation;

[0011] a second instruction, the second instruction being used to perform a modular reduction operation;

[0012] A third instruction, the third instruction is used to perform a modular addition operation;

[0013] A fourth instruction is used to perform a modular subtraction operation.

[0014] In the above scheme, the second processor includes a register group and a temporary register, the register group includes a plurality of registers; the data to be processed includes one or more source operands of the modulus operation associated with the instruction to be executed, and includes related moduli and / or related preprocessing numbers; wherein,

[0015] The first processor is further configured to send a fifth instruction, a sixth instruction, and a seventh instruction to the second processor, wherein the fifth instruction, the sixth instruction, and the seventh instruction are formed based on the RISC-V instruction format, the fifth instruction is configured to instruct the second processor to load the one or more source operands into the first target register corresponding to the instruction to be executed in the register group, the sixth instruction is configured to instruct the second processor to load the relevant modulus and / or relevant preprocessing number into the temporary register, and the seventh instruction is configured to instruct the second processing unit to store the operation result in the second target register corresponding to the instruction to be executed in the register group back into the third target register of the first processor;

[0016] The second processor is also used to receive the fifth instruction, the sixth instruction and the seventh instruction sent by the first processor, and based on the fifth instruction, the sixth instruction and the seventh instruction, load the one or more source operands into the first target register, load the relevant modulus and / or the relevant pre-processing number into the temporary register, and based on the one or more source operands and the relevant modulus and / or the relevant pre-processing number, perform the modulus operation associated with the instruction to be executed, obtain the operation result, store the operation result in the second target register, and store the operation result in the second target register back to the third target register.

[0017] In the above solution, the second processor further includes a first module, a second module and a third module; wherein,

[0018] The first module is used to receive the instruction to be executed, the fifth instruction, the sixth instruction and the seventh instruction, send first information to the second module, and send second information to the third module; the first information is used to schedule the second module to perform a modular operation associated with the instruction to be executed, and the second information is used to schedule the third module to execute the fifth instruction, the sixth instruction and the seventh instruction;

[0019] The second module is configured to receive the first information sent by the first module, read the one or more source operands from the first target register based on the first information, read the relevant modulus and / or relevant preprocessing number from the temporary register, perform the modulus operation associated with the instruction to be executed based on the one or more source operands and the relevant modulus and / or relevant preprocessing number, obtain the operation result, and store the operation result in the second target register; the temporary register is set in the second module;

[0020] The third module is used to receive the data to be processed and the second information sent by the first module, and based on the second information, load the one or more source operands into the first target register, load the relevant modulus and / or relevant preprocessing number into the temporary register, and store the operation result in the second target register back into the third target register.

[0021] In the above solution, the first module is also used for:

[0022] maintaining third information, wherein the third information represents an association relationship between an eighth instruction and registers in the register group, wherein the eighth instruction includes an instruction that has not been completely executed by the second processor;

[0023] In a case where the third information does not include the first target register and the second target register, the first information is sent to the second module, and the second information is sent to the third module.

[0024] In the above solution, the second processor is further used to determine fourth information and / or fifth information, and send the fourth information and / or fifth information to the first processor, the fourth information includes pipeline related information of the instruction to be executed, and the fifth information represents the execution status of the instruction to be executed;

[0025] The first processor is further configured to receive the fourth information and / or the fifth information sent by the second processor, and perform its own pipeline state management based on the fourth information and / or the fifth information.

[0026] The embodiment of the present application further provides an acceleration method, which is applied to a second processor in an acceleration device, comprising:

[0027] receiving an instruction to be executed and data to be processed associated with the instruction to be executed sent by a first processor in the acceleration device, wherein the instruction to be executed is associated with a modulus operation of an encryption algorithm;

[0028] Based on the to-be-executed instruction and the to-be-processed data, performing a modulo operation associated with the to-be-executed instruction to obtain an operation result;

[0029] Sending the operation result to the first processor.

[0030] In the above scheme, the instruction to be executed is formed based on the instruction format of RISC-V, and the instruction to be executed includes one of the following:

[0031] A first instruction, the first instruction is used to perform a modular multiplication operation;

[0032] a second instruction, the second instruction being used to perform a modular reduction operation;

[0033] A third instruction, the third instruction is used to perform a modular addition operation;

[0034] A fourth instruction is used to perform a modular subtraction operation.

[0035] In the above scheme, the second processor includes a register group and a temporary register, the register group includes a plurality of registers; the data to be processed includes one or more source operands of the modulo operation associated with the instruction to be executed, and includes related moduli and / or related preprocessing numbers; the performing the modulo operation associated with the instruction to be executed based on the instruction to be executed and the data to be processed includes:

[0036] Receive a fifth instruction, a sixth instruction, and a seventh instruction sent by the first processor, wherein the fifth instruction, the sixth instruction, and the seventh instruction are formed based on the RISC-V instruction format, the fifth instruction is used to instruct the second processor to load the one or more source operands into the first target register corresponding to the instruction to be executed in the register group, the sixth instruction is used to instruct the second processor to load the relevant modulus and / or relevant preprocessing number into the temporary register, and the seventh instruction is used to instruct the second processing unit to store the operation result in the second target register corresponding to the instruction to be executed in the register group back to the third target register of the first processor;

[0037] Based on the fifth instruction, the sixth instruction and the seventh instruction, the one or more source operands are loaded into the first target register, the relevant modulus and / or the relevant preprocessing number are loaded into the temporary register, and based on the one or more source operands, and the relevant modulus and / or the relevant preprocessing number, the modulus operation associated with the instruction to be executed is performed to obtain the operation result, the operation result is stored in the second target register, and the operation result in the second target register is stored back in the third target register.

[0038] In the above solution, performing the modulus operation associated with the instruction to be executed based on the one or more source operands, and the related modulus and / or the related preprocessing number includes:

[0039] The one or more source operands are read from the first target register, the relevant modulus and / or the relevant preprocessing number are read from the temporary register, and a modulus operation associated with the instruction to be executed is performed based on the one or more source operands and the relevant modulus and / or the relevant preprocessing number.

[0040] In the above scheme, the method further comprises:

[0041] maintaining third information, wherein the third information represents an association relationship between an eighth instruction and registers in the register group, wherein the eighth instruction includes an instruction that has not been completely executed by the second processor;

[0042] In a case where the third information does not include the first target register and the second target register, the one or more source operands are read from the first target register, the relevant modulus and / or relevant preprocessing number are read from the temporary register, and based on the one or more source operands, and the relevant modulus and / or relevant preprocessing number, a modulus operation associated with the instruction to be executed is performed.

[0043] In the above scheme, the method further comprises:

[0044] Determine fourth information and / or fifth information, and send the fourth information and / or fifth information to the first processor, so that the first processor can perform its own pipeline status management based on the fourth information and / or fifth information; the fourth information includes pipeline-related information of the instruction to be executed, and the fifth information represents the execution status of the instruction to be executed.

[0045] The embodiment of the present application further provides an acceleration method, which is applied to a third processor, comprising:

[0046] Perform a modular operation of the encryption algorithm by executing at least one of the following instructions:

[0047] a ninth instruction including a modulus, the ninth instruction being used to store the modulus into a fourth destination register;

[0048] a tenth instruction including a first source operand and a second source operand, the tenth instruction being configured to perform a modulo addition operation based on the first source operand and the second source operand and a modulus in a fourth destination register;

[0049] an eleventh instruction including a third source operand and a fourth source operand, the eleventh instruction being configured to perform a modular subtraction operation based on the third source operand and the fourth source operand and a modulus in a fourth destination register;

[0050] A twelfth instruction comprising a fifth source operand and a sixth source operand, the twelfth instruction being used to perform a modular multiplication operation based on the fifth source operand and the sixth source operand, and a modulus in a fourth target register.

[0051] An embodiment of the present application also provides a storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the computer program implements the steps of any of the methods on the second processor side described above, or implements the steps of any of the methods on the third processor side described above.

[0052] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned second processor side methods, or implements the steps of any of the above-mentioned third processor side methods.

[0053] The acceleration device, method, storage medium and computer program product provided by the embodiments of the present application, the acceleration device includes a first processor and a second processor; wherein the first processor is used to send the instruction to be executed and the data to be processed associated with the instruction to be executed to the second processor when the instruction to be executed is associated with the modular operation of the encryption algorithm; the second processor is used to receive the instruction to be executed and the data to be processed sent by the first processor, perform the modular operation associated with the instruction to be executed based on the instruction to be executed and the data to be processed, obtain the operation result, and send the operation result to the first processor. According to the solution provided by the embodiment of the present application, when a processor (i.e., the first processor) is running an encryption algorithm, when an instruction to be executed is associated with a modulo operation of the encryption algorithm, the processor sends the instruction to be executed and the corresponding data to be processed to another processor (such as a coprocessor, i.e., the second processor mentioned above) for execution, and obtains the operation result of the modulo operation associated with the instruction to be executed by the other processor. In this way, by enabling one processor to send the instruction to be executed associated with the modulo operation of the encryption algorithm to another processor for execution, the processor can be prevented from using conventional instructions to perform the modulo operation, thereby greatly reducing the number of instructions executed by the processor and operations related to factors such as data and / or control of the modulo operation, at least solving the problem of inefficiency of the processor in running a fast modulo algorithm, thereby achieving more efficient fast modulo operation and improving the execution speed of the data center encryption algorithm; in other words, the operating efficiency of the fast modulo operation can be improved, thereby achieving overall performance improvement when running the data center encryption algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 This is a schematic diagram of the structure of the acceleration device of the embodiment of the present application;

[0055] Figure 2A schematic diagram of the encoding format of the extended instructions (i.e., the first instruction, the second instruction, the third instruction, the fourth instruction, the fifth instruction, the sixth instruction, and the seventh instruction) in an embodiment of the present application;

[0056] Figure 3 This is a flow chart of the second processor-side acceleration method according to an embodiment of the present application;

[0057] Figure 4 This is a schematic diagram of the encoding format of an acceleration instruction (i.e., the ninth instruction) according to an embodiment of the present application;

[0058] Figure 5 This is a schematic diagram of the encoding format of another acceleration instruction (i.e., the tenth instruction) according to an embodiment of the present application;

[0059] Figure 6 This is a schematic diagram of the encoding format of the third acceleration instruction (i.e., the eleventh instruction) according to an embodiment of the present application;

[0060] Figure 7 This is a schematic diagram of the encoding format of the fourth acceleration instruction (i.e., the twelfth instruction) according to an embodiment of the present application;

[0061] Figure 8 This is a schematic diagram of the overall architecture of the acceleration device used in this application example;

[0062] Fig. 9 This is a schematic diagram of the architecture of the analog multiplication unit used in this application;

[0063] Fig.10 This is a schematic diagram of the modular reduction unit architecture for the application example of this application;

[0064] Fig.11 This is a schematic diagram of the architecture of an analog add / subtract unit for the application example;

[0065] Fig.12 A schematic diagram of the acceleration process of the data center encryption algorithm used in this application example. DETAILED DESCRIPTION

[0066] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0067] Modular reduction is the core operation of many encryption algorithms, such as asymmetric encryption algorithms based on Diffie-Hellman key exchange (i.e. ElGamal), RSA (Rivest-Shamir-Adleman), BGV (Brakerski-Gentry-Vaikuntanathan), and CKKS (Cheon-Kim-Kim-Song) and other typical encryption algorithms. Modular reduction is also one of the slowest operations. In practical applications, there are cases where modular reduction is used alone, and there are also cases where modular reduction and multiplication, addition, and subtraction operations are combined to form modular multiplication, modular addition, and modular subtraction operations. In related technologies, modular reduction operations can be completed by software in a processor (such as a central processing unit (CPU, Central Process Unit), etc.), and specific implementation methods at the instruction level may include the following two:

[0068] Method 1, simple implementation method; that is, implementing independent multiplication, addition, subtraction, and modular reduction instructions, completing modular multiplication, modular addition, and modular reduction operations by first multiplying, adding, subtracting, and then modular reduction;

[0069] Method 2, fast modular algorithm method; that is, through a specific algorithm, instead of directly using modular reduction operations, modular multiplication, modular addition, modular subtraction and modular reduction operations are formed through a combination of multiplication, addition, subtraction, and shift operations.

[0070] Among them, for the above method 1, the naive implementation method actually uses the modular reduction operation, and the execution time of the modular reduction operation is about 1.5 to 5 times that of the multiplication operation, and 6 to 20 times that of the addition and subtraction operations, and the operation speed is low. For the above method 2, although the fast modular algorithm method does not use the modular reduction operation, the operation speed is greatly improved compared with the naive implementation method; however, the existing RISC-V instruction set has data correlation, control correlation, and inefficient shifting methods when implementing the fast modular algorithm, which makes the fast modular operation (i.e., the fast modular algorithm) still have a lot of room for improvement.

[0071] From the above description, it can be seen that there is no effective solution in the related technology on how to effectively accelerate the encryption algorithm.

[0072] Based on this, in various embodiments of the present application, when a processor is running an encryption algorithm, when an instruction to be executed is associated with a modular operation of the encryption algorithm, the processor sends the instruction to be executed and the corresponding data to be processed to another processor (such as a coprocessor, etc.) for execution, and obtains the operation result of the modular operation associated with the instruction to be executed by the other processor. In this way, by enabling a processor to send the instruction to be executed associated with the modular operation of the encryption algorithm to another processor for execution, the processor can be prevented from using conventional instructions to perform modular operations, thereby greatly reducing the number of instructions executed by the processor and operations related to factors such as data and / or control of modular operations, at least solving the problem of inefficiency of the processor in running a fast modular algorithm, thereby achieving more efficient fast modular operations and improving the execution speed of the data center encryption algorithm; in other words, the operating efficiency of the fast modular operations can be improved, thereby achieving overall performance improvement when running the data center encryption algorithm.

[0073] Specifically, the embodiment of the present application provides an acceleration device, such as Figure 1 As shown, the acceleration device 100 includes: a first processor 110 and a second processor 120; wherein,

[0074] The first processor 110 is configured to send the instruction to be executed and the to-be-executed data associated with the instruction to be executed to the second processor 120 when the instruction to be executed is associated with a modular operation of an encryption algorithm;

[0075] The second processor 120 is used to receive the instructions to be executed and the data to be processed sent by the first processor 110, perform a modulo operation associated with the instructions to be executed based on the instructions to be executed and the data to be processed, obtain an operation result, and send the operation result to the first processor 110.

[0076] In actual application, the specific types of the first processor 110 and the second processor 120 can be determined according to requirements (such as data center deployment requirements, encryption algorithm requirements, etc.), and the embodiments of the present application do not limit this. Exemplarily, the first processor 110 may include a RISC-V processor, and the second processor 120 may include a coprocessor. In this case, the coprocessor may also be called a RISC-V fast modular arithmetic coprocessor, etc.

[0077] In actual application, the first processor 110 may include a processing and execution unit for conventional instructions that are not related to the modular operation of the encryption algorithm, and a decoding and dispatching logic, a committing logic, and a write-back logic for instructions associated with the modular operation of the encryption algorithm (which may also be referred to as fast modular operation extension instructions in the subsequent description). When the operation of the conventional instructions is involved, that is, when the instructions to be executed are not related to the modular operation of the encryption algorithm, the first processor 110 can complete the decoding, execution, and write-back operations of the instructions to be executed internally, that is, the first processor 110 can execute the instructions to be executed by itself. When the operation of the fast modular operation extension instructions is involved, that is, when the instructions to be executed are associated with the modular operation of the encryption algorithm, the decoding and dispatching logic in the first processor 110 can transfer the instructions to be executed and the related data to be processed to the second processor 120, and the second processor 120 completes the corresponding operation; and the committing logic in the first processor 110 can wait for and receive the operation result from the second processor 120, and the write-back logic in the first processor 110 can write the operation result into the destination register (which may be recorded as the third target register in the subsequent description).

[0078] In actual application, the instruction to be executed can be a separately designed RISC-V extended instruction that can quickly complete modular multiplication, modular addition, modular subtraction or modular reduction operations, thereby avoiding problems such as data dependency, control dependency and general operation inefficiency caused by implementing fast modular operations through multiple instructions.

[0079] Based on this, in one embodiment, the instruction to be executed may be formed based on the instruction format of RISC-V, and the instruction to be executed may include one of the following:

[0080] A first instruction, the first instruction is used to perform a modular multiplication operation;

[0081] a second instruction, the second instruction being used to perform a modular reduction operation;

[0082] A third instruction, the third instruction is used to perform a modular addition operation;

[0083] A fourth instruction is used to perform a modular subtraction operation.

[0084] In practical application, considering that the execution of modular multiplication, modular addition, modular subtraction, and modular reduction operations requires the input of one or more source operands, as well as related moduli and / or related preprocessing numbers, and considering that the second processor 120 needs to return the operation result to the first processor 110, the first processor 110 may also send to the second processor 120 an instruction for instructing the second processor 120 to load one or more source operands into a specific register (which may be recorded as the fifth instruction in the subsequent description), an instruction for instructing the second processor 120 to load related moduli and / or related preprocessing numbers into a specific temporary register (which may be recorded as the sixth instruction in the subsequent description), and an instruction for instructing the second processing unit to store the operation result of the instruction to be executed in the specific register back to the first processor 110 (which may be recorded as the seventh instruction in the subsequent description) at the same time, before, or after sending the instruction to be executed to the second processor 120.

[0085] Based on this, in one embodiment, if Figure 1 As shown, the second processor 120 may include a register group 121 and a temporary register 122, wherein the register group 121 includes a plurality of registers; the data to be processed may include one or more source operands of a modulus operation associated with the instruction to be executed, and may include related moduli and / or related preprocessing numbers; wherein,

[0086] The first processor 110 may also be used to send a fifth instruction, a sixth instruction and a seventh instruction to the second processor 120, wherein the fifth instruction, the sixth instruction and the seventh instruction are formed based on the instruction format of RISC-V, the fifth instruction is used to instruct the second processor 120 to load the one or more source operands into the first target register corresponding to the instruction to be executed in the register group 121, the sixth instruction is used to instruct the second processor 120 to load the relevant modulus and / or relevant pre-processing number into the temporary register 122, and the seventh instruction is used to instruct the second processing unit to store the operation result of the instruction to be executed in the second target register corresponding to the register group 121 back to the third target register of the first processor 110;

[0087] The second processor 120 can also be used to receive the fifth instruction, the sixth instruction and the seventh instruction sent by the first processor 110, and based on the fifth instruction, the sixth instruction and the seventh instruction, load the one or more source operands into the first target register, load the relevant modulus and / or the relevant pre-processing number into the temporary register 122, and based on the one or more source operands and the relevant modulus and / or the relevant pre-processing number, perform the modulus operation associated with the instruction to be executed, obtain the operation result, store the operation result in the second target register, and store the operation result in the second target register back to the third target register.

[0088] Among them, in actual application, each fast modulus arithmetic extension instruction (i.e., the first instruction, the second instruction, the third instruction, and the fourth instruction) can be associated with one or more registers in the multiple registers included in the register group 121, and a fast modulus arithmetic extension instruction can be associated with the same or different registers as another fast modulus arithmetic extension instruction. When two fast modulus arithmetic extension instructions are associated with one or more identical registers, it means that the two fast modulus arithmetic extension instructions are data-dependent, that is, the operation of one fast modulus arithmetic extension instruction depends on the operation result and / or source operand of another fast modulus arithmetic extension instruction. In addition, it can be understood that the first target register and the second target register can be the same or different, which can be determined specifically according to requirements (such as data center deployment requirements, encryption algorithm requirements, etc.), and the embodiments of the present application are not limited to this.

[0089] In actual application, the above-mentioned RISC-V extended instructions (i.e., the first instruction, the second instruction, the third instruction, the fourth instruction, the fifth instruction, the sixth instruction, and the seventh instruction) can form a new RISC-V extended instruction set (also referred to as an extended instruction group). The specific encoding definition method of the extended instruction set and the specific encoding format of each extended instruction can be determined according to the requirements (such as data center deployment requirements, encryption algorithm requirements, etc.), and the embodiments of the present application do not limit this. Exemplarily, the extended instruction set can be implemented using the custom extended instruction group marked as Custom 3 (Custom3) in the RISC-V instruction extension proposal, and the funct3 and funct7 domains (i.e., fields) therein are further encoded and defined; and the operation code (expressed as opcode in English) of the extended instruction set can be 1111011, and the specific encoding format of each extended instruction in the extended instruction set (i.e., the first instruction, the second instruction, the third instruction, the fourth instruction, the fifth instruction, the sixth instruction, and the seventh instruction) can be as follows Figure 2 As shown. Figure 2It can be seen that the 14th to 12th bits in each extended instruction can be collectively referred to as the funct3 domain. The three bits in the funct3 domain are vld_d, vld_s1 and vld_s2 from high to low. vld_d indicates whether the current instruction needs to be written back to the destination register (i.e., the third target register), vld_s1 indicates whether the first source operand of the current instruction is valid, and vld_s2 indicates whether the second source operand of the current instruction is valid. It can be understood that vld_s1 and vld_s2 can reflect that the inline assembly function of the current instruction contains several parameters. In addition, vld_d, vld_s1 and vld_s2 can all be high-valid bits. The 31st to 25th bits in each extended instruction can be collectively referred to as the funct7 domain. The 28th to 25th bits in the funct7 domain can be used as instruction identification (such as ID, etc.) encoding, and the 31st to 29th bits can be temporarily set as invalid bits to reserve space for subsequent related extensions.

[0090] In practical application, based on Figure 2The encoding format shown, the specific encoding of the above RISC-V extended instructions (i.e., the first instruction, the second instruction, the third instruction, the fourth instruction, the fifth instruction, the sixth instruction, and the seventh instruction) can be shown in Table 1. Among them, the function of CO_LOAD (i.e., the fifth instruction) is to load one or more source operands into the dedicated register group (i.e., the register group 121); the function of CO_STORE (i.e., the seventh instruction) is to store the data in the dedicated register group (i.e., the operation result) back to the RISC-V processor (i.e., the first processor 110); for both CO_LOAD and CO_STORE instructions, only rs1 and rd are valid, rs1 can indicate the number of the source register in the RISC-V register stack (i.e., the register stack of the first processor 110) or the number of the coprocessor dedicated register group (i.e., the register group 121), and the data stored in rs2 can represent the offset of the memory address. The function of CO_LOAD_SPEC (i.e., the sixth instruction) is to load the modulus and / or preprocessing number into the register (i.e., the register 122) of the execution unit (also referred to as the operation execution module, which may be recorded as the second module 124 in the subsequent description). The rs1 in CO_LOAD_SPEC may indicate the number of the modulus in the RISC-V register stack, and the rs2 may indicate the number of the preprocessing number in the RISC-V register stack. When vld_s1 is at a high level, it may indicate the loading of the modulus, and when vld_s2 is at a high level, it may indicate the loading of the preprocessing number. The four instructions CO_MUL (i.e. the first instruction), CO_MM (i.e. the second instruction), CO_ADD (i.e. the third instruction), and CO_MI (i.e. the fourth instruction) are dedicated instructions for modular operations. Except for the modular reduction instruction (i.e. CO_MM) which only requires a source operand other than a modulus and a preprocessed number, the other three instructions (i.e. CO_MUL, CO_ADD, CO_MI) all require two additional source operands; these four instructions all need to be written back to a dedicated destination register (i.e. the third target register).

[0091] Table 1

[0092]

[0093]

[0094] In actual application, the second processor 120 may be divided into functional modules according to different operations to be performed.

[0095] Based on this, in one embodiment, if Figure 1 As shown, the second processor 120 may also include a first module 123, a second module 124 and a third module 125; wherein,

[0096] The first module 123 is used to receive the instruction to be executed, the fifth instruction, the sixth instruction and the seventh instruction, send first information to the second module 124, and send second information to the third module 125; the first information is used to schedule the second module 124 to perform the modulo operation associated with the instruction to be executed, and the second information is used to schedule the third module 125 to execute the fifth instruction, the sixth instruction and the seventh instruction;

[0097] The second module 124 is configured to receive the first information sent by the first module 123, read the one or more source operands from the first target register based on the first information, read the relevant modulus and / or relevant pre-processing number from the temporary register 122, perform the modulus operation associated with the instruction to be executed based on the one or more source operands and the relevant modulus and / or relevant pre-processing number, obtain the operation result, and store the operation result in the second target register; the temporary register 122 is set in the second module 124;

[0098] The third module 125 is used to receive the data to be processed and the second information sent by the first module 123, and based on the second information, load the one or more source operands into the first target register, load the relevant modulus and / or relevant preprocessing number into the temporary register 122, and store the operation result in the second target register back into the third target register.

[0099] Among them, in actual application, the first information is used to schedule the second module 124 to perform the modular operation associated with the instruction to be executed, which means that the first information is used to schedule the second module 124 to read the one or more source operands from the first target register, read the relevant modulus and / or relevant pre-processing number from the temporary register 122, and perform the modular operation associated with the instruction to be executed based on the one or more source operands and the relevant modulus and / or relevant pre-processing number, obtain the operation result, and store the operation result in the second target register. In addition, the first information can specifically include the operation type, the modular operation type, the identifier of the first target register, the operation code, etc., and these information can be obtained by the first module 123 decoding the instruction to be executed.

[0100] In actual application, the second information is used to schedule the third module 125 to execute the fifth instruction, the sixth instruction and the seventh instruction, which means that the second information is used to schedule the third module 125 to load the one or more source operands into the first target register, load the relevant modulus and / or the relevant pre-processing number into the temporary register 122, and store the operation result in the second target register back into the third target register. In addition, the second information can specifically include the operation type, the identifier of the first target register, the identifier of the third target register, etc., and these information can be obtained by the first module 123 decoding the fifth instruction, the sixth instruction and the seventh instruction.

[0101] In actual application, in order to ensure the correctness of the operation execution result, the first module 123 needs to schedule the second module 124 to execute the modular operation associated with the instruction to be executed according to the data related situation.

[0102] Based on this, in one embodiment, the first module 123 may also be used for:

[0103] Maintaining third information, wherein the third information represents an association relationship between an eighth instruction and registers in the register group 121, wherein the eighth instruction includes an instruction that has not been completely executed by the second processor 120;

[0104] In a case where the third information does not include the first target register and the second target register, the first information is sent to the second module 124 , and the second information is sent to the third module 125 .

[0105] Among them, in actual application, it can be seen from the above description that for the fast modulus arithmetic extension instructions (that is, the first instruction, the second instruction, the third instruction, and the fourth instruction), when two fast modulus arithmetic extension instructions are associated with one or more identical registers, it means that the two fast modulus arithmetic extension instructions are data-dependent, that is, the operation of one fast modulus arithmetic extension instruction depends on the operation result and / or source operand of another fast modulus arithmetic extension instruction; if these two instructions are non-pipelined instructions, it is necessary to execute the fast modulus arithmetic extension instruction after the other fast modulus arithmetic extension instruction is executed to ensure the correctness of the operation execution result.

[0106] In one embodiment, the second processor 120 may also be used to determine fourth information and / or fifth information, and send the fourth information and / or fifth information to the first processor 110, wherein the fourth information includes pipeline-related information of the instruction to be executed, and the fifth information represents an execution state of the instruction to be executed;

[0107] The first processor 110 may also be configured to receive the fourth information and / or the fifth information sent by the second processor 120, and perform its own pipeline state management based on the fourth information and / or the fifth information.

[0108] Specifically, in actual application, the first module 123 may send the fourth information and / or the fifth information to the first processor 110 in real time. The fourth information may include the number of instruction execution beats of the instruction to be executed (i.e., the number of clock cycles required for instruction execution), whether pipeline execution is required, and other contents; when the first processor 110 performs its own pipeline state management according to the fourth information, it may determine whether to block its own in-core pipeline according to the number of instruction execution beats of the instruction to be executed, whether pipeline execution is required, and other information.

[0109] In actual application, the execution status of the to-be-executed instruction may include at least one of the following:

[0110] State 1, submission state; this state can indicate whether the instruction to be executed has been returned to the first processor 110 to complete submission, and this state is the last stage of the life cycle of the instruction to be executed;

[0111] State 2, internal execution state; since the interaction between the second processor 120 and the first processor 110 takes time, the second processor 120 may maintain the execution state of the instruction to be executed internally. In the case where the instruction to be executed is a non-pipelined instruction, if the work of the instruction to be executed in the second processor 120 has been completed, the second processor 120 may schedule subsequent instructions to start working;

[0112] State 3, operand state; this state can be used for data-related judgments. For example, assuming that the instruction to be executed requires the source operands and / or calculation results of the preceding instruction, then in order to maximize performance, if the instruction to be executed is a pipelined instruction that does not require blocking, the instruction to be executed can start executing when the required operands are in place. Therefore, the current operand state can be maintained for each instruction for the call of subsequent instructions.

[0113] In actual application, according to the different operations that need to be performed, the first module 123, the second module 124, and the third module 125 can be further divided into functional units. The specific division method can be determined in combination with the needs (such as data center deployment requirements, encryption algorithm requirements, etc.), and the embodiments of the present application are not limited to this.

[0114] In practical application, in various embodiments of the present application, the operations performed by the first processor 110 and the second processor 120 can be implemented by a computer program (i.e., a software program), and the computer program can be stored in a memory, and the memory can be set inside or outside the acceleration device 100. The memory can specifically store various types of data to support the operations of the first processor 110 and the second processor 120. It can be understood that the memory can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache.By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), direct memory bus random access memory (DRRAM). The memory described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memory.

[0115] Accordingly, the embodiment of the present application further provides an acceleration method, which is applied to the second processor (ie, the second processor 120) in the acceleration device, such as Figure 3 As shown, the method may include:

[0116] Step 301: receiving an instruction to be executed and data to be processed associated with the instruction to be executed sent by a first processor in the acceleration device, wherein the instruction to be executed is associated with a modulo operation of an encryption algorithm;

[0117] Step 302: Based on the instruction to be executed and the data to be processed, perform a modulo operation associated with the instruction to be executed to obtain an operation result;

[0118] Step 303: Send the calculation result to the first processor.

[0119] The instruction to be executed is formed based on the RISC-V instruction format, and the instruction to be executed may include one of the following:

[0120] A first instruction, the first instruction is used to perform a modular multiplication operation;

[0121] a second instruction, the second instruction being used to perform a modular reduction operation;

[0122] A third instruction, the third instruction is used to perform a modular addition operation;

[0123] A fourth instruction is used to perform a modular subtraction operation.

[0124] In one embodiment, the second processor may include a register group and a temporary register, the register group includes a plurality of registers; the data to be processed may include one or more source operands of a modulo operation associated with the instruction to be executed, and include a related modulus and / or a related preprocessing number; performing the modulo operation associated with the instruction to be executed based on the instruction to be executed and the data to be processed may include:

[0125] Receive a fifth instruction, a sixth instruction, and a seventh instruction sent by the first processor, wherein the fifth instruction, the sixth instruction, and the seventh instruction are formed based on the RISC-V instruction format, the fifth instruction is used to instruct the second processor to load the one or more source operands into the first target register corresponding to the instruction to be executed in the register group, the sixth instruction is used to instruct the second processor to load the relevant modulus and / or relevant preprocessing number into the temporary register, and the seventh instruction is used to instruct the second processing unit to store the operation result in the second target register corresponding to the instruction to be executed in the register group back to the third target register of the first processor;

[0126] Based on the fifth instruction, the sixth instruction and the seventh instruction, the one or more source operands are loaded into the first target register, the relevant modulus and / or the relevant pre-processing number are loaded into the temporary register, and based on the one or more source operands, and the relevant modulus and / or the relevant pre-processing number, the modulus operation associated with the instruction to be executed is performed to obtain the operation result, the operation result is stored in the second target register, and the operation result in the second target register is stored back in the third target register (i.e., the operation result is sent to the first processor).

[0127] In one embodiment, performing the modulo operation associated with the instruction to be executed based on the one or more source operands and the related modulus and / or the related preprocessing number may include:

[0128] The one or more source operands are read from the first target register, the relevant modulus and / or the relevant preprocessing number are read from the temporary register, and a modulus operation associated with the instruction to be executed is performed based on the one or more source operands and the relevant modulus and / or the relevant preprocessing number.

[0129] In one embodiment, the method may further include:

[0130] maintaining third information, wherein the third information represents an association relationship between an eighth instruction and registers in the register group, wherein the eighth instruction includes an instruction that has not been completely executed by the second processor;

[0131] Accordingly, the reading of the one or more source operands from the first target register, the reading of the relevant modulus and / or the relevant preprocessing number from the temporary register, and the performing of the modulus operation associated with the instruction to be executed based on the one or more source operands and the relevant modulus and / or the relevant preprocessing number may include:

[0132] In a case where the third information does not include the first target register and the second target register, the one or more source operands are read from the first target register, the relevant modulus and / or relevant preprocessing number are read from the temporary register, and based on the one or more source operands, and the relevant modulus and / or relevant preprocessing number, a modulus operation associated with the instruction to be executed is performed.

[0133] In one embodiment, the method may further include:

[0134] Determine fourth information and / or fifth information, and send the fourth information and / or fifth information to the first processor, so that the first processor can perform its own pipeline status management based on the fourth information and / or fifth information; the fourth information includes pipeline-related information of the instruction to be executed, and the fifth information represents the execution status of the instruction to be executed.

[0135] The embodiment of the present application further provides an acceleration method, which is applied to a third processor, including:

[0136] Perform a modular operation of the encryption algorithm by executing at least one of the following instructions:

[0137] a ninth instruction including a modulus, the ninth instruction being used to store the modulus into a fourth destination register;

[0138] a tenth instruction including a first source operand and a second source operand, the tenth instruction being configured to perform a modulo addition operation based on the first source operand and the second source operand and a modulus in a fourth destination register;

[0139] an eleventh instruction including a third source operand and a fourth source operand, the eleventh instruction being configured to perform a modular subtraction operation based on the third source operand and the fourth source operand and a modulus in a fourth destination register;

[0140] A twelfth instruction comprising a fifth source operand and a sixth source operand, the twelfth instruction being used to perform a modular multiplication operation based on the fifth source operand and the sixth source operand, and a modulus in a fourth target register.

[0141] Wherein, in actual application, the third processor may include the first processor in the acceleration device (i.e., the first processor 110). Specifically, the first processor may use a preset specific condition to determine the size of the amount of operation of the encryption algorithm to be accelerated. When the amount of operation of the encryption algorithm to be accelerated is not large, such as when the amount of operation of the encryption algorithm to be accelerated is less than a specific threshold, the first processor may accelerate the encryption algorithm by executing the acceleration instruction (i.e., at least one of the ninth instruction, the tenth instruction, the eleventh instruction, and the twelfth instruction), without interacting with the second processor in the acceleration device (i.e., the second processor 120), thereby reducing the interaction overhead between the first processor and the second processor. Accordingly, when the amount of operation of the encryption algorithm to be accelerated is large, such as when the amount of operation of the encryption algorithm to be accelerated is greater than or equal to a specific threshold, the first processor may send the instruction to be executed and the data to be processed associated with the instruction to be executed to the second processor, and the second processor performs the modulus operation associated with the instruction to be executed based on the instruction to be executed and the data to be processed, obtains the operation result, and sends the operation result to the first processor.

[0142] In actual application, the third processor may also include other processors in addition to the first processor and the second processor, that is, the above-mentioned acceleration device is not required. By directly adding acceleration instructions of the encryption algorithm (that is, at least one of the ninth instruction, the tenth instruction, the eleventh instruction, and the twelfth instruction) in a specific processor (that is, the third processor), the processor can directly accelerate the encryption algorithm, thereby directly realizing more efficient fast modular operations without installing a coprocessor.

[0143] In actual application, the encoding format of the ninth instruction can be as follows: Figure 4As shown, the register rs1 may contain the modulus, that is, the ninth instruction may be used to store the modulus in the register rs1 into the fourth target register. Here, it can be understood that after the third processor executes the ninth instruction once, before executing the ninth instruction again, the number set by the instruction is used as the modulus (that is, the modulus in the fourth target register) to perform the modulus operation; in other words, before executing at least one of the tenth instruction, the eleventh instruction, and the twelfth instruction, the ninth instruction needs to be executed first to set the modulus, and at least one of the tenth instruction, the eleventh instruction, and the twelfth instruction executed after the ninth instruction is executed will perform the modulus operation according to the modulus set by the ninth instruction (that is, the modulus in the fourth target register); for this group of acceleration instructions (that is, the ninth instruction, the tenth instruction, the eleventh instruction, and the twelfth instruction), the modulus can be set multiple times, that is, the ninth instruction can be executed multiple times, and the effective range of the modulus set by the ninth instruction (that is, the modulus in the fourth target register) is used each time before the next execution of the ninth instruction to set the new modulus.

[0144] In actual application, it can be understood that in order to meet the requirements of the modulus operation, the modulus set by the ninth instruction (that is, the modulus in the fourth target register) must be a prime number, and the source operands (that is, the first source operand, the second source operand, the third source operand, the fourth source operand, the fifth source operand, and the sixth source operand) must be smaller than the modulus set by the ninth instruction.

[0145] In actual application, the encoding format of the tenth instruction can be as follows: Figure 5 As shown, registers rs1 and rs2 can store the first source operand and the second source operand respectively, and the tenth instruction can be used to first calculate the result of rs1 plus rs2 (that is, calculate the result of the first source operand plus the second source operand), and then take the result modulo the modulus in the fourth target register, and fill the modulo result into register rd; in other words, executing the tenth instruction is equivalent to completing rd=(rs1+rs2)mod q, wherein mod represents the modulo operation, and q represents the modulus in the fourth target register.

[0146] In actual application, the encoding format of the eleventh instruction can be as follows: Figure 6As shown, registers rs1 and rs2 can store the third source operand and the fourth source operand respectively, and the eleventh instruction can be used to first calculate the result of rs1 minus rs2 (that is, calculate the result of the third source operand minus the fourth source operand), then take the result modulo the modulus in the fourth target register, and fill the modulo result into register rd; in other words, executing the eleventh instruction is equivalent to completing rd=(rs1-rs2)mod q, wherein mod represents the modulo operation, and q represents the modulus in the fourth target register.

[0147] In actual application, the encoding format of the twelfth instruction can be as follows: Figure 7 As shown, registers rs1 and rs2 can store the fifth source operand and the sixth source operand respectively, and the twelfth instruction can be used to first calculate the result of rs1 multiplied by rs2 (that is, calculate the result of the fifth source operand multiplied by the sixth source operand), and then take the result modulo the modulus in the fourth target register, and fill the modulo result into register rd; in other words, executing the twelfth instruction is equivalent to completing rd=(rs1×rs2)mod q, where mod represents the modulo operation and q represents the modulus in the fourth target register.

[0148] The acceleration device and method provided in the embodiments of the present application include a first processor and a second processor; wherein the first processor is used to send the instruction to be executed and the data to be processed associated with the instruction to be executed to the second processor when the instruction to be executed is associated with the modular operation of the encryption algorithm; the second processor is used to receive the instruction to be executed and the data to be processed sent by the first processor, perform the modular operation associated with the instruction to be executed based on the instruction to be executed and the data to be processed, obtain the operation result, and send the operation result to the first processor. According to the solution provided by the embodiment of the present application, when a processor (i.e., the first processor) is running an encryption algorithm, when an instruction to be executed is associated with a modulo operation of the encryption algorithm, the processor sends the instruction to be executed and the corresponding data to be processed to another processor (such as a coprocessor, i.e., the second processor mentioned above) for execution, and obtains the operation result of the modulo operation associated with the instruction to be executed by the other processor. In this way, by enabling one processor to send the instruction to be executed associated with the modulo operation of the encryption algorithm to another processor for execution, the processor can be prevented from using conventional instructions to perform the modulo operation, thereby greatly reducing the number of instructions executed by the processor and operations related to factors such as data and / or control of the modulo operation, at least solving the problem of inefficiency of the processor in running a fast modulo algorithm, thereby achieving more efficient fast modulo operation and improving the execution speed of the data center encryption algorithm; in other words, the operating efficiency of the fast modulo operation can be improved, thereby achieving overall performance improvement when running the data center encryption algorithm.

[0149] In addition, the solution provided by the embodiment of the present application, when the amount of operation of the encryption algorithm to be accelerated is not large, for example, when the amount of operation of the encryption algorithm to be accelerated is less than a specific threshold, the first processor can accelerate the encryption algorithm by executing the acceleration instruction (i.e., at least one of the ninth instruction, the tenth instruction, the eleventh instruction, and the twelfth instruction) without interacting with the second processor, thereby reducing the interaction overhead between the first processor and the second processor. Alternatively, by directly adding an acceleration instruction of the encryption algorithm (i.e., at least one of the ninth instruction, the tenth instruction, the eleventh instruction, and the twelfth instruction) in a specific processor (i.e., the third processor), the processor can directly accelerate the encryption algorithm, thereby directly realizing more efficient fast modular operations without installing a coprocessor.

[0150] The present application is described in further detail below in conjunction with application examples.

[0151] In this application example, the first processor includes a RISC-V processor, and the second processor includes a RISC-V fast modular arithmetic coprocessor, referred to as a coprocessor for short.

[0152] In this application example, in order to at least solve the inefficiency problem that still exists in the processor (such as CPU, etc.) when running the fast modulo algorithm, achieve more efficient fast modulo operations, and improve the execution speed of the data center encryption algorithm, a method and device for accelerating the data center encryption algorithm based on RISC-V instruction extension are proposed to accelerate the modulo operations that cannot be run at high speed using only the existing RISC-V instruction set, thereby solving the problem of low efficiency of the data center encryption algorithm.

[0153] The acceleration method proposed in this application example designs separate instructions to complete fast modular multiplication, modular addition, modular subtraction, and modular reduction operations, that is, the first instruction, the second instruction, the third instruction, and the fourth instruction are designed to avoid data correlation, control correlation, and general operation inefficiency caused by multiple instruction implementation methods. These instructions can be called fast modular operation instructions. This application example also proposes an acceleration device for implementing the above acceleration method, such as Figure 8 As shown, it includes a RISC-V processor (i.e., the first processor mentioned above) and a RISC-V fast modular arithmetic coprocessor (referred to as the coprocessor in the subsequent description, i.e., the second processor mentioned above). In combination with the coprocessor, the RISC-V processor can effectively support the acceleration method proposed in this application example. Specifically, the RISC-V processor can include a processing execution unit for conventional RISC-V instructions and a decoding and dispatching logic for fast modular arithmetic extension instructions. When it comes to conventional instruction operations, the RISC-V processor can complete the decoding, execution, and write-back operations of the instructions by itself. When it comes to fast modular operation extension instructions, the decoding logic in the RISC-V processor will transmit the instruction and related data to be processed (such as source operands, and related moduli and / or related pre-processing numbers) to the coprocessor after parsing the instruction (i.e., identifying that the instruction is an extended instruction, i.e., determining that the instruction to be executed is associated with the modular operation of the encryption algorithm), and the coprocessor will complete the specified operation; and the submission logic of the RISC-V processor will wait for and receive the operation result from the coprocessor, and the write-back logic will write the processing result (i.e., the operation result) to the destination register (i.e., the third target register mentioned above).

[0154] In this application example, Figure 8As shown, the coprocessor may include an instruction scheduling module (i.e., the first module mentioned above), an operation execution module (i.e., the second module mentioned above), a dedicated load / store module (i.e., the third module mentioned above), and a dedicated register group (i.e., the register group mentioned above). The instruction scheduling module may further decode the extended instruction according to the instruction execution state of the current coprocessor, parse out the operation type, specific operation, dedicated register number (such as the identification of the first target register and the second target register mentioned above), generate valid signals, operation codes, and other information, and distribute the relevant information to related modules for subsequent processing (i.e., sending the first information to the second module mentioned above, and sending the second information to the third module mentioned above). Among them, the instruction scheduling module can further decode the extended instruction according to the instruction execution status of the current coprocessor, which means that in order to ensure the correctness of the execution result, it is necessary to affect the decoding process according to data correlation and whether the instruction is pipelined; for example, if the preceding instruction is a non-pipelined instruction, then the decoding of the subsequent instruction cannot start until this instruction is executed; for example, if the preceding instruction and the instruction being decoded have data correlation, the decoding process can start, but after the data correlation is found, it is necessary to wait for the source operand and / or operation result of the preceding instruction to be in place before the decoding information can be distributed to the relevant modules.

[0155] The operation execution module can include multiple different modular operation units for completing specific computing tasks; the operation execution module can first read the source operand from the dedicated register group according to the dedicated register number provided by the instruction scheduling module (such as the identifier of the first target register and the second target register mentioned above), and then schedule the corresponding modular operation unit to perform the corresponding modular operation according to the operation code and other information, and finally store the operation result back to the dedicated register group. The role of the dedicated register group in the coprocessor is similar to that of the register file in the CPU. It can be used to retain information such as operands and operation results. It is the data interface between the operation execution module and the dedicated load / store module. The dedicated load / store module is the interface for the entire coprocessor to interact with the RISC-V processor for data; the loading unit inside the dedicated load / store module can receive the source operand from the RISC-V processor and provide data for the dedicated register group according to the information in the extended instruction; the storage unit can retrieve the operation result from the dedicated register group and send it back to the RISC-V processor.

[0156] From the above description, it can be seen that in this application example, the four modules included in the coprocessor (i.e., instruction scheduling module, operation execution module, dedicated load / store module and dedicated register group) form a complete data path and a complete interaction mechanism with the RISC-V processor, which can execute fast modular operation extension instructions without destroying the original execution mode of the RISC-V processor, thereby achieving the effect of improving the operating performance.

[0157] In this application example, Figure 8 As shown, the instruction scheduling module may include a decoding unit, a dispatching unit and a pipeline management unit. Among them, the decoding unit can receive extended instructions from the RISC-V processor and parse out information such as operation type, specific operation, and special register number. The dispatch unit can manage the instruction execution status of the entire coprocessor, and can be specifically used to decide whether to issue the next instruction; here, since the coprocessor only accelerates operations and does not include branch operations, the dispatch unit can decide whether to issue the next instruction based on data correlation; specifically, a table of historical instruction register numbers (i.e., the third information mentioned above) can be managed in the dispatch unit, and in the process of each instruction being dispatched to write back, the table can save the special register number information of the instruction, and the table entry is released after the instruction write back is completed; before the subsequent instruction is issued, if the dispatch unit queries that the special register number of the instruction is the same as any table entry in the table, it indicates that there is data correlation (data correlation means that an instruction may depend on the calculation result and / or source operand of the previous instruction, which can be judged by whether the special register numbers of the two instructions are equal), at this time, the dispatch unit can block the issuance of the instruction until there is a data-related instruction write back and the conflicting table entry is released; in this way, through the design of the dispatch unit, the correctness of the coprocessor execution result can be ensured. The pipeline management unit can be responsible for the communication of status information between the coprocessor and the RISC-V processor. For example, the unit can derive the instruction execution count (i.e., the clock cycle required for instruction execution), whether the instruction is pipelined, and other information based on the operation information and status information provided by the decoding unit and the dispatch unit, and can generate relevant pipeline control information (i.e., the fourth information mentioned above) and / or extended instruction execution status (i.e., the fifth information mentioned above) and transmit it back to the RISC-V processor, so as to notify the RISC-V processor of the extended instruction execution status and whether it is necessary to block the pipeline in the core.

[0158] In this application example, Figure 8As shown, the dedicated load / store module may include a load unit and a storage unit. Among them, the load unit may receive the source operand from the RISC-V processor, and at the same time, according to the register number (i.e., the identifier of the first target register) in the extended load instruction (i.e., the fifth instruction), load the data into the dedicated register group; and for the load instruction of the modulus and preprocessing number (i.e., the sixth instruction), the load unit may bypass the dedicated register group and directly bypass the data to the temporary register of the operation execution module. The storage unit may read the operation result from the dedicated register group according to the register number (i.e., the identifier of the second target register) in the extended storage instruction (i.e., the seventh instruction), and store the operation result back into the RISC-V processor. In this way, through the dedicated load / store module, a complete data interaction path can be established between the coprocessor and the RISC-V processor, thereby reducing the data transmission cost between the RISC-V processor and the coprocessor.

[0159] In this application example, Figure 8 As shown, the operation execution module may include a modular multiplication unit, a modular reduction unit, a modular addition and subtraction unit, and a data temporary storage unit (i.e., a temporary register). The data temporary storage unit is used to temporarily store the modulus and pre-processed data in the modular operation. For the modular operation in the same application, the modulus and the pre-processed data usually remain unchanged throughout the entire execution process. Therefore, if the same method of reading data from a dedicated register is used as other source operands of the modular operation, it may cause too much additional data transmission. Therefore, a group of temporary registers can be used in the operation execution module to temporarily store these data. The temporary register communicates directly with the load unit bypassing the dedicated register group, and the values ​​inside the temporary register can be directly called by each computing unit.

[0160] In this application example, the modular multiplication unit in the operation execution module can be used to perform modular multiplication operations, and the modular multiplication unit can be specifically implemented according to the algorithm shown in Table 2. As shown in Table 2, the algorithm receives four inputs: modulus, multiplicand, multiplier and preprocessing number; wherein the preprocessing number is jointly confirmed by the multiplicand and the modulus; the calculation of the preprocessing number requires real division, so the calculation of the preprocessing number can be completed by the RISC-V processor, and then transmitted to the coprocessor as input; according to the algorithm, after the preprocessing number is calculated, the division or modular reduction operation is no longer used in the process of performing modular multiplication calculation, thereby effectively improving the algorithm performance. The hardware architecture implemented according to the algorithm shown in Table 2 can be as follows Fig. 9 As shown, in Fig. 9In the modular multiplication unit architecture shown, the input and output ports are represented by hollow circles; the modules are represented by closed polygons; the data and its flow direction are represented by connecting lines with arrows; the devices with triangular protrusions on the lower edges are devices containing sequential logic, and the devices without triangular protrusions are devices containing only combinational logic; the unnamed slender rectangular modules are ordinary registers used to store data and distinguish pipeline stages; the inputs of the low-word multiplier and the high-word multiplier are both operands of two machine word lengths, and both contain two levels of registers internally. The difference between the two is that the output of the low-word multiplier is the low k bits of the multiplication result (k is the machine word length), and the output of the high-word multiplier is the high k bits of the multiplication result; the subtractor, comparator, and selector are all pure combinational devices, and their functions are as indicated by their names. Combining Table 2 with Fig. 9 It can be seen that the modular multiplication unit contains a total of 6 pipeline stages: the low-word multiplier 1 in the 1st and 2nd levels completes the operation of the 1st line in the algorithm, and the high-word multiplier 1 completes the operation of the 2nd line in the algorithm; the low-word multiplier 2 in the 3rd and 4th levels completes the operation of the 3rd line; the subtractor 1 in the 5th level completes the operation of the 4th line; the subtractor, comparator and selector in the 6th level complete the operation of the 5th and 6th lines.

[0161] Table 2

[0162]

[0163] In this application example, the modular reduction unit in the operation execution module can be used to perform modular reduction operations, and the modular reduction unit can be specifically implemented according to the algorithm shown in Table 3. As shown in Table 3, the implementation process of the modular reduction algorithm is roughly the same as that of the modular multiplication algorithm. The main difference is that the modular reduction algorithm has a single input, the preprocessing number is uniquely determined by the modulus, and there is one less multiplication step in the algorithm. Therefore, the modular reduction algorithm can be regarded as a simplified modular multiplication algorithm. The hardware architecture implemented according to the algorithm shown in Table 3 can be as follows: Fig.10 As shown, the correspondence between the modular reduction unit architecture and the fast modular reduction algorithm is basically consistent with the correspondence between the modular multiplication unit and the fast modular multiplication algorithm, and this application example will not be repeated.

[0164] Table 3

[0165]

[0166]

[0167] In this application example, the modular addition and subtraction unit in the operation execution module can be used to perform modular addition and modular subtraction operations, and the modular addition and subtraction unit can be specifically implemented according to the algorithms shown in Tables 4 and 5. As shown in Tables 4 and 5, the implementation processes of the modular addition algorithm and the modular subtraction algorithm are similar: the modular addition algorithm first performs an addition, and if the addition result exceeds the modulus, it performs a subtraction; the modular subtraction algorithm first performs a subtraction, and if the subtraction result is less than 0, it performs an addition. Therefore, the modular addition algorithm and the modular subtraction algorithm can be implemented using the same set of hardware, and the specific function can be selected by parsing the control signal generated by the instruction. The hardware architecture implemented according to the algorithm shown in Tables 4 and 5 can be as follows: Fig.11 As shown, the modular addition and subtraction unit includes 2 pipeline stages: the adder / subtractor 1 in the first stage completes the operation of the first line in the modular addition or modular subtraction algorithm; the adder / subtractor 2, the comparator and the selector in the second stage complete the operation of the second and third lines in the modular addition or modular subtraction algorithm. The specific operation performed by the modular addition and subtraction unit can be controlled by the addition / subtraction control signal: when the control signal is addition, the unit performs modular addition operation, at this time, the function of the adder / subtractor 1 is addition, the function of the adder / subtractor 2 is subtraction, and the comparator is used to compare whether the input is greater than the modulus; when the control signal is subtraction, the unit performs modular subtraction operation, at this time, the function of the adder / subtractor 1 is subtraction, the function of the adder / subtractor 2 is addition, and the comparator is used to confirm whether the input is less than 0.

[0168] Table 4

[0169]

[0170] Table 5

[0171]

[0172] In this application example, based on Figure 8 The acceleration device architecture shown, the complete workflow of the coprocessor (i.e., the second processor) and the RISC-V processor (i.e., the first processor) may include:

[0173] Step 1: When the instruction to be executed in the RISC-V processor is a regular RISC-V instruction, the RISC-V processor completes the operations of decoding, executing, and writing back the instruction by itself;

[0174] Step 2: When the instruction to be executed in the RISC-V processor is a fast modular operation extension instruction, the RISC-V processor passes the instruction-related information (i.e., the instruction to be executed itself) to the instruction scheduling module in the coprocessor, and passes the required source operand, modulus, and preprocessing number to the load / store module in the coprocessor, and the coprocessor completes the related operations of the extension instruction;

[0175] Here, during the execution of the extended instruction, the RISC-V processor can synchronously receive the pipeline control information (i.e., the fourth information mentioned above) from the instruction scheduling module in the coprocessor, and manage the pipeline state in the processor in combination with the internal control information; for example, if a branch prediction error occurs in the branch prediction information of the RISC-V processor, the RISC-V processor must clear the subsequent instructions being executed in order to obtain the correct result. This action also needs to occur in the coprocessor, that is, the control information (i.e., the fourth information mentioned above) and status information (i.e., the fifth information mentioned above) of the coprocessor will also be cleared, and will affect the internal pipeline state of the processor accordingly.

[0176] Step 3: Inside the coprocessor, upon receiving a request from the RISC-V processor to execute an extended instruction, the instruction scheduling module may issue relevant execution information (i.e., the first information) to the operation execution module after parsing the instruction and determining data relevance; the operation execution module may schedule the corresponding modular operation unit to perform the operation and write the operation result back to the dedicated register group;

[0177] Here, when the operation execution module is performing calculations, the pipeline management unit in the instruction scheduling module can synchronously update the instruction execution status information (i.e., the fifth information mentioned above) and interact with the RISC-V processor in real time about the instruction execution status information.

[0178] Step 4: After the coprocessor completes the calculation of the extended instruction, the load / store module completes the writing of the operation result of the coprocessor to the RISC-V processor; at the same time, the instruction scheduling module can notify the RISC-V processor that the instruction execution is completed.

[0179] In this application example, based on the coprocessor and extended instruction set design, an acceleration process for the data center encryption algorithm is also designed. Fig.12 As shown, a data center encryption algorithm can be implemented using a software program (the software program can specifically include functions for implementing the algorithms shown in Tables 2 to 5). After the compiler completes the compilation, it is sent to the acceleration device; the RISC-V processor completes the conventional computing operations, and the coprocessor completes the extended instruction operations; finally, the complete data center encryption algorithm is executed, and a data center encryption application including extended instruction acceleration is realized.

[0180] In this application example, in addition to the acceleration device including the RISC-V processor and the RISC-V coprocessor, in order to reduce the interaction overhead between the main processor (i.e., the above-mentioned RISC-V processor) and the coprocessor (i.e., the above-mentioned RISC-V coprocessor), when the amount of encryption operations to be accelerated is not large, the main processor can be equipped with a scheme of adding encryption algorithm acceleration instructions, and the encryption operations can be completed by the main processor. Specifically, the following four encryption operation acceleration instructions can be added to the main processor:

[0181] 1) setq rs1 (i.e. the ninth instruction above): The encoding format of this instruction can be as follows Figure 4 As shown, it is used to fill the value in register rs1 into the modulus register (i.e., the fourth target register mentioned above); after executing this instruction and before using the setq instruction again (i.e., before executing this instruction again), the modulus operation is performed with the number set by the instruction as the modulus;

[0182] 2) addq rd, rs1, rs2 (i.e. the tenth instruction above): The encoding format of this instruction can be as follows: Figure 5 As shown, it is used to first calculate the result of rs1 plus rs2, then use the result to modulo the modulus in the modulus register (i.e., the fourth target register mentioned above), and fill the modulo result into rd; executing this instruction is equivalent to completing rd = (rs1 + rs2) mod q, where mod represents the modulo operation, and q represents the modulus set by executing the setq instruction before executing this instruction (i.e., the modulus in the fourth target register mentioned above);

[0183] 3) subq rd, rs1, rs2 (i.e. the eleventh instruction above): The encoding format of this instruction can be as follows Figure 6 As shown, it is used to first calculate the result of rs1 minus rs2, then use the result to modulo the modulus in the modulus register (i.e., the fourth target register mentioned above), and fill the modulo result into rd; executing this instruction is equivalent to completing rd = (rs1-rs2) mod q, where mod represents the modulo operation, and q represents the modulus set by executing the setq instruction before executing this instruction (i.e., the modulus in the fourth target register mentioned above);

[0184] 4) mulq rd, rs1, rs2 (i.e. the twelfth instruction above): The encoding format of this instruction can be as follows Figure 7 As shown, it is used to first calculate the result of rs1 multiplying rs2, then take the result modulo the modulus in the modulus register (i.e., the fourth target register mentioned above), and fill the modulo result into rd; executing this instruction is equivalent to completing rd = (rs1×rs2) mod q, wherein mod represents the modulo operation, and q represents the modulus set by executing the setq instruction before executing this instruction (i.e., the modulus in the fourth target register mentioned above).

[0185] In this application example, before using this group of acceleration instructions, the setq instruction must be executed to set the modulus. After the setq instruction is executed, the addq, subq, and mulq operations executed will perform modulus operations according to the modulus set by setq. The modulus can be set multiple times, and the effective range of the modulus set each time using setq is before the new modulus set by setq next time. The modulus set by setq must be a prime number, otherwise the correctness of the operation result cannot be guaranteed. In addition, the addq, subq, and mulq instructions also require that the operands from the source registers (i.e., rs1, rs2) (i.e., the first source operand, the second source operand, the third source operand, the fourth source operand, the fifth source operand, and the sixth source operand mentioned above) are all smaller than the modulus, otherwise the requirements for the modulus operation will not be met.

[0186] In this application example, the newly added modular operation instructions (i.e., the acceleration instructions for the above four encryption operations) can effectively speed up the modular operation. For example, if the instructions addq and subq are not used to perform modular operations, the operations that need to be performed to achieve the expected functions include at least:

[0187] (addition)

[0188] add x4,x1,x2

[0189] blt x3,x4,f1

[0190] sub x4, x4, x3

[0191] f1:

[0192] (Subtraction)

[0193] sub x4,x1,x2

[0194] blt x4,x0,f1

[0195] add x4,x4,x3

[0196] f1:

[0197] (x1 and x2 store the operands to be added or subtracted, x3 stores the modulus, and x4 stores the final result)

[0198] It can be seen that compared with using only addq and subq instructions, the above implementation method not only has more instructions, but also needs to introduce data-related and control-related processing, making it difficult to perform modular operations efficiently.

[0199] In this application example, for modular multiplication operations, if the fast instruction mulq is not used, and the modular operation supported by the M extended instruction set is used, then each modular multiplication requires a multiplication operation and a modular operation, and the essence of the modular operation is to perform a division operation, which takes much longer than addition, subtraction, and multiplication, and the execution efficiency is low. Therefore, the fast modular multiplication instruction mulq can be used, and the efficient Barrett modular multiplication algorithm can be used in the internal implementation of the instruction, and the modular operation is completed with only addition, subtraction, and multiplication operations, thereby improving the efficiency of performing modular operations.

[0200] This application example aims at the large number of fast modular operations in data center encryption algorithms. It uses the method of designing a RISC-V extended instruction coprocessor to accelerate a large number of modular operations such as modular multiplication, modular addition and subtraction, and modular reduction in data center encryption algorithms. Compared with fast modular operations implemented by software and the existing RISC-V instruction set, the number of instructions is greatly reduced, and data-related and control-related factors are reduced (that is, operations related to data and / or control factors of modular operations are reduced), which improves the operating efficiency of fast modular operations, thereby achieving an overall performance improvement in running data center encryption algorithms. In addition, the solution provided by this application example has at least the following advantages:

[0201] 1) The four modules of the coprocessor (i.e., instruction scheduling module, operation execution module, dedicated load / store module, and dedicated register group) form a complete data path and a complete interaction mechanism with the RISC-V processor. They can execute fast modular operation extension instructions without destroying the original execution mode of the RISC-V processor, thereby achieving the effect of improving the running performance;

[0202] 2) By managing a table of historical instruction register numbers (i.e., the third information) in the dispatch unit and designing a dispatch unit to block instruction issuance, the correctness of the coprocessor execution result can be ensured;

[0203] 3) Through the dedicated load / store module, a complete data interaction path can be established between the coprocessor and the RISC-V processor, thereby reducing the data transmission cost between the RISC-V processor and the coprocessor;

[0204] 4) After the modular multiplication algorithm shown in Table 2 calculates the preprocessing number, the division or modular reduction operation is no longer used in the process of performing the modular multiplication calculation, thereby effectively improving the algorithm performance;

[0205] 5) When the amount of encryption operations that need to be accelerated is not large, the main processor (i.e., RISC-V processor) can be equipped with new encryption algorithm acceleration instructions, and the encryption operations can be completed by the main processor. That is, the four encryption operation-related instructions of modulus setting setq, modular addition addq, modular subtraction subq, and modular multiplication mulq are added to the main processor, thereby effectively improving the efficiency of executing modular operations.

[0206] In an exemplary embodiment, the embodiment of the present application further provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory storing a computer program for implementing the operation of the above-mentioned second processor 120, the memory can be set inside or outside the acceleration device 100, and the computer program can be executed by the second processor 120 to complete the steps of any method described in the above-mentioned second processor side. For another example, a memory storing a computer program for implementing the operation of the above-mentioned third processor is included, and the computer program can be executed by the third processor to complete the steps of any method described in the above-mentioned third processor side. In addition, the storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.

[0207] In an exemplary embodiment, the embodiment of the present application also provides a computer program product, including a computer program, which can be executed by the second processor 120 to complete the steps of any method described in the aforementioned second processor side; or, the computer program can be executed by the above-mentioned third processor to complete the steps of any method described in the aforementioned third processor side.

[0208] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0209] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0210] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.

Claims

1. An acceleration device, characterized in that: include: A first processor and a second processor; wherein, The first processor is configured to send the instruction to be executed and the to-be-executed data associated with the instruction to be executed to the second processor when the instruction to be executed is associated with a modular operation of an encryption algorithm; The second processor is used to receive the instructions to be executed and the data to be processed sent by the first processor, perform a modulo operation associated with the instructions to be executed based on the instructions to be executed and the data to be processed, obtain an operation result, and send the operation result to the first processor.

2. The device according to claim 1, characterized in that The instruction to be executed is formed based on the instruction format of the fifth-generation reduced instruction set RISC-V, and the instruction to be executed includes one of the following: A first instruction, the first instruction is used to perform a modular multiplication operation; a second instruction, the second instruction being used to perform a modular reduction operation; A third instruction, the third instruction is used to perform a modular addition operation; A fourth instruction is used to perform a modular subtraction operation.

3. The device according to claim 1, characterized in that The second processor includes a register group and a temporary register, wherein the register group includes a plurality of registers; the data to be processed includes one or more source operands of a modulus operation associated with the instruction to be executed, and includes related moduli and / or related preprocessing numbers; wherein, The first processor is further configured to send a fifth instruction, a sixth instruction, and a seventh instruction to the second processor, wherein the fifth instruction, the sixth instruction, and the seventh instruction are formed based on the RISC-V instruction format, the fifth instruction is configured to instruct the second processor to load the one or more source operands into the first target register corresponding to the instruction to be executed in the register group, the sixth instruction is configured to instruct the second processor to load the relevant modulus and / or relevant preprocessing number into the temporary register, and the seventh instruction is configured to instruct the second processing unit to store the operation result in the second target register corresponding to the instruction to be executed in the register group back into the third target register of the first processor; The second processor is also used to receive the fifth instruction, the sixth instruction and the seventh instruction sent by the first processor, and based on the fifth instruction, the sixth instruction and the seventh instruction, load the one or more source operands into the first target register, load the relevant modulus and / or the relevant pre-processing number into the temporary register, and based on the one or more source operands and the relevant modulus and / or the relevant pre-processing number, perform the modulus operation associated with the instruction to be executed, obtain the operation result, store the operation result in the second target register, and store the operation result in the second target register back to the third target register.

4. The device according to claim 3, characterized in that The second processor further comprises a first module, a second module and a third module; wherein, The first module is used to receive the instruction to be executed, the fifth instruction, the sixth instruction and the seventh instruction, send first information to the second module, and send second information to the third module; the first information is used to schedule the second module to perform a modular operation associated with the instruction to be executed, and the second information is used to schedule the third module to execute the fifth instruction, the sixth instruction and the seventh instruction; The second module is configured to receive the first information sent by the first module, read the one or more source operands from the first target register based on the first information, read the relevant modulus and / or relevant preprocessing number from the temporary register, perform the modulus operation associated with the instruction to be executed based on the one or more source operands and the relevant modulus and / or relevant preprocessing number, obtain the operation result, and store the operation result in the second target register; the temporary register is set in the second module; The third module is used to receive the data to be processed and the second information sent by the first module, and based on the second information, load the one or more source operands into the first target register, load the relevant modulus and / or relevant preprocessing number into the temporary register, and store the operation result in the second target register back into the third target register.

5. The device according to claim 4, characterized in that The first module is further used for: maintaining third information, wherein the third information represents an association relationship between an eighth instruction and registers in the register group, wherein the eighth instruction includes an instruction that has not been completely executed by the second processor; In a case where the third information does not include the first target register and the second target register, the first information is sent to the second module, and the second information is sent to the third module.

6. The device according to any one of claims 1 to 5, characterized in that The second processor is further configured to determine fourth information and / or fifth information, and send the fourth information and / or fifth information to the first processor, wherein the fourth information includes pipeline-related information of the instruction to be executed, and the fifth information represents an execution state of the instruction to be executed; The first processor is further configured to receive the fourth information and / or the fifth information sent by the second processor, and perform its own pipeline state management based on the fourth information and / or the fifth information.

7. An acceleration method, characterized in that: The second processor used in the acceleration device includes: receiving an instruction to be executed and data to be processed associated with the instruction to be executed sent by a first processor in the acceleration device, wherein the instruction to be executed is associated with a modulus operation of an encryption algorithm; Based on the to-be-executed instruction and the to-be-processed data, performing a modulo operation associated with the to-be-executed instruction to obtain an operation result; Sending the operation result to the first processor.

8. The method according to claim 7, characterized in that The instruction to be executed is formed based on the instruction format of RISC-V, and the instruction to be executed includes one of the following: A first instruction, the first instruction is used to perform a modular multiplication operation; a second instruction, the second instruction being used to perform a modular reduction operation; A third instruction, the third instruction is used to perform a modular addition operation; A fourth instruction is used to perform a modular subtraction operation.

9. The method according to claim 7, characterized in that: The second processor comprises a register group and a temporary register, wherein the register group comprises a plurality of registers; the data to be processed comprises one or more source operands of a modulus operation associated with the instruction to be executed, and comprises a related modulus and / or a related pre-processing number; The performing a modulo operation associated with the instruction to be executed based on the instruction to be executed and the data to be processed includes: Receive a fifth instruction, a sixth instruction, and a seventh instruction sent by the first processor, wherein the fifth instruction, the sixth instruction, and the seventh instruction are formed based on the RISC-V instruction format, the fifth instruction is used to instruct the second processor to load the one or more source operands into the first target register corresponding to the instruction to be executed in the register group, the sixth instruction is used to instruct the second processor to load the relevant modulus and / or relevant preprocessing number into the temporary register, and the seventh instruction is used to instruct the second processing unit to store the operation result in the second target register corresponding to the instruction to be executed in the register group back to the third target register of the first processor; Based on the fifth instruction, the sixth instruction and the seventh instruction, the one or more source operands are loaded into the first target register, the relevant modulus and / or the relevant preprocessing number are loaded into the temporary register, and based on the one or more source operands, and the relevant modulus and / or the relevant preprocessing number, the modulus operation associated with the instruction to be executed is performed to obtain the operation result, the operation result is stored in the second target register, and the operation result in the second target register is stored back in the third target register.

10. The method according to claim 9, characterized in that The performing a modulo operation associated with the instruction to be executed based on the one or more source operands, and the related modulo number and / or the related preprocessing number, comprises: The one or more source operands are read from the first target register, the relevant modulus and / or the relevant preprocessing number are read from the temporary register, and a modulus operation associated with the instruction to be executed is performed based on the one or more source operands and the relevant modulus and / or the relevant preprocessing number.

11. The method according to claim 10, characterized in that The method further comprises: maintaining third information, wherein the third information represents an association relationship between an eighth instruction and registers in the register group, wherein the eighth instruction includes an instruction that has not been completely executed by the second processor; In a case where the third information does not include the first target register and the second target register, the one or more source operands are read from the first target register, the relevant modulus and / or relevant preprocessing number are read from the temporary register, and based on the one or more source operands, and the relevant modulus and / or relevant preprocessing number, a modulus operation associated with the instruction to be executed is performed.

12. The method according to any one of claims 7 to 11, characterized in that: The method further comprises: Determine fourth information and / or fifth information, and send the fourth information and / or fifth information to the first processor, so that the first processor can perform its own pipeline status management based on the fourth information and / or fifth information; the fourth information includes pipeline-related information of the instruction to be executed, and the fifth information represents the execution status of the instruction to be executed.

13. An acceleration method, characterized in that: Applicable to the third processor, including: Perform a modular operation of the encryption algorithm by executing at least one of the following instructions: a ninth instruction including a modulus, the ninth instruction being used to store the modulus into a fourth destination register; a tenth instruction including a first source operand and a second source operand, the tenth instruction being configured to perform a modulo addition operation based on the first source operand and the second source operand and a modulus in a fourth destination register; an eleventh instruction including a third source operand and a fourth source operand, the eleventh instruction being configured to perform a modular subtraction operation based on the third source operand and the fourth source operand and a modulus in a fourth destination register; A twelfth instruction comprising a fifth source operand and a sixth source operand, the twelfth instruction being used to perform a modular multiplication operation based on the fifth source operand and the sixth source operand, and a modulus in a fourth target register.

14. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 7 to 12, or implements the steps of the method according to claim 13.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 7 to 12, or implements the steps of the method according to claim 13.

Citation Information

Cited By

  • Instruction acceleration device and operation method thereof

    CN121541926A