Ciphertext computing accelerator, ciphertext computing instruction processing method, device and medium
By connecting the ciphertext calculation unit and the double-cache SRAM structure through coding matching, the variable-length full-pipeline parsing of ciphertext calculation instructions is realized, which solves the problem of low processing efficiency of ciphertext calculation instructions and improves the processing efficiency and performance of ciphertext calculations. Storage speed.
Patent Information
- Application Number
- CN202410824626.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-06-25
AI Technical Summary
The processing efficiency of ciphertext calculation instructions in the prior art is low, resulting in increased processing time for ciphertext calculation instructions, and there are problems such as waste of bit width and excessive parsing time.
The code matching method is used to connect the ciphertext calculation control unit, routing unit and operator calculation unit. Through variable length instructions and double cache SRAM structure, full pipeline analysis of ciphertext calculation instructions is realized, reducing transmission time and improving analysis efficiency.
It improves the processing efficiency of ciphertext calculation instructions, saves the bit width of instructions, reduces transmission time, and improves storage and parsing speed through a double cache structure.
Smart Images

Figure CN118400094B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a ciphertext computing accelerator, a ciphertext computing instruction processing method, a device and a medium. Background Art
[0002] Ciphertext computing means converting data into ciphertext and then performing computing in the ciphertext state, so that the final result is consistent with the result of plaintext computing. At the same time, ciphertext computing can ensure that the computing result is consistent with the plaintext computing, thus ensuring that the business value of the data is not affected.
[0003] In the prior art, the ciphertext calculation control instruction adopts a fixed length instruction, and the instruction parsing adopts a single cache parsing method. The inventors have found that the ciphertext calculation in the prior art has the problem of low efficiency in processing ciphertext calculation instructions. Summary of the invention
[0004] The present application provides a ciphertext computing accelerator, a ciphertext computing instruction processing method, device and medium, which are used to solve the problem of low processing efficiency in the ciphertext computing instruction processing process, so as to improve the ciphertext computing instruction processing efficiency.
[0005] In a first aspect, the present application provides a ciphertext computing accelerator, comprising: a ciphertext computing control unit CCU, a ciphertext computing routing unit CRU, a ciphertext data storage unit DSU, and a ciphertext operator computing unit OCU;
[0006] The CCU, CRU, DSU and OCU are connected by coding matching, the CCU is connected to the host computer, the CRU has at least one level, each level of CRU corresponds to a layer number and is connected to a DSU and an OCU, and the DSU and OCU corresponding to each level receive the control flow data sent by the CCU through the CRU;
[0007] Any of the CCU, CRU, DSU and OCU can receive control flow data sent by the upper level unit and forward the control flow data to the lower level unit;
[0008] The control flow data is obtained after parsing and compiling a single instruction data, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths.
[0009] In a second aspect, the present application provides a method for processing ciphertext computing instructions, which is applied to the ciphertext computing accelerator described in the first aspect, wherein the ciphertext computing accelerator is communicatively connected to a host computer, and the method comprises:
[0010] Receiving the ciphertext calculation instruction sent by the host computer according to the preset bus width, and storing the ciphertext calculation instruction in the first-level cache SRAM according to the preset first-level cache data structure;
[0011] Control the CCU to read the bus-width ciphertext instruction from the primary cache SRAM and split it into single instruction data, and then write all the single instruction data into the secondary cache SRAM according to a preset secondary cache data structure, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field, and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths;
[0012] Each clock cycle controls the CCU to read a single instruction data from the secondary cache SRAM and decode the single instruction data according to a preset instruction format to obtain parsed data and a target node until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU.
[0013] In a possible implementation, the address occupied by the instruction type field is q bits, where q is a preset bit width value; accordingly, the control CCU reads out the bus bit width ciphertext instruction from the first-level cache SRAM and splits it into single instruction data, including: S502a: controlling the CCU to read the first type data of the corresponding bus bit width from the first-level cache SRAM with a read address of n, where n is an address value starting from 0 as an initial value; S502b: merging the first type data with the first type split remaining data in the first-level cache SRAM with an address of n-1 into second type data, and when n-1 is less than 0, the second type data is equal to the first type data; S502c: extracting the instruction type field located at the front q bits from the second type data , parse the instruction type field to obtain the third type data with an effective length of s; S502d: when it is detected that the length of the third type data is less than or equal to the length of the second type data, the third type data is determined as a single instruction data to be written into the secondary cache SRAM and written into the secondary cache SRAM, and the third type data is deleted from the second type data to obtain the deleted second type data; S502e: when it is detected that the length of the deleted second type data is less than the instruction type field length q, the deleted second type data is determined as the instruction data to be merged, and after assigning n+1 to n, jump to step S502e, until the last single instruction data in the primary cache SRAM is the end instruction.
[0014] In a possible implementation, the control CCU reads out the bus width ciphertext instruction from the first-level cache SRAM and splits it into single instruction data, including: after S502c, when it is detected that the length of the third type of data is greater than the length of the second type of data, the second type of data is determined as the first type of split remaining data, and after assigning n+1 to n, jumps to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction; or after S502d, when it is detected that the length of the deleted second type of data is greater than or equal to the length q of the instruction field type, jumps to step S502c. In a possible implementation, the control CCU reads out the bus width ciphertext instruction from the first-level cache SRAM and splits it into single instruction data also includes: when it is detected that the read address is n=0, directly skip step S502b and execute step S502c.
[0015] In a possible implementation, each clock cycle controls the CCU to read out a single instruction data from the secondary cache SRAM and decodes the single instruction data according to a preset instruction format to obtain the parsed data and the target node, and further includes: controlling the CCU to package the parsed data into control flow data and send it to the target node, so that the target node performs encoding matching processing on the control flow data, and if a successful match is detected, executes the ciphertext calculation instruction according to the control flow data.
[0016] In a possible implementation, the target node is at least one unit among CRU, DSU and OCU, the CRU includes at least one level, each level of the CRU corresponds to a first code, the DSU connected to the CRU of each level corresponds to a second code of the level, and the OCU connected to the CRU of each level corresponds to a third code of the level; the first code, the second code and the third code corresponding to each level are the same, or the target node represented by each code in the first code, the second code and the third code is unique.
[0017] In a possible implementation, after the control CCU packages the parsed data into control flow data and sends it to the target node so that the target node performs encoding matching processing on the control flow data, it also includes: if a match failure is detected, the control CCU returns to read out a single instruction data of the next address from the secondary cache SRAM and decodes the single instruction data according to a preset instruction format.
[0018] In a third aspect, the present application provides a ciphertext computing instruction processing device, which is applied to the ciphertext computing accelerator described in the first aspect, wherein the ciphertext computing accelerator is communicatively connected to a host computer, and the device comprises:
[0019] A receiving module, used for receiving the ciphertext calculation instruction sent by the host computer according to the preset bus bit width, and storing the ciphertext calculation instruction into the first-level cache SRAM according to the preset first-level cache data structure;
[0020] A splitting module, used to control the CCU to read the bus-width ciphertext instruction from the first-level cache SRAM and split it into single instruction data, and then write all the single instruction data into the second-level cache SRAM according to a preset second-level cache data structure, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths;
[0021] The parsing module is used to control the CCU to read a single instruction data from the secondary cache SRAM in each clock cycle and decode the single instruction data according to a preset instruction format to obtain parsed data and a target node until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU.
[0022] In a fourth aspect, the present application provides a computer-readable storage medium, in which a computer-executed instruction is stored. When the computer-executed instruction is executed, the ciphertext computing instruction processing method described in the second aspect above is implemented.
[0023] The ciphertext computing accelerator, ciphertext computing instruction processing method, device and medium provided by the present application are first applied to the ciphertext computing accelerator connected by coding matching, and then after receiving the ciphertext computing instruction sent by the host computer, the space of the ciphertext computing instruction is saved by means of variable-length instructions, thereby reducing the transmission time of the ciphertext computing instruction. The full-pipeline parsing of the ciphertext computing variable-length instruction is then realized through the double-cache structure of the first-level cache SRAM and the second-level cache SRAM, and the parsing efficiency of the ciphertext instruction is improved, that is, each clock cycle controls the CCU to read a single instruction data from the second-level cache SRAM and decode the single instruction data according to the preset instruction format to obtain the parsing data and the target node, until the single instruction data is the end instruction. The storage and parsing speed of the ciphertext computing instruction is improved by using the double-cache structure to achieve the purpose of improving the processing efficiency of the ciphertext computing instruction. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0025] Figure 1 A parallel connection diagram of a ciphertext computing accelerator in the prior art provided in an embodiment of the present application;
[0026] Figure 2 A schematic diagram of the bit width of a fixed-length ciphertext instruction provided in an embodiment of the present application;
[0027] Figure 3 A schematic diagram of an application scenario of the method for processing ciphertext computing instructions provided in an embodiment of the present application;
[0028] Figure 4 A coding matching connection diagram of a ciphertext computing accelerator provided in an embodiment of the present application;
[0029] Figure 5 A flowchart of a method for processing ciphertext calculation instructions provided in an embodiment of the present application;
[0030] Figure 6 A schematic diagram of the instruction field structure of the ciphertext calculation instruction provided in an embodiment of the present application;
[0031] Figure 7 A schematic diagram of the data structure of the first-level cache SRAM provided in an embodiment of the present application;
[0032] Figure 8 A schematic diagram of the data structure of the secondary cache SRAM provided in an embodiment of the present application;
[0033] Fig. 9 A schematic diagram of a splitting process for reading out a bus-width ciphertext computing instruction from a primary cache SRAM and splitting it into single instruction data provided in an embodiment of the present application;
[0034] Fig.10 A schematic diagram of the arrangement of control flow data output when parsing instructions provided in an embodiment of the present application;
[0035] Fig.11 A schematic diagram of the structure of a ciphertext computing instruction processing device provided in an embodiment of the present application;
[0036] Fig.12 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0038] Figure 1 A parallel connection diagram of a ciphertext computing accelerator in the prior art provided in an embodiment of the present application.
[0039] Figure 2 A schematic diagram of the bit width of a fixed-length ciphertext instruction provided in an embodiment of the present application.
[0040] like Figure 1 and Figure 2 As shown, the ciphertext computing accelerator includes CCU (Ciphertext Computing Control Unit), CRU (Ciphertext Computing Routing Unit), DSU (Ciphertext Data Storage Unit) and OCU (Ciphertext Operator Computing Unit). The inventor found that when using a ciphertext computing accelerator, since the instructions of OCU are the most complex and require a larger bit width, the instructions of CRU are the simplest and require the smallest bit width, and the instruction complexity and instruction bit width of DSU are in the middle, therefore, when using fixed-length instructions, the instruction lengths of CRU, DSU and OCU must be equal to the instruction length of OCU instructions, resulting in more bit width waste, and the transmission time and parsing time of instructions corresponding to different instruction lengths are also different, and the instruction length is positively correlated with the execution time of the instruction, so the following is adopted. Figure 2 The bit width of the fixed-length ciphertext instruction shown in the figure, when performing instruction parsing, the parsing time of the instruction with the longest bit width must be used for parsing. For example, the parsing time required for the CRU ciphertext instruction is the shortest 0.1 second, but the actual parsing time according to the fixed-length ciphertext instruction is 0.4 seconds, the same as the parsing time required for the OCU. Moreover, during the data storage and reading process, the corresponding ciphertext calculation instruction may not be parsed out in each clock cycle, resulting in time intervals or blank clock cycles without ciphertext calculation instructions. Therefore, the whole data processing process increases the parsing time of the ciphertext calculation instruction, resulting in a problem of reduced ciphertext calculation instruction processing efficiency.
[0041] In order to solve the above technical problems, the embodiments of the present application provide the following technical ideas for solving the problems: using customized control instruction lengths for different control objects to form variable-length instructions, saving the bit width of ciphertext instructions, and reducing the transmission time of instructions. The full-pipeline parsing of variable-length ciphertext calculations is realized through the structure of a double-buffered SRAM, and forwarded to the ciphertext data storage unit and the ciphertext operator calculation unit through the ciphertext calculation routing unit CRU. The CRU / DSU and OCU will configure the code associated with this unit, and the control flow will then control the corresponding unit by code matching. Further improve the parsing efficiency.
[0042] Figure 3 A schematic diagram of an application scenario of the method for processing ciphertext computing instructions provided in an embodiment of the present application, such as Figure 3 As shown, it includes: a host computer 301 and a ciphertext calculation accelerator 302.
[0043] The host computer 301 is connected to the ciphertext computing accelerator 302 through a PCIE (Peripheral Component Interconnect Express) interface, and sends the fully homomorphic ciphertext computing data and instructions to the ciphertext computing accelerator 302 through the PCIE interface.
[0044] Figure 4 The coding matching connection diagram of the ciphertext computing accelerator provided in the embodiment of the present application.
[0045] like Figure 4 As shown, the ciphertext computing accelerator 302 provided in the embodiment of the present application includes a ciphertext computing control unit CCU, a ciphertext computing routing unit CRU, a ciphertext data storage unit DSU and a ciphertext operator computing unit OCU. The CCU, CRU, DSU and OCU are connected by coding matching, the CCU is connected to the host computer, the CRU level includes at least one, each level of CRU corresponds to a layer number and is connected to a DSU and an OCU, and the DSU and OCU corresponding to the level receive the control flow data sent by the CCU through the CRU; any unit among the CCU, CRU, DSU and OCU can receive the control flow data sent by the upper level unit and forward the control flow data to the lower level unit; the control flow data is obtained after the single instruction data is parsed and compiled, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths.
[0046] In this embodiment, the CCU is used to parse the ciphertext computing instructions, and the parsed control data flow is forwarded to the ciphertext data storage unit and the ciphertext operator computing unit through the ciphertext computing routing unit. The encoding of this unit will be configured inside the CRU / DSU / OCU, and the control flow controls each unit by encoding matching.
[0047] like Figure 4 As shown, in an optional embodiment of the present application, the codes corresponding to each level of CRU are 0, 1, 2, and 3 in sequence. Correspondingly, the codes of the DSU connected to the CRU of each level can also be 0, 1, 2, and 3. Similarly, the codes of the OCU connected to the CRU of each level can also be 0, 1, 2, and 3. It should be noted that the codes between the CRU, DSU, and OCU of each level do not need to correspond one to one, and it is only necessary to ensure that the codes of the CRU, DSU, or OCU in each level are unique codes.
[0048] In summary, the ciphertext computing accelerator provided in the embodiment of the present application connects the CCU, CRU, DSU and OCU through a coding matching method. The coding matching method belongs to a serial control signal method. Compared with the parallel signal control method, it saves more control signal line routing area, improves the scale of the sealed computing network, and provides hardware acceleration conditions for the processing process of ciphertext computing instructions, thereby improving the processing efficiency of ciphertext computing instructions.
[0049] Figure 5 This is a flow chart of the method for processing ciphertext calculation instructions provided in an embodiment of the present application. The execution subject of this embodiment may be Figure 3 The ciphertext calculation accelerator 302 in the illustrated embodiment may also be other computer-related devices or circuits that have a function of accelerating the ciphertext algorithm, and this embodiment is not particularly limited. In addition, the ciphertext calculation accelerator 302 is connected to the host computer for communication.
[0050] like Figure 5 As shown, the ciphertext calculation instruction processing method includes:
[0051] S501: receiving a ciphertext calculation instruction sent by a host computer according to a preset bus width, and storing the ciphertext calculation instruction into a first-level cache SRAM according to a preset first-level cache data structure.
[0052] Figure 6 A schematic diagram of the instruction field structure of the ciphertext calculation instruction provided in an embodiment of the present application.
[0053] Figure 7 A schematic diagram of the data structure of the first-level cache SRAM provided in an embodiment of the present application.
[0054] like Figure 6 and Figure 7As shown, in this embodiment, the instruction field of the ciphertext calculation instruction includes the instruction type, instruction code, instruction time and instruction parameters. Among them, the instruction type can be distinguished according to the bit width required to be occupied by different ciphertext calculation instructions. For example, the instruction to control the ciphertext operator calculation unit OCU is the most complex and requires a larger bit width, such as Figure 7 The instructions for controlling the ciphertext calculation routing unit CRU are the simplest and require the smallest bit width, such as Figure 7 The green box in the middle. The instruction complexity and the required bit width of the control ciphertext data storage unit DSU are centered, such as Figure 7 The orange box in the middle is used to supplement the bit width occupied by invalid data of the first-level cache SRAM address. The bit width occupied by invalid data can be adjusted according to usage requirements, such as Figure 7 The white box in the first-level cache address 3.
[0055] Starting from the address 0 of the first-level cache SRAM, the ciphertext calculation instructions are gradually stored in the cache SRAM until all the ciphertext calculation instructions are written. The orange box represents the ciphertext calculation instructions of the DSU (hereinafter referred to as the DSU instruction), the green box represents the ciphertext calculation instructions of the CRU (hereinafter referred to as the CRU instruction), and the blue box represents the ciphertext calculation instructions of the OCU (hereinafter referred to as the OCU instruction).
[0056] In this embodiment, the preset bus width can be the PCIE bus data width, the ciphertext calculation instructions are arranged continuously in the memory, and the instructions read in the PCIE total memory are based on the vertical width as the basic unit. Each bus width will include multiple complete or incomplete indefinite length instructions.
[0057] In this embodiment, the ciphertext calculation instructions are stored in the first-level cache SRAM according to the preset first-level cache data structure. The main function of the first-level cache is to control the vertical data flow. The condition that the cache SRAM can be written is that the first-level cache is not full, and the condition that the cache SRAM can be read is that the cache is not empty.
[0058] S502: Control the CCU to read the bus-width ciphertext instruction from the first-level cache SRAM and split it into single instruction data, and then write all the single instruction data into the second-level cache SRAM according to the preset second-level cache data structure, where the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths.
[0059] In this embodiment, the preset instruction format refers to the instruction type field, instruction code field, instruction length field and instruction parameter field in a single instruction data. The addresses of these fields are arranged in sequence to form a single instruction data of a fixed format such as Figure 6As shown. The bit widths of single instruction data corresponding to different instruction type fields are different, which means that the bit width of single instruction data is determined by the instruction type. For example, the bit width of OCU instruction is larger than that of DSU instruction, and the bit width of DSU instruction is larger than that of CRU instruction.
[0060] In this embodiment, the instruction type field is parsed to obtain the instruction type of a single instruction data. The instruction code field is parsed to obtain the code of the target node. The instruction time field is parsed according to the preset instruction format to obtain the instruction execution time of the target node. The instruction parameter field is parsed to obtain the parameters of the target node.
[0061] Figure 8 A schematic diagram of the data structure of the secondary cache SRAM provided in an embodiment of the present application.
[0062] like Figure 8 As shown, in this embodiment, step S502 refers to the process in which the CCU reads out the bus-width encrypted computing instructions from the first-level cache SRAM and splits them into single instruction data, and then writes each single instruction data into the second-level cache SRAM in order of address from 0 to n.
[0063] Fig. 9 A schematic diagram of a splitting process for reading out bus-width encrypted computing instructions from a first-level cache SRAM and splitting them into single instruction data is provided in an embodiment of the present application.
[0064] like Fig. 9 As shown, specifically, in an optional embodiment of the present application, the address occupied by the instruction type field is q bits, where q is a preset bit width value. Accordingly, from step "start splitting" to step "end splitting", step S502 includes: step start.
[0065] S502a: Control the CCU to read the first type of data of the corresponding bus width from the first-level cache SRAM with a read address of n, where n is an address value starting from 0 as an initial value.
[0066] In this embodiment, the first type of data may be all instruction data contained in the bus width under a certain read address. Assume that the bus width is p, the length of a single instruction is s, s is determined by the instruction type, and the address length occupied by the instruction type field is q. In this embodiment, the read address may be the first-level cache SRAM address. For example, when n=1, the corresponding first type of data to be split may be as follows: Figure 7 The bus-width ciphertext instruction corresponding to the first-level cache SRAM address 1 shown, the first type of data includes a part of an OCU instruction, a complete DSU instruction, a complete CRU instruction and a part of a DSU instruction.
[0067] S502b: merge the first type data and the first type split remaining data in the first level cache SRAM with address n-1 into second type data, and when n-1 is less than 0, the second type data is equal to the first type data.
[0068] In this embodiment, the first type of split remaining data in the first-level cache SRAM with address n-1 may be the remaining data after the last split. For example, when the first-level cache address n=1, the corresponding address is n-1 and the address in the cache SRAM is 0. The remaining data after the split is a part of the OCU instruction, corresponding to the attached Figure 7 The last blue box in the first type of data with the first level cache address 0. The second type of data merged at this time is a complete OCU instruction, a complete DSU instruction, a complete CRU instruction, and a part of a CRU instruction.
[0069] When n-1 is less than 0, that is, n=0, there is no first-type split remaining data in the first-level cache SRAM with address n-1, and the second-type data is the first-type data at address n=0. The second-type data obtained after the first-type data is merged is exactly the same as the first-type data before the merger.
[0070] In an optional embodiment of the present application, after step S502a, the process further includes: when it is detected that the read address is n=0, directly skipping step S502b and executing step S502c.
[0071] In this embodiment, when n=0, the second type of data is completely identical to the first type of data before merging. Therefore, step S502b does not need to be performed, and the process can directly jump to step S502c, thereby saving time and improving efficiency.
[0072] S502c: Extract the instruction type field located at the front q bits from the second type data, parse the instruction type field, and obtain the third type data with an effective length of s.
[0073] In this embodiment, the instruction type field of the first q bits extracted from the second type of data refers to the instruction type field in a single instruction data that is the first in the second type of data, and the bit width occupied by the instruction type field is q. Parsing the q-bit instruction type field refers to the process of parsing the instruction type field to obtain the instruction length of the single instruction data corresponding to the instruction type field. The third type of data refers to the single instruction data corresponding to the q-bit instruction type field. For example: after parsing the first q bits of the instruction type field, it can be known that the single instruction data corresponding to the instruction type field is a complete OCU instruction obtained after merging, and the effective length of the OCU instruction can be determined to be s.
[0074] S502d: When it is detected that the length of the third type of data is less than or equal to the length of the second type of data, the third type of data is determined as a single instruction data to be written into the secondary cache SRAM and written into the secondary cache SRAM, and the third type of data is deleted from the second type of data to obtain the deleted second type of data.
[0075] In this embodiment, deleting the third type of data from the second type of data means that the third type of data in the first level cache SRAM has been written into the second level cache SRAM, so the third type of data in the original first level cache SRAM has been split and should be deleted. For example, when n=1, the deleted second type of data includes a complete DSU instruction, a complete CRU instruction, and a part of a DSU instruction.
[0076] S502e: When it is detected that the length of the second type data after deletion is less than the instruction type field length q, the second type data after deletion is determined as the remaining data of the first type split, and after n+1 is assigned to n, jump to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction.
[0077] In this embodiment, the length of the deleted second type data refers to the bit width occupied by all data in the second type data after deleting the third type data. When it is detected that the length of the deleted second type data is less than the instruction type field length q, it means that the deleted second type data can no longer form a complete single instruction data. For example: Figure 7 The data represented by the last blue box corresponding to the address n=0. In this embodiment, the new first-type splitting remaining data refers to the remaining data finally obtained after the first-type data in the first-level cache SRAM with the address n is split this time, and the first-type splitting remaining data can be used as the data to be merged with the first-type data in the first-level cache SRAM with the address n+1 of the next split.
[0078] At this time, the address n+1 is assigned to n, and then the process returns to step S502a. For example, n+1=2, after the assignment of n, n=2 in S502a, and then step S502a is executed. Until the last single instruction data in the first-level cache SRAM is the end instruction, it means that the instructions in the first-level cache SRAM are read empty.
[0079] In an optional embodiment of the present application, step S502 includes:
[0080] S502f: After S502c, when it is detected that the length of the third type of data is greater than the length of the second type of data, the second type of data is determined as the new first type of split remaining data, and after assigning n+1 to n, jump to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction. In this embodiment, when it is detected that the length of the third type of data is greater than the length of the second type of data, it means that the second type of data is only a part of the third type of data, for example: Figure 7 The second type of data in is the data represented by the last blue box when address n=0. At this time, the data in the next address needs to be split. Therefore, n+1 is assigned to n and then jumps to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction.
[0081] S502g: When it is detected that the length of the second type data after deletion is greater than or equal to the length q of the instruction field type, jump to step S502c.
[0082] In this embodiment, when it is detected that the deleted second type data is greater than or equal to the length q of the instruction type field, it means that the deleted second type data contains at least one instruction type field data, and there may be a complete and divisible single instruction data, so step S502c needs to be executed again at this time to further determine whether there is a complete single instruction data.
[0083] In this embodiment, when the data in the first-level cache SRAM is read out, the splitting ends.
[0084] S503: In each clock cycle, the CCU is controlled to read a single instruction data from the secondary cache SRAM and decode the single instruction data according to a preset instruction format to obtain parsed data and a target node until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU.
[0085] In this embodiment, controlling the CCU to read a single instruction data from the secondary cache SRAM in each clock cycle means reading each single instruction data in the secondary cache SRAM one by one, that is, a single instruction data will be read in each clock cycle, and there will be no empty reading, that is, a control signal will be output in each clock cycle until the single instruction data is the end instruction, which also means that the single instruction data in the secondary cache SRAM is read empty, and the full-pipeline output control signal is achieved, thereby making the output control flow tightly arranged, thereby improving the efficiency of the control instruction output. For example: Figure 8As shown, the DSU instruction in the L2 cache SRAM address 0 is read out first, then the CRU instruction in the L2 cache SRAM address 1 is read out, and the DCU instruction in the L2 cache SRAM address 2 is read out, and so on, until the data in the L2 cache SRAM is read out. Parsed data refers to the information related to the instruction field obtained after parsing a single instruction data. The target node can be the next or next batch of node units whose control flow data needs to be sent by the CCU. For example: the target node can be CRU and DSU.
[0086] In this embodiment, the decoding process refers to parsing each single instruction data to obtain data related to the corresponding ciphertext computing instruction.
[0087] Based on the above embodiment, in an optional embodiment of the present application, after step S503, the following is further included:
[0088] S504: Control the CCU to package the parsed data into control flow data and send it to the target node, so that the target node performs encoding matching processing on the control flow data. If a successful match is detected, the ciphertext calculation instruction is executed according to the control flow data.
[0089] In this embodiment, the control flow data refers to the parsed data with code obtained after parsing. After the CCU sends the control flow data to each unit, each unit will match the code. If a match is detected, the unit will execute the ciphertext calculation instruction corresponding to the control flow data.
[0090] In an optional embodiment of the present application, the target node is at least one unit among CRU, DSU and OCU, the CRU level includes at least one, each level of CRU corresponds to a first code, the DSU connected to the CRU of each level corresponds to the second code of the level, and the OCU connected to the CRU of each level corresponds to the third code of the level; the first code, second code and third code corresponding to each level are the same, or the target node represented by each code in the first code, the second code and the third code is unique.
[0091] In this embodiment, the encoding method of CRU, DSU and OCU of each level of the target node is as follows: Figure 4 The embodiment shown has been described, so this embodiment will not be described again here.
[0092] Fig.10 This is a schematic diagram of the arrangement of control flow data output during instruction parsing provided in an embodiment of the present application. Fig.10As shown, each single instruction data can be parsed and processed to obtain a control flow data, and the control flow data obtained from adjacent single instruction data are also closely adjacent. This allows the CCU to output a control flow data in each clock cycle, allowing the output control flow data to be closely arranged, thereby improving the efficiency of instruction output.
[0093] In an optional embodiment of the present application, in step S504, the control CCU is controlled to package the parsed data into control flow data and send it to the target node so that the target node performs encoding matching processing on the control flow data. It also includes: if a match failure is detected, the control CCU is returned to read the single instruction data of the next address from the secondary cache SRAM and decode the single instruction data according to the preset instruction format.
[0094] In this embodiment, if the match fails, it means that an error occurs in the decoding process, and the encoding in the control stream data to be encoded obtained by parsing is incorrect, and the decoding process needs to be performed again.
[0095] In summary, the ciphertext computing instruction processing method provided in the embodiment of the present application is applied to a ciphertext computing accelerator connected by coding matching. After receiving the ciphertext computing instruction sent by the host computer, the space of the ciphertext computing instruction is saved by using the variable length instruction method, thereby reducing the transmission time of the ciphertext computing instruction. The full pipeline parsing of the ciphertext computing variable length instruction is then realized through the double cache structure of the first-level cache SRAM and the second-level cache SRAM, thereby improving the parsing efficiency of the ciphertext instruction. And each clock cycle CCU can output a parsed control flow data and a target node that can execute the control flow data until a single instruction data is an end instruction, and the storage, reading and parsing speed of the ciphertext computing instruction are improved by using the double cache structure and the full pipeline parsing method, so as to achieve the purpose of improving the processing efficiency of the ciphertext computing instruction.
[0096] Fig.11 A schematic diagram of the structure of a ciphertext computing instruction processing device provided in an embodiment of the present application, the device is applied to Figure 3 The ciphertext computing accelerator 302 shown includes: a receiving module 1101, a splitting module 1102 and a parsing module 1103.
[0097] The receiving module 1101 is used to receive the ciphertext calculation instruction sent by the host computer according to the preset bus width, and store the ciphertext calculation instruction into the first-level cache SRAM according to the preset first-level cache data structure;
[0098] The splitting module 1102 is used to control the CCU to read the bus-width ciphertext instruction from the first-level cache SRAM and split it into single instruction data, and then split all the single instruction data, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths;
[0099] The parsing module 1003 is used to control the CCU to read a single instruction data from the secondary cache SRAM in each clock cycle and decode the single instruction data according to a preset instruction format to obtain parsed data and a target node until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU;
[0100] In an optional embodiment of the present application, the address occupied by the instruction type field is q bits, where q is a preset bit width value; accordingly, the splitting module 1102 is specifically used to: control the CCU to read the bus bit width ciphertext instruction from the first-level cache SRAM and split it into single instruction data, including: S502a: control the CCU to read the first type of data corresponding to the bus bit width from the first-level cache SRAM with a read address of n, where n is an address value starting from 0 as an initial value; S502b: merge the first type of data and the first type of split remaining data in the first-level cache SRAM with an address of n-1 into second type data, and when n-1 is less than 0, the second type of data is equal to the first type of data; S502c: extract the q bits at the front from the second type of data Instruction type field, parse the instruction type field to obtain the third type data with an effective length of s; S502d: when it is detected that the length of the third type data is less than or equal to the length of the second type data, the third type data is determined as a single instruction data to be written into the secondary cache SRAM and written into the secondary cache SRAM, and the third type data is deleted from the second type data to obtain the deleted second type data; S502e: when it is detected that the length of the deleted second type data is less than the length q of the instruction type field, the deleted second type data is determined as the new first type split remaining data, and after assigning n+1 to n, jump to step S502a, until the last single instruction data in the first level cache SRAM is the end instruction.
[0101] In an optional embodiment of the present application, the splitting module 1102 is specifically used for: after S502c, when it is detected that the length of the third type of data is greater than the length of the second type of data, the second type of data is determined as the remaining data of the first type split, and after assigning n+1 to n, jumping to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction; or after S502d, when it is detected that the length of the deleted second type of data is greater than or equal to the length q of the instruction field type, jumping to step S502c.
[0102] In an optional embodiment of the present application, the splitting module 1102 is further used to: when it is detected that the read address is n=0, directly skip step S502b and execute step S502c.
[0103] In an optional embodiment of the present application, the parsing module 1103 is also used to: control the CCU to package the parsed data into control flow data and send it to the target node, so that the target node can perform encoding matching processing on the control flow data, and if a successful match is detected, execute the ciphertext calculation instructions according to the control flow data.
[0104] In an optional embodiment of the present application, the parsing module 1103 is further used for: the target node is at least one unit among CRU, DSU and OCU, the CRU level includes at least one, each level of CRU corresponds to a first code, the DSU connected to the CRU of each level corresponds to the second code of the level, and the OCU connected to the CRU of each level corresponds to the third code of the level; the first code, the second code and the third code corresponding to each level are the same, or the target node represented by each code in the first code, the second code and the third code is unique.
[0105] In an optional embodiment of the present application, the parsing module 1103 is further specifically used to: if a match failure is detected, return to the step of controlling the CCU to read the single instruction data of the next address from the secondary cache SRAM and decode the single instruction data according to a preset instruction format. The ciphertext computing instruction processing device provided in this embodiment can be used to execute the technical solution of the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated in this embodiment.
[0106] Fig.12 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.12 As shown, the electronic device includes: at least one processor 1201 and a memory 1202 .
[0107] The memory 1202 is used to store computer-executable instructions.
[0108] The processor 1201 is used to execute the computer-executable instructions stored in the memory 1202 to implement the various steps involved in the above method embodiment. For details, please refer to the relevant description in the above method embodiment.
[0109] Optionally, the memory 1202 may be independent or integrated with the processor 1201 .
[0110] When the memory 1202 is independently provided, the electronic device further includes a bus 1203 for connecting the memory 1202 and the processor 1201 .
[0111] An embodiment of the present application also provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed, the above-mentioned ciphertext calculation instruction processing method is implemented.
[0112] In this embodiment, the computer execution instruction may be Fig.12 The processor shown or Figure 4 The deployment shown is performed by a ciphertext computing accelerator server or a computer device. There is no limit on the specific execution subject.
[0113] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned ciphertext computing instruction processing method when executed by a processor.
[0114] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0115] The modules described above as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0116] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each module may exist physically separately, or two or more modules may be integrated into one unit. The unit composed of the above modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0117] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method of each embodiment of the present application.
[0118] It should be understood that the above processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0119] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0120] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0121] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0122] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.
[0123] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0124] The present invention is intended to illustrate the technical solution of the present application rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solution from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A ciphertext computing accelerator, characterized in that: include: Ciphertext calculation control unit CCU, ciphertext calculation routing unit CRU, ciphertext data storage unit DSU and ciphertext operator calculation unit OCU; The CCU, CRU, DSU and OCU are connected by coding matching, the CCU is connected to the host computer, the CRU has at least one level, each level of CRU corresponds to a layer number and is connected to a DSU and an OCU, and the DSU and OCU corresponding to each level receive the control flow data sent by the CCU through the CRU; Any of the CCU, CRU, DSU and OCU can receive control flow data sent by the upper level unit and forward the control flow data to the lower level unit; The control flow data is obtained after parsing and compiling a single instruction data, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths; The CCU is used to read out the bus-width ciphertext instructions from the ciphertext computing instructions stored in the first-level cache SRAM according to the preset first-level cache data structure and split them into single instruction data, and then write all the single instruction data into the second-level cache SRAM according to the preset second-level cache data structure; The CCU is also used to read a single instruction data from the secondary cache SRAM in each clock cycle, and decode the single instruction data according to a preset instruction format to obtain parsed data and a target node, until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU; The address occupied by the instruction type field is q bits, where q is a preset bit width value; The CCU is specifically used for S502a: reading the first type of data corresponding to the bus width from the first-level cache SRAM with a read address of n, wherein n is an address value starting from 0 as an initial value; S502b: merging the first type of data and the first type of split remaining data in the first-level cache SRAM with an address of n-1 into second type of data, and when n-1 is less than 0, the second type of data is equal to the first type of data; S502c: extracting the instruction type field located at the front q bits from the second type of data, parsing the instruction type field, and obtaining the third type of data with an effective length of s; S502d: when it is detected If the length of the third type of data is less than or equal to the length of the second type of data, the third type of data is determined as a single instruction data to be written into the secondary cache SRAM and written into the secondary cache SRAM, and the third type of data is deleted from the second type of data to obtain the deleted second type of data; S502e: when it is detected that the length of the deleted second type of data is less than the instruction type field length q, the deleted second type of data is determined as the new first type of split remaining data, and after assigning n+1 to n, jump to step S502a until the last single instruction data in the primary cache SRAM is the end instruction.
2. A method for processing ciphertext computing instructions, characterized in that: Applied to the ciphertext computing accelerator according to claim 1, the ciphertext computing accelerator is communicatively connected to a host computer, and the method comprises: Receiving the ciphertext calculation instruction sent by the host computer according to the preset bus width, and storing the ciphertext calculation instruction in the first-level cache SRAM according to the preset first-level cache data structure; Control the CCU to read the bus-width ciphertext instruction from the primary cache SRAM and split it into single instruction data, and then write all the single instruction data into the secondary cache SRAM according to a preset secondary cache data structure, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field, and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths; Controlling the CCU to read a single instruction data from the secondary cache SRAM in each clock cycle, and decoding the single instruction data according to a preset instruction format to obtain parsed data and a target node, until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU; The address occupied by the instruction type field is q bits, where q is a preset bit width value; Accordingly, the control CCU reads the bus width ciphertext instruction from the first-level cache SRAM and splits it into single instruction data, including: S502a: Control the CCU to read the first type of data of the corresponding bus width from the first-level cache SRAM with a read address of n, where n is an address value starting from 0 as an initial value; S502b: merge the first type of data and the first type of split remaining data in the first level cache SRAM at address n-1 into second type of data, and when n-1 is less than 0, the second type of data is equal to the first type of data; S502c: extracting the instruction type field located at the front q bits from the second type data, parsing the instruction type field, and obtaining the third type data with an effective length of s; S502d: When it is detected that the length of the third type of data is less than or equal to the length of the second type of data, the third type of data is determined as a single instruction data to be written into the secondary cache SRAM and written into the secondary cache SRAM, and the third type of data is deleted from the second type of data to obtain the deleted second type of data; S502e: When it is detected that the length of the deleted second type data is less than the instruction type field length q, the deleted second type data is determined as the new first type split remaining data, and after n+1 is assigned to n, jump to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction.
3. The method according to claim 2, characterized in that The control CCU reads the bus width ciphertext instruction from the first-level cache SRAM and splits it into single instruction data, including: After S502c, when it is detected that the length of the third type of data is greater than the length of the second type of data, the second type of data is determined as the remaining data of the first type of splitting, and after n+1 is assigned to n, the process jumps to step S502a until the last single instruction data in the first-level cache SRAM is the end instruction; or After S502d, when it is detected that the length of the deleted second type data is greater than or equal to the length q of the instruction field type, jump to step S502c.
4. The method according to claim 2, characterized in that: The controlling CCU to read the bus width ciphertext instruction from the first level cache SRAM and split it into single instruction data also includes: When it is detected that the read address is n=0, step S502b is directly skipped and step S502c is executed.
5. The method according to claim 2, characterized in that: After each clock cycle controls the CCU to read a single instruction data from the secondary cache SRAM and decodes the single instruction data according to a preset instruction format to obtain parsed data and a target node, the method further includes: The control CCU packages the parsed data into control flow data and sends it to the target node, so that the target node performs encoding matching processing on the control flow data, and executes the ciphertext calculation instruction according to the control flow data if a successful match is detected.
6. The method according to claim 5, characterized in that The target node is at least one of a CRU, a DSU and an OCU, the CRU comprises at least one level, each level of the CRU corresponds to a first code, the DSU connected to the CRU of each level corresponds to a second code of the level, and the OCU connected to the CRU of each level corresponds to a third code of the level; The first code, the second code and the third code corresponding to each level are the same, or the target node represented by each code in the first code, the second code and the third code is unique.
7. The method according to any one of claims 5 to 6, characterized in that After the control CCU packages the parsed data into control flow data and sends it to the target node so that the target node performs encoding matching processing on the control flow data, the method further includes: If a match failure is detected, the process returns to the step of controlling the CCU to read out a single instruction data of a next address from the secondary cache SRAM and decoding the single instruction data according to a preset instruction format.
8. A ciphertext computing instruction processing device, characterized in that: Applied to the ciphertext computing accelerator according to claim 1, the ciphertext computing accelerator is communicatively connected to a host computer, and the device comprises: A receiving module, used for receiving the ciphertext calculation instruction sent by the host computer according to the preset bus bit width, and storing the ciphertext calculation instruction into the first-level cache SRAM according to the preset first-level cache data structure; A splitting module, used to control the CCU to read the bus-width ciphertext instruction from the first-level cache SRAM and split it into single instruction data, and then write all the single instruction data into the second-level cache SRAM according to a preset second-level cache data structure, wherein the single instruction data includes an instruction type field, an instruction encoding field, an instruction time field and an instruction parameter field, and the single instruction data corresponding to different instruction type fields occupy different bit widths; A parsing module, used for controlling the CCU to read a single instruction data from the secondary cache SRAM in each clock cycle, and decoding the single instruction data according to a preset instruction format to obtain parsed data and a target node, until the single instruction data is an end instruction, wherein the target node is at least one unit among the CRU, DSU and OCU; The address occupied by the instruction type field is q bits, where q is a preset bit width value; The splitting module is specifically used for S502a: controlling the CCU to read the first type of data of the corresponding bus width from the first-level cache SRAM with a read address of n, wherein n is an address value starting from 0 as an initial value; S502b: merging the first type of data and the first type of split remaining data in the first-level cache SRAM with an address of n-1 into second type of data, and when n-1 is less than 0, the second type of data is equal to the first type of data; S502c: extracting the instruction type field located at the front q bits from the second type of data, parsing the instruction type field, and obtaining the third type of data with an effective length of s; S502d: when If it is detected that the length of the third type of data is less than or equal to the length of the second type of data, the third type of data is determined as a single instruction data to be written into the secondary cache SRAM and written into the secondary cache SRAM, and the third type of data is deleted from the second type of data to obtain the deleted second type of data; S502e: When it is detected that the length of the deleted second type of data is less than the instruction type field length q, the deleted second type of data is determined as the new first type of split remaining data, and after assigning n+1 to n, jump to step S502a until the last single instruction data in the primary cache SRAM is the end instruction.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed, the ciphertext computing instruction processing method according to any one of claims 2 to 7 is implemented.
Citation Information
Patent Citations
Encryption and decryption circuit, encryption and decryption equipment and encryption and decryption method
CN109861818A
Data decoding method and device, electronic equipment and storage medium
CN116016943A
Reliability design method of block cipher mode, cipher card and server
CN116073987A
Effective storage for length variable data sequentially stored in storage medum
CN1294387A
Hardware architecture for accelerating torus fully homomorphic encryption(TFHE) with streaming core and folded fully pipelined fft
KR102616119B1
