Data processing method and device, and computer device

By directly forwarding the target data value to the input of the calculation module, the steps of writing and reading data are omitted, which solves the problems of slow calculation speed and large register consumption in traditional multiply-accumulate units, and realizes automatic iterative calculation and improves the degree of automation.

CN116909629BActive Publication Date: 2026-02-24GLENFLY TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310843408.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-10
Publication Date
2026-02-24
Estimated Expiration
2043-07-10

AI Technical Summary

Technical Problem

Traditional multiply-accumulate operators require intermediate result storage and retrieval during calculation, resulting in slow calculation speed and excessive register consumption, which affects execution efficiency.

Method used

By directly forwarding the target data value to the input of the calculation module, the steps of writing and reading data are omitted, and the calculation module automatically iterates and calculates until the target data value that matches the calculation information is obtained.

Benefits of technology

It improves computing speed, reduces register consumption, and enables automatic iterative calculation and automation of the computing module.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116909629B_ABST
    Figure CN116909629B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data processing, in particular to a data processing method and device, computer equipment, a storage medium and a computer program product. The data processing method comprises the following steps: in response to a calculation instruction, source data is acquired; the source data is calculated by using a calculation module to obtain a target data value; when the target data value does not conform to calculation information carried by the calculation instruction, new source data is acquired, and the target data value is forwarded to an input end of the calculation module; the new source data and the target data value are calculated by using the calculation module to obtain a new target data value; when the new target data value conforms to the calculation information, the new target data value is taken as a data calculation result; otherwise, the new source data is continuously acquired until the new target data value conforms to the calculation information, through the setting, register resources can be saved, data writing and reading steps are omitted, and the calculation speed is accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer applications, and in particular to a data processing method, apparatus, computer equipment, storage medium, and computer program product. Background Technology

[0002] With the rapid development of microprocessors, users have increasingly higher requirements for data operations in graphics processing. Microprocessor computation involves a large number of operations. Taking multiplication and addition as an example, to improve the efficiency of data multiplication and addition, multiplication accumulators are typically used to perform multiple consecutive data multiplications and additions. Compared to multipliers and adders, multiplication accumulators not only reduce hardware overhead but also reduce the time required for consecutive multiplication and addition operations.

[0003] However, in the traditional multiply-accumulate instruction, the multiply-accumulate unit needs to store the intermediate multiply-accumulate result in the accumulator (Acc register), and then retrieve the result from the accumulator when performing the next addition. Multiply-accumulate operations involve multiple multiplication and addition operations to obtain the final result. This not only consumes time in storing and retrieving intermediate results but also consumes registers, resulting in a slow execution speed and low efficiency for multiply-accumulate instructions. Summary of the Invention

[0004] Therefore, it is necessary to provide a data processing method, apparatus, computer equipment, storage medium, and computer program product that can improve the response speed of accumulation calculation instructions, in order to address the above-mentioned technical problems.

[0005] Firstly, this application provides a data processing method, including:

[0006] Retrieve source data in response to computation commands;

[0007] The source data is processed using a calculation module to obtain the target data value;

[0008] When the target data value does not conform to the calculation information carried by the calculation instruction, new source data is obtained, and the target data value is forwarded to the input end of the calculation module.

[0009] The calculation module is used to calculate the new source data and the target data value to obtain a new target data value. When the new target data value matches the calculation information, the new target data value is used as the data calculation result. Otherwise, new source data is continuously acquired until the new target data value matches the calculation information.

[0010] In one embodiment, the computing module includes an adder;

[0011] The source data includes at least two sub-source data;

[0012] The step of using a calculation module to calculate the source data to obtain the target data value includes:

[0013] The target data value is obtained by using the adder to calculate at least two of the sub-source data.

[0014] The step of using the calculation module to calculate the new source data and the target data value to obtain the new target data value includes:

[0015] The adder is used to calculate at least two new sub-source data and the target data value to obtain a new target data value.

[0016] In one embodiment, the computing module includes a multiplier;

[0017] The source data includes at least two sub-source data;

[0018] The step of using a calculation module to calculate the source data to obtain the target data value includes:

[0019] The target data value is obtained by using the multiplier to calculate at least two of the sub-source data.

[0020] The step of using the calculation module to calculate the new source data and the target data value to obtain the new target data value includes:

[0021] The multiplier is used to calculate at least two new sub-source data and the target data value to obtain a new target data value.

[0022] In one embodiment, the computing module includes a multiply-accumulate unit;

[0023] The source data includes at least two sub-source data;

[0024] The step of using a calculation module to calculate the source data to obtain the target data value includes:

[0025] The multiply accumulator is used to perform multiplication on at least two sub-source data to obtain the accumulated value as the target data value;

[0026] The step of using the calculation module to calculate the new source data and the target data value to obtain the new target data value includes:

[0027] The multiply accumulator is used to perform multiplication on at least two new sub-source data to obtain a new cumulative multiplication value;

[0028] The multiply-accumulator is used to perform addition calculations on at least two new sub-source data and a new cumulative value to obtain a new target data value.

[0029] In one embodiment, the method further includes:

[0030] The calculation module is monitored in real time, and when the calculation module calculates the target data value, the actual number of calculations is incremented by one;

[0031] The calculation information includes the target number of calculations;

[0032] When the target data value does not conform to the calculation information carried by the calculation instruction, acquiring new source data and forwarding the target data value to the input of the calculation module includes:

[0033] When the actual number of calculations does not match the target number of calculations, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0034] In one embodiment, when the actual number of calculations meets the target number of calculations, the target data value obtained by the calculation module in the last calculation is used as the data calculation result.

[0035] In one embodiment, the step of acquiring source data in response to a calculation instruction includes:

[0036] In response to the calculation instruction, a preset amount of source data is obtained;

[0037] After the calculation module calculates the source data to obtain the target data value, the method further includes:

[0038] When new source data is available, a preset number of new source data are acquired, and the target data value is forwarded to the input of the calculation module until no new source data is available.

[0039] Secondly, this application also provides a data computing device, comprising:

[0040] The acquisition module is used to acquire source data in response to calculation instructions;

[0041] The calculation module is used to calculate the source data to obtain the target data value.

[0042] The forwarding module is used to obtain new source data and forward the target data value to the input terminal of the calculation module when the target data value does not conform to the calculation information carried by the calculation instruction.

[0043] The result determination module is used to perform calculations on the new source data and the target data value using the calculation module to obtain a new target data value. When the new target data value matches the calculation information, the new target data value is used as the data calculation result. Otherwise, new source data is continuously acquired until the new target data value matches the calculation information.

[0044] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the data processing method described in any of the above embodiments.

[0045] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the data processing method described in any of the above embodiments.

[0046] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the data processing method described in any of the above embodiments.

[0047] The aforementioned data processing methods, apparatus, computer equipment, storage media, and computer program products can directly transmit target data values ​​to the input end of the calculation module, reducing register consumption and eliminating the steps of writing data to and reading data from registers, thus accelerating the calculation speed. The calculation module can automatically obtain the target data value that meets the calculation information by performing calculations on new source data and target source data, realizing automatic iterative calculation of the calculation module and improving the automation level of data calculation. Attached Figure Description

[0048] Figure 1 This is a flowchart illustrating a data processing method in one embodiment;

[0049] Figure 2 This is a schematic diagram of the processing flow of a common computing module;

[0050] Figure 3 This is a schematic diagram of the structure of a common computing module;

[0051] Figure 4 This is a schematic diagram of the structure of the computing module in a data processing method in one embodiment;

[0052] Figure 5 This is a timing diagram of common computing modules;

[0053] Figure 6 This is a timing diagram of the computation module in a data processing method in one embodiment;

[0054] Figure 7 This is a structural block diagram of a data computing device in one embodiment;

[0055] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0057] The data processing method provided in this application can be applied to an Arithmetic Logic Unit (ALU), a major component of the central processing unit (CPU). It is capable of performing arithmetic and logical operations, including all processes related to these operations such as addition, subtraction, and shift operations, as well as Boolean comparisons (XOR, OR, AND, and NOT operations). Furthermore, binary numbers can be processed using the ALU for both mathematical and bitwise operations. The ALU is divided into an AU (Arithmetic Unit) and a LU (Logic Unit). The operands and codes used by the ALU tell it which operations must be performed based on the input data. After the ALU completes its calculations, the results are sent to the server's data storage unit for storage.

[0058] In one embodiment, a data processing method is provided, such as Figure 1 As shown, the data processing method includes:

[0059] Step 202: In response to the calculation command, obtain the source data.

[0060] A calculation instruction refers to a command that performs calculations on data. This instruction can be entered by the user through a terminal or automatically triggered by the server. For example, when source data exists in a specific storage location on the server, a calculation instruction can be automatically generated to perform calculations on the source data.

[0061] Source data can refer to input data such as floating-point numbers or integers. Source data can be input by the user through the terminal, or it can be obtained by upstream steps in an automated processing flow. For example, the automated processing flow automatically collects the number of target objects, and the number of target objects can be directly used as the source data in step 202.

[0062] As an example, a calculation instruction carries a data tag, which can be composed of at least one of letters, characters, or numbers, used to identify the source data corresponding to the calculation instruction. The ALU can pre-store the correspondence between data tags and source data. One data tag can correspond to at least one source data. When the ALU receives a calculation instruction, it can match the source data corresponding to the calculation instruction from the pre-stored correspondence based on the data tag carried by the calculation instruction.

[0063] In this embodiment, the ALU receives the calculation instruction and obtains the source data corresponding to the calculation instruction based on the data tag carried by the calculation instruction. Through this setting, the target source data can be quickly matched and automatically extracted.

[0064] Step 204: Use the calculation module to calculate the source data to obtain the target data value.

[0065] The calculation module refers to the module in the ALU that is responsible for all processes related to arithmetic and logical operations. The calculation module is used to perform calculations on the source data, and the calculation content can include addition, subtraction, multiplication, division, and accumulation of multiplication.

[0066] The target data value refers to the value output after the source data is input into the calculation module for calculation and processing.

[0067] In this embodiment, the ALU inputs the source data into the calculation module and uses the calculation module to process the source data to obtain the target data value.

[0068] Step 206: When the target data value does not match the calculation information carried by the calculation instruction, obtain new source data and forward the target data value to the input end of the calculation module.

[0069] The calculation information can refer to a pre-defined numerical range, which can be the range of the target data value or the range of the number of calculations performed by the calculation module after receiving the calculation instruction.

[0070] The new source data can be input by the user through the terminal or obtained by the upstream steps in the automatic processing flow. The source data in step 202 and the new source data in step 206 can be distinguished by their storage locations.

[0071] As an example, the calculation instruction carries multiple data tags arranged in sequence. The ALU pre-stores the correspondence between the data tags and the source data. When the ALU receives the calculation instruction, it first retrieves a preset number of data tags from the sequentially arranged data tags carried by the instruction, and then matches them with the source data in step 202 from the pre-stored correspondence. Subsequently, if the target data value does not match the calculation instruction, it retrieves another preset number of data tags from the remaining data tags and matches them with the new data source from the correspondence, and so on. The data tags used to retrieve the source data in step 202 and the data tags used to retrieve the new source data in step 206 are arranged sequentially and do not overlap.

[0072] like Figure 2 As shown, typically, after the calculation module obtains the target data value, the ALU first writes the target data value into a register for data storage. Then, it checks whether the target data value matches the calculation information. If it doesn't, the ALU reads the target data value from the register and inputs it into the calculation module for the next iteration. This process stores intermediate calculation results in registers, which involves writing and reading the target data value. This not only increases register consumption but also reduces the ALU's data processing speed.

[0073] In this embodiment, after determining that the target data value does not conform to the calculation information, the ALU directly forwards the target data value to the input of the calculation module instead of writing it to the register. This omits the data writing and reading steps, and at the same time, it obtains new source data according to the remaining data tags. Through this setting, the calculation speed of the ALU is accelerated, register resources are saved, automatic iterative calculation of the calculation module is realized, and the degree of automation of data calculation is improved.

[0074] Step 208: Use the calculation module to calculate the new source data and target data values ​​to obtain the new target data value; when the new target data value matches the calculation information, use the new target data value as the data calculation result; otherwise, continue to acquire new source data until the new target data value matches the calculation information.

[0075] After the ALU obtains new source data based on the remaining data tags, it inputs this new source data into the input terminal of the calculation module. The calculation module processes the target data value calculated in step 204 and the new source data to obtain a new target data value. The ALU then determines whether the new target data value conforms to the calculation information. If it does, the ALU performs data standardization on the new target data value and writes the standardized target data value as the calculation result into a designated register, completing the data processing. If it does not conform, the ALU inputs the new target data value into the input terminal of the calculation module again and continues to obtain new source data based on the remaining data tags, repeating the calculation to obtain the target data value. The ALU obtains the target data value that conforms to the calculation information by repeating this process.

[0076] In the above data processing method, the ALU can automatically match and obtain the corresponding source data according to the received calculation instructions, thereby realizing the rapid matching and automatic extraction of target source data; the calculation module calculates the source data to obtain the target data value for automatic calculation processing of the source data; the calculation information is obtained from the calculation instructions, and when the target data value does not conform to the calculation information, new source data can be automatically obtained again, and the target data value is directly forwarded to the input end of the calculation module to omit the data writing and reading steps, speed up the calculation speed of the ALU, and save register resources. The calculation module calculates the new source data and the target source data to obtain new target source data to complete the iterative calculation of the target source data to obtain the target data value that meets the calculation information. This setting realizes the automatic iterative calculation of the calculation module and improves the automation level of data calculation.

[0077] In some alternative embodiments, the computation module includes an adder;

[0078] The source data includes at least two sub-source data;

[0079] Step 204 includes:

[0080] An adder is used to calculate at least two sub-source data to obtain the target data value;

[0081] Step 208 includes:

[0082] An adder is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0083] An adder can add two binary numbers. In this embodiment, the target data value is the sum of the two sub-source data. When the target data value obtained in step 204 does not conform to the calculation information, the ALU obtains new sub-source data and adds the new sub-source data and the target data value to obtain a new target data value.

[0084] As an example, the ALU inputs two source data A and B into the adder to obtain the target data value A+B. When the target data value A+B does not meet the calculation information, the ALU re-inputs the target data value A+B into the adder and obtains new source data C and D into the adder. The adder adds the target data value A+B and the new source data C and D to obtain the new target data value A+B+C+D, and so on.

[0085] In another embodiment, after receiving a calculation instruction, the ALU acquires at least two sub-source data. If the target data value obtained from the first calculation does not conform to the calculation information, the ALU acquires a new sub-source data. Step 208 then includes: using an adder to calculate the new sub-source data and the target data value to obtain a new target data value. For example, the ALU inputs two sub-source data A and B into the adder to obtain the target data value A+B. When the target data value A+B does not conform to the calculation information, the ALU re-inputs the target data value A+B into the adder and acquires a new sub-source data C, which is then input into the adder. The adder adds the target data value A+B and the new sub-source data C to obtain a new target data value A+B+C, and so on.

[0086] In this embodiment, the adder in the ALU achieves automatic calculation, automatic judgment, and automatic iteration, thereby improving the automation level of the adder.

[0087] In some alternative embodiments, the computation module includes a multiplier;

[0088] The source data includes at least two sub-source data;

[0089] Step 204 includes:

[0090] The target data value is obtained by using a multiplier to calculate at least two sub-source data.

[0091] Step 208 includes:

[0092] A multiplier is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0093] A multiplier can multiply two binary numbers. It is composed of a more basic adder. In this embodiment, the target data value is the product of two sub-source data. When the target data value obtained in step 204 does not conform to the calculation information, the ALU obtains new sub-source data and multiplies the new sub-source data with the target data value to obtain a new target data value.

[0094] As an example, the ALU inputs two source data A and B into the multiplier to obtain the target data value A*B. When the target data value A*B does not conform to the calculation information, the ALU re-inputs the target data value A*B into the multiplier and obtains new source data C and D into the multiplier. The multiplier multiplies the target data value A*B with the new source data C and D to obtain a new target data value A*B*C*D, and so on.

[0095] In another embodiment, after receiving a calculation instruction, the ALU acquires at least two sub-source data. If the target data value obtained from the first calculation does not conform to the calculation information, the ALU acquires a new sub-source data. Step 208 then includes: using a multiplier to calculate the new sub-source data and the target data value to obtain a new target data value. For example, the ALU inputs two sub-source data A and B into the multiplier to obtain the target data value A*B. When the target data value A*B does not conform to the calculation information, the ALU re-inputs the target data value A*B into the multiplier and acquires a new sub-source data C, which is then input into the multiplier. The multiplier multiplies the target data value A*B and the new sub-source data C to obtain a new target data value A*B*C, and so on.

[0096] In this embodiment, the multiplier in the ALU achieves automatic calculation, automatic judgment, and automatic iteration, thereby improving the automation level of the multiplier.

[0097] In some optional embodiments, the computation module includes a multiply-accumulate unit;

[0098] The source data includes at least two sub-source data;

[0099] Step 204 includes:

[0100] A multiply accumulator is used to perform multiplication on at least two sub-source data, and the accumulated value is used as the target data value.

[0101] Step 208 includes:

[0102] A multiply accumulator is used to multiply at least two new sub-source data to obtain a new cumulative value;

[0103] A multiply-accumulator is used to add at least two new sub-source data and a new cumulative value to obtain a new target data value.

[0104] A multiply-accumulate unit consists of an adder and a multiplier, with the output of the multiplier connected to the input of the adder. It can input the product of the multiplier's output along with another value into the adder to obtain the calculation result.

[0105] like Figure 3As shown, typically, the multiply-accumulate takes two source data A and B as inputs to the multiplier, and the resulting product A*B is input to the adder. The adder simultaneously reads data Z from the ACC register. The adder adds the product A*B to the data Z to obtain the target data value. Then, the target data value output by the adder is written back to the ACC register, and the target data value is normalized before being output.

[0106] In step 204 of this embodiment, the target data value is the product of the two sub-source data. During the first calculation of the target data value, the input of the adder in the multiplication accumulator only has the accumulated product value output by the multiplier. Therefore, the adder directly uses the accumulated product value as the target data value. When the target data value does not meet the calculation information, the ALU obtains the two sub-source data again and inputs them into the multiplier. The multiplier calculates a new accumulated product value and inputs it into the input of the adder. At the same time, the ALU forwards the target data value output by the adder for the first time directly to the input of the adder. The adder adds the target data value and the new accumulated product value to obtain a new target data value, and so on.

[0107] like Figure 4 As shown in the example, the ALU inputs two sub-source data A and B into the multiplier of the multiplier-accumulator to obtain the accumulated value A*B, which is then input into the adder of the multiplier-accumulator. The adder only receives the accumulated value A*B at this point, so it directly outputs A*B as the target data value. When the target data value A*B does not meet the calculation information, the ALU obtains new sub-source data C and D and inputs them into the multiplier to obtain a new accumulated value C*D. At the same time, the ALU transmits the target data value A*B to the input of the adder as data Z through the forwarding channel. The adder then receives the new accumulated value C*D and the target data value A*B, and adds the two to obtain a new target data value A*B+C*D, and so on.

[0108] In this embodiment, the ALU can directly forward the target data value output by the adder to the input of the adder, eliminating the writing and reading steps of the ACC register and speeding up the data processing speed.

[0109] In some optional embodiments, the data processing method further includes:

[0110] The real-time detection and calculation module increments the actual number of calculations by one when it calculates the target data value.

[0111] The calculation information includes the target number of calculations;

[0112] Step 206 includes:

[0113] When the actual number of calculations does not match the target number of calculations, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0114] The target number of calculations refers to the number of loop calculations. When the calculation module includes a multiply-accumulate unit, the target number of calculations represents the number of loop calculations performed by the multiply-accumulate unit.

[0115] The actual number of calculations refers to the number of times the calculation module actually performs the calculations in a loop.

[0116] like Figure 5 As shown, when the calculation module is a multiply-accumulate, and the calculation instruction received by the ALU contains a target number of calculations of 4, the ALU includes 5 stages OPFO, EX0, EX1, EX2 and WB in each multiply-accumulate operation. If each stage requires 1 cycle, then performing four multiply-accumulate operations requires 8 cycles.

[0117] As an example, when the calculation module is a multiplication accumulator, and the calculation instruction received by the ALU contains a target number of calculations of 4, it means that the multiplication accumulator needs to perform four multiplication-addition operations in a loop. The first multiplication-addition operation includes: the ALU first sets the actual calculation count rpt to 0, and inputs two sub-source data A and B into the multiplier in the multiplication accumulator, obtaining the accumulated product A*B, which is then input into the adder. The adder only receives the accumulated product A*B at this point, so it directly outputs A*B as the target data value. At this time, the ALU updates the actual calculation count rpt to 1. It can be seen that the actual calculation count rpt does not match the target number of calculations. The second multiplication-addition operation continues; the second multiplication-addition operation includes: the ALU acquiring new sub-source data C and D and inputting them into the multiplier to obtain a new accumulated multiplication value C*D. Simultaneously, the ALU transmits the target data value A*B to the input of the adder as data Z through the forwarding channel. The adder then receives the new accumulated multiplication value C*D and the target data value A*B, and adds them together to obtain a new target data value A*B+C*D. At this point, the ALU updates the actual number of calculations rpt to 2. Since the actual number of calculations rpt does not match the target number of calculations, the third multiplication-addition operation continues; the third multiplication-addition operation includes: AL The ALU acquires new source data E and F and inputs them into the multiplier to obtain a new cumulative multiplication value E*F. Simultaneously, the ALU transmits the target data value A*B+C*D to the adder's input as data Z via the forwarding channel. The adder then receives the new cumulative multiplication value E*F and the target data value A*B+C*D, and adds them together to obtain the new target data value A*B+C*D+E*F. At this point, the ALU updates the actual computation count rpt to 3. Since the actual computation count rpt does not match the target computation count, a fourth multiplication-addition operation is performed. The fourth multiplication-addition operation includes: the ALU acquiring new source data G, ... Input H to the multiplier to obtain a new accumulated multiplication value G*H. Simultaneously, the ALU transmits the target data value A*B+C*D+E*F to the adder's input as data Z via the forwarding channel. The adder now receives the new accumulated multiplication value G*H and the target data value A*B+C*D+E*F, and adds them to obtain the new target data value A*B+C*D+E*F+G*H. At this point, the ALU updates the actual number of calculations rpt to 4. Since the actual number of calculations rpt matches the target number of calculations, A*B+C*D+E*F+G*H is used as the calculation result, standardized, and then output. For example... Figure 6 As shown, compared with the common multiply-accumulate, the forwarding-based multiply-accumulate eliminates the ACC register, reducing register consumption.

[0118] In some optional embodiments, the data processing method further includes:

[0119] When the actual number of calculations matches the target number of calculations, the target data value obtained from the last calculation by the calculation module will be used as the data calculation result.

[0120] In this embodiment, when the calculation instruction received by the ALU contains a target number of calculations of 1, the calculation module only needs to perform one loop calculation.

[0121] As an example, when the calculation module is a multiply-accumulate, and the calculation instruction received by the ALU contains a target number of calculations of 1, it means that the multiply-accumulate needs to perform a multiply-add operation once. The first multiply-add operation includes: the ALU first counts the actual number of calculations rpt to 0, and inputs the two sub-source data A and B into the multiplier in the multiply-accumulate to obtain the accumulated multiplication value A*B, which is then input into the input of the adder in the multiply-accumulate. The adder only receives the accumulated multiplication value A*B at this time, so it directly outputs A*B as the target data value. At this time, the ALU updates the actual number of calculations rpt to 1. It can be seen that the actual number of calculations rpt has met the target number of calculations, so there is no need to perform the second multiply-add operation. At this time, the target data value A*B is the final data calculation result.

[0122] In some alternative embodiments, step 202 includes:

[0123] In response to the calculation instruction, a preset amount of source data is obtained;

[0124] Following step 204, the following also includes:

[0125] When new source data is available, a preset number of new source data are acquired, and the target data value is forwarded to the input of the calculation module until no new source data is available.

[0126] In this embodiment, the calculation instruction can refer to at least one source data. When the calculation instruction is an instruction to perform calculations on the data in a specific data packet, the source data refers to all the data contained in the specific data packet. At this time, the amount of source data can be understood as having been preset.

[0127] New source data refers to source data that is referred to by computation instructions but has not yet been acquired by the ALU.

[0128] As an example, the preset quantity can be two. A specific data packet contains data A, B, C, and D. In step 202, the ALU first obtains two source data A and B from the specific data packet and performs calculations. At this point, the ALU determines that new source data C and D exist in the specific data packet. The ALU then continues to obtain a preset number of new source data C and D and perform calculations. Finally, the ALU determines that no new source data exists in the specific data packet and ends the calculation. This data processing method can directly transmit the target data value to the input of the adder through the forwarding channel. The forwarding-based multiply-accumulate eliminates the ACCregister, reducing register consumption. It also omits the steps of writing data to and reading data from registers, thus accelerating the ALU's calculation speed. The calculation module can automatically obtain the target data value that satisfies the calculation information by calculating the new source data and the target source data, realizing iterative calculation of the target data. This setting enables automatic iterative calculation of the calculation module, improving the automation level of data calculation.

[0129] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0130] Based on the same inventive concept, this application also provides a data computing device for implementing the data processing method described above. The solution provided by this device is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more data computing device embodiments provided below can be found in the limitations of the data processing method described above, and will not be repeated here.

[0131] In one embodiment, such as Figure 7As shown, a data calculation device 700 is provided, including an acquisition module 702, a calculation module 704, a forwarding module 706, and a result determination module 708. The acquisition module 702 is used to acquire source data in response to a calculation instruction; the calculation module 704 is used to perform calculations on the source data to obtain a target data value; the forwarding module 706 is used to acquire new source data and forward the target data value to the input terminal of the calculation module when the target data value does not conform to the calculation information carried by the calculation instruction; the result determination module 708 is used to perform calculations on the new source data and the target data value to obtain a new target data value; when the new target data value conforms to the calculation information, the new target data value is used as the data calculation result; otherwise, new source data is continuously acquired until the new target data value conforms to the calculation information.

[0132] In some alternative embodiments, the computation module includes an adder;

[0133] The source data includes at least two sub-source data;

[0134] The computing module 704 is also configured as follows:

[0135] An adder is used to calculate at least two sub-source data to obtain the target data value;

[0136] The result determination module 708 is also configured as follows:

[0137] An adder is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0138] In some alternative embodiments, the computation module includes a multiplier;

[0139] The source data includes at least two sub-source data;

[0140] The computing module 704 is also configured as follows:

[0141] The target data value is obtained by using a multiplier to calculate at least two sub-source data.

[0142] The result determination module 708 is also configured as follows:

[0143] A multiplier is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0144] In some optional embodiments, the computation module includes a multiply-accumulate unit;

[0145] The source data includes at least two sub-source data;

[0146] The computing module 704 is also configured as follows:

[0147] A multiply accumulator is used to perform multiplication on at least two sub-source data, and the accumulated value is used as the target data value.

[0148] The result determination module 708 is also configured as follows:

[0149] A multiply accumulator is used to multiply at least two new sub-source data to obtain a new cumulative value;

[0150] A multiply-accumulator is used to add at least two new sub-source data and a new cumulative value to obtain a new target data value.

[0151] In some alternative embodiments, the data computing device 700 is further configured to:

[0152] The real-time detection and calculation module increments the actual number of calculations by one when it calculates the target data value.

[0153] The calculation information includes the target number of calculations;

[0154] Forwarding module 706 is also configured as follows:

[0155] When the actual number of calculations does not match the target number of calculations, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0156] In some optional embodiments, the computing module 704 is further configured to:

[0157] When the actual number of calculations matches the target number of calculations, the target data value obtained from the last calculation by the calculation module will be used as the data calculation result.

[0158] Each module in the aforementioned data computing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0159] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a data processing method. The display unit is used to form a visually visible image and can be a display screen, projection device, or virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0160] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0161] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0162] Retrieve source data in response to computation commands;

[0163] The calculation module is used to calculate the source data to obtain the target data value;

[0164] When the target data value does not match the calculation information carried by the calculation instruction, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0165] The calculation module performs calculations on the new source data and target data values ​​to obtain a new target data value. When the new target data value matches the calculation information, the new target data value is used as the data calculation result; otherwise, new source data is continuously acquired until the new target data value matches the calculation information.

[0166] In some alternative embodiments, the computation module includes an adder;

[0167] The source data includes at least two sub-source data;

[0168] When a computer program is executed by a processor, it also performs the following steps:

[0169] An adder is used to calculate at least two sub-source data to obtain the target data value;

[0170] An adder is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0171] In some alternative embodiments, the computation module includes a multiplier;

[0172] The source data includes at least two sub-source data;

[0173] When a computer program is executed by a processor, it also performs the following steps:

[0174] The target data value is obtained by using a multiplier to calculate at least two sub-source data.

[0175] A multiplier is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0176] In some optional embodiments, the computation module includes a multiply-accumulate unit;

[0177] The source data includes at least two sub-source data;

[0178] When a computer program is executed by a processor, it also performs the following steps:

[0179] A multiply accumulator is used to perform multiplication on at least two sub-source data, and the accumulated value is used as the target data value.

[0180] A multiply accumulator is used to multiply at least two new sub-source data to obtain a new cumulative value;

[0181] A multiply-accumulator is used to add at least two new sub-source data and a new cumulative value to obtain a new target data value.

[0182] In some optional embodiments, the computer program, when executed by the processor, also performs the following steps:

[0183] The real-time detection and calculation module increments the actual number of calculations by one when it calculates the target data value.

[0184] The calculation information includes the target number of calculations;

[0185] When the target data value does not match the calculation information carried by the calculation instruction, new source data is obtained, and the target data value is forwarded to the input of the calculation module, including:

[0186] When the actual number of calculations does not match the target number of calculations, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0187] In some optional embodiments, the computer program, when executed by the processor, also performs the following steps:

[0188] When the actual number of calculations matches the target number of calculations, the target data value obtained from the last calculation by the calculation module will be used as the data calculation result.

[0189] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0190] Retrieve source data in response to computation commands;

[0191] The calculation module is used to calculate the source data to obtain the target data value;

[0192] When the target data value does not match the calculation information carried by the calculation instruction, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0193] The calculation module performs calculations on the new source data and target data values ​​to obtain a new target data value. When the new target data value matches the calculation information, the new target data value is used as the data calculation result; otherwise, new source data is continuously acquired until the new target data value matches the calculation information.

[0194] In some alternative embodiments, the computation module includes an adder;

[0195] The source data includes at least two sub-source data;

[0196] When a computer program is executed by a processor, it also performs the following steps:

[0197] An adder is used to calculate at least two sub-source data to obtain the target data value;

[0198] An adder is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0199] In some alternative embodiments, the computation module includes a multiplier;

[0200] The source data includes at least two sub-source data;

[0201] When a computer program is executed by a processor, it also performs the following steps:

[0202] The target data value is obtained by using a multiplier to calculate at least two sub-source data.

[0203] A multiplier is used to calculate at least two new source data and target data values ​​to obtain a new target data value.

[0204] In some optional embodiments, the computation module includes a multiply-accumulate unit;

[0205] The source data includes at least two sub-source data;

[0206] When a computer program is executed by a processor, it also performs the following steps:

[0207] A multiply accumulator is used to perform multiplication on at least two sub-source data, and the accumulated value is used as the target data value.

[0208] A multiply accumulator is used to multiply at least two new sub-source data to obtain a new cumulative value;

[0209] A multiply-accumulator is used to add at least two new sub-source data and a new cumulative value to obtain a new target data value.

[0210] In some optional embodiments, the computer program, when executed by the processor, also performs the following steps:

[0211] The real-time detection and calculation module increments the actual number of calculations by one when it calculates the target data value.

[0212] The calculation information includes the target number of calculations;

[0213] When the target data value does not match the calculation information carried by the calculation instruction, new source data is obtained, and the target data value is forwarded to the input of the calculation module, including:

[0214] When the actual number of calculations does not match the target number of calculations, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

[0215] In some optional embodiments, the computer program, when executed by the processor, also performs the following steps:

[0216] When the actual number of calculations matches the target number of calculations, the target data value obtained from the last calculation by the calculation module will be used as the data calculation result.

[0217] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0218] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0219] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A data processing method, characterized in that, include: Retrieve source data in response to computation commands; The source data is input from the terminal or obtained by upstream steps in an automated processing flow; The calculation instruction includes a data tag, which corresponds to the source data; The source data is processed using a calculation module to obtain the target data value; When the target data value does not conform to the calculation information carried by the calculation instruction, new source data is obtained, and the target data value is directly forwarded to the input terminal of the calculation module; the calculation information includes a preset numerical range or a range of calculation times; The calculation module is used to calculate the new source data and the target data value to obtain a new target data value; when the new target data value matches the calculation information, the new target data value is used as the data calculation result. Otherwise, continue acquiring new source data until the new target data value matches the calculated information; The step of responding to a calculation instruction and acquiring source data includes: In response to the calculation instruction, a preset amount of source data is obtained; After the calculation module calculates the source data to obtain the target data value, the method further includes: When new source data is available, a preset number of new source data are acquired, and the target data value is forwarded to the input of the calculation module until no new source data is available.

2. The method according to claim 1, characterized in that, The calculation module includes an adder; The source data includes at least two sub-source data; The step of using a calculation module to calculate the source data to obtain the target data value includes: The target data value is obtained by using the adder to calculate at least two of the sub-source data. The step of using the calculation module to calculate the new source data and the target data value to obtain the new target data value includes: The adder is used to calculate at least two new sub-source data and the target data value to obtain a new target data value.

3. The method according to claim 1, characterized in that, The calculation module includes a multiplier; The source data includes at least two sub-source data; The step of using a calculation module to calculate the source data to obtain the target data value includes: The target data value is obtained by using the multiplier to calculate at least two of the sub-source data. The step of using the calculation module to calculate the new source data and the target data value to obtain the new target data value includes: The multiplier is used to calculate at least two new sub-source data and the target data value to obtain a new target data value.

4. The method according to claim 1, characterized in that, The calculation module includes a multiply-accumulate unit; The source data includes at least two sub-source data; The step of using a calculation module to calculate the source data to obtain the target data value includes: The multiply accumulator is used to perform multiplication on at least two sub-source data to obtain the accumulated value as the target data value; The step of using the calculation module to calculate the new source data and the target data value to obtain the new target data value includes: The multiply accumulator is used to perform multiplication on at least two new sub-source data to obtain a new cumulative multiplication value; The multiply-accumulator is used to perform addition calculations on at least two new sub-source data and a new cumulative value to obtain a new target data value.

5. The method according to claim 1, characterized in that, The method further includes: The calculation module is monitored in real time, and when the calculation module calculates the target data value, the actual number of calculations is incremented by one; The calculation information includes the target number of calculations; When the target data value does not conform to the calculation information carried by the calculation instruction, acquiring new source data and forwarding the target data value to the input of the calculation module includes: When the actual number of calculations does not match the target number of calculations, new source data is obtained, and the target data value is forwarded to the input of the calculation module.

6. The method according to claim 5, characterized in that, The method further includes: When the actual number of calculations meets the target number of calculations, the target data value obtained by the last calculation by the calculation module is used as the data calculation result.

7. A data computing device, characterized in that, include: The acquisition module is used to acquire source data in response to calculation instructions; The source data is input from the terminal or obtained by upstream steps in an automated processing flow; The calculation instruction includes a data tag, which corresponds to the source data; The calculation module is used to calculate the source data to obtain the target data value. The forwarding module is used to obtain new source data and directly forward the target data value to the input terminal of the calculation module when the target data value does not conform to the calculation information carried by the calculation instruction; the calculation information includes a preset numerical range or a range of calculation times. The result determination module is used to calculate the new source data and the target data value using the calculation module to obtain the new target data value; When a new target data value matches the calculation information, the new target data value is used as the data calculation result; otherwise, new source data is continuously acquired until a new target data value matches the calculation information. The acquisition module is also used to acquire a preset amount of source data in response to the calculation instruction; The data computing device is further configured to, after calculating the source data using the computing module to obtain the target data value, continue to acquire a preset number of new source data when new source data exists, and forward the target data value to the input terminal of the computing module until no new source data exists.

8. The apparatus according to claim 7, characterized in that, The calculation module includes an adder; the source data includes at least two sub-source data. The calculation module is further configured to use the adder to calculate at least two of the sub-source data to obtain the target data value; The result determination module is further configured to use the adder to calculate at least two new sub-source data and the target data value to obtain a new target data value.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the data processing method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the data processing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • SM4 algorithm operation method, system and device and computer readable storage medium

    CN114598451A

  • Hardware system for sparse convolution calculation and calculation method

    CN114780910A