Floating-point data floating-point multiplication and addition operation method, device, electronic device and storage medium

By preprocessing the floating point source operands, floating point multiplication and addition operations of non-standardized numbers are directly performed, which solves the problem of low computational efficiency of the floating point multiplication and addition component when processing non-standardized numbers, and improves the floating of the processor Point multiplication and command performance.

CN118819465BActive Publication Date: 2024-11-29BEIJING VCORE TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411296828.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2024-11-29
Estimated Expiration
2044-09-18

AI Technical Summary

Technical Problem

When the floating point multiplication and addition component processes unstandardized numbers, the computing efficiency is low, resulting in the processor's performance in processing floating point multiplication and addition instructions.

Method used

By preprocessing the floating point source operands, floating point multiplication and addition operations of non-standardized numbers are directly performed to avoid pipeline blocking and standardization, and a gradual underflow underflow treatment method is adopted.

Benefits of technology

Improve the computing efficiency of the floating point multiplication and addition component and improve the performance of the processor in processing floating point multiplication and addition instructions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819465B_ABST
    Figure CN118819465B_ABST
Patent Text Reader

Abstract

The present invention provides a floating-point data floating-point multiplication and addition method, device, electronic device and storage medium, which relate to the technical field of computer processors. The method comprises: when the type of at least one floating-point source operand is not the target type, preprocessing each floating-point source operand to obtain a preprocessing operand; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessing operand is normalized data or non-normalized data; performing floating-point multiplication and addition operations on each preprocessing operand to obtain an operation result. Since the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessing operand is normalized data or non-normalized data, direct floating-point multiplication and addition operations on normalized data and non-normalized data are realized, and it is not necessary to convert non-normalized data into normalized data, thereby improving the operation efficiency of the floating-point multiplication and addition component, and thus improving the performance of the processor in processing floating-point multiplication and addition instructions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer processors, and in particular to a floating-point data floating-point multiplication and addition operation method, device, electronic equipment and storage medium. Background Art

[0002] An important indicator of a high-performance processor is the performance of the Fused Multiply-accumulate (FMA) unit in the central processing unit (CPU). High-performance processors usually have a FMA unit to perform floating-point multiplication and addition operations on floating-point numbers.

[0003] The arithmetic unit of the floating-point multiplication and addition component generally only supports floating-point multiplication and addition operations on floating-point numbers in the format of normalized numbers. When the floating-point component of the processor obtains a small operation result on the floating-point number and is smaller than the minimum value that can be represented by the normalized number, it is necessary to use a non-normalized number to represent the operation result. Therefore, the floating-point multiplication and addition component must involve the processing of non-normalized numbers. When the floating-point multiplication and addition component is to operate on the operation result in the format of a non-normalized number, it is necessary to pre-process the non-normalized number, which may specifically include: method 1, using software to simulate the non-normalized number for calculation; method 2, when the floating-point multiplication and addition operation component encounters a non-normalized number input, the pipeline blocks one clock cycle to unify the mantissa of the non-normalized number into the form of a normalized number by left shifting, so as to further perform floating-point multiplication and addition operations.

[0004] However, for method one, the use of software for denormalized number operations greatly reduces the operational efficiency of the floating-point multiplication and addition unit; for method two, it will form bubbles in the pipeline, thereby reducing the number of instructions executed in each clock cycle, and because the pipeline of one clock cycle is blocked, it is impossible to fully process data, which increases the complexity of write-back and various related logic controls, and reduces the performance of the processor in processing floating-point multiplication and addition instructions. Therefore, the method for the floating-point multiplication and addition unit to process denormalized data is complicated, which makes the operational efficiency of the floating-point multiplication and addition unit low, and further leads to low performance of the processor in processing floating-point multiplication and addition instructions. Summary of the invention

[0005] The present invention provides a floating-point data floating-point multiplication and addition operation method, device, electronic device and storage medium, which are used to solve the problem that the operation efficiency of floating-point multiplication and addition components is low, thereby causing the processor to have low performance in processing floating-point multiplication and addition instructions.

[0006] The present invention provides a floating-point data floating-point multiplication and addition operation method, comprising:

[0007] In a case where the type of at least one floating-point source operand is not the target type, preprocessing each of the floating-point source operands to obtain a preprocessing operand; the type of the floating-point source operand is normalized data or denormalized data, and the type of the preprocessing operand is normalized data or denormalized data;

[0008] Perform floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result.

[0009] According to a floating-point data floating-point multiplication and addition operation method provided by the present invention, the preprocessing of each floating-point source operand to obtain a preprocessed operand comprises:

[0010] For each of the floating-point source operands, when the type of the floating-point source operand is denormalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and 1 bit of 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain the preprocessed operand.

[0011] According to a floating-point data floating-point multiplication and addition operation method provided by the present invention, the floating-point multiplication and addition operation is performed on each of the preprocessing operands to obtain an operation result, including:

[0012] A floating-point multiplication-addition operation is performed on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain the operation result.

[0013] According to a floating-point data floating-point multiplication and addition operation method provided by the present invention, the method further includes:

[0014] In the process of performing floating-point multiplication and addition operations on each of the preprocessing operands, a right shift operation is performed on the mantissa of the preprocessing operand to be added;

[0015] In the case where the shift amount of the right shift right order operation is greater than a preset value, determining a mantissa exceeding the preset value;

[0016] Based on the mantissa exceeding the preset value, it is determined whether to set a rounding bit; the rounding bit is used to control the rounding of the operation result.

[0017] According to a floating-point data floating-point multiplication and addition operation method provided by the present invention, determining whether to set a rounding bit based on a mantissa exceeding the preset value includes:

[0018] When the mantissa exceeding the preset value is not all zero, the rounding bit is set.

[0019] According to a floating-point data floating-point multiplication and addition operation method provided by the present invention, determining whether to set a rounding bit based on a mantissa exceeding the preset value includes:

[0020] When the mantissa exceeding the preset value is all 0, no rounding bit is set.

[0021] According to a floating-point data floating-point multiplication and addition operation method provided by the present invention, the method further includes:

[0022] In a case where the floating-point source operand is a floating-point single-precision source operand and the type of the floating-point source operand is a denormalized number, the floating-point source operand is converted to a floating-point double-precision source operand.

[0023] The present invention also provides a floating-point data floating-point multiplication and addition operation device, comprising:

[0024] A preprocessing module, configured to preprocess each of the floating-point source operands to obtain a preprocessed operand when the type of at least one floating-point source operand is not the target type; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessed operand is normalized data or non-normalized data;

[0025] The operation module is used to perform floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result.

[0026] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any one of the above-mentioned floating-point data floating-point multiplication and addition operation methods is implemented.

[0027] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned floating-point data floating-point multiplication and addition operation methods is implemented.

[0028] The floating-point data floating-point multiplication and addition operation method, device, electronic device and storage medium provided by the present invention are as follows: when the type of at least one floating-point source operand is not the target type, each of the floating-point source operands is preprocessed to obtain a preprocessed operand; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessed operand is normalized data or non-normalized data; floating-point multiplication and addition operation is performed on each of the preprocessed operands to obtain an operation result. Since the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessed operand is normalized data or non-normalized data, direct floating-point multiplication and addition operation of normalized data and non-normalized data is realized, and non-normalized data does not need to be converted into normalized data, thereby improving the operation efficiency of the floating-point multiplication and addition component, and further improving the performance of the processor in processing floating-point multiplication and addition instructions. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0030] Figure 1 It is a schematic diagram of the implementation flow of the traditional floating-point multiplication and addition component provided by the prior art.

[0031] Figure 2 This is one of the flow charts of the floating-point data floating-point multiplication and addition operation method provided by the present invention.

[0032] Figure 3 This is the second flow chart of the floating-point data floating-point multiplication and addition operation method provided by the present invention.

[0033] Figure 4 This is the third flow chart of the floating-point data floating-point multiplication and addition operation method provided by the present invention.

[0034] Figure 5 The present invention is a schematic diagram of the structure of a floating-point data floating-point multiplication and addition operation device.

[0035] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0037] In order to facilitate a clearer understanding of the embodiments of the present application, the relevant knowledge is first introduced as follows.

[0038] At present, the computing performance of the FMA unit has become an important indicator for evaluating the floating-point peak performance of the processor. High-performance processor cores are generally equipped with 2 to 4 FMA units, which can provide a floating-point peak performance of 4 to 8 floating-point operations per cycle. The processing performance of the floating-point multiplication and addition unit has a crucial impact on the overall performance of the CPU. The instruction set of high-performance processors, such as the fifth-generation Reduced Instruction Set Computing Five (RISC-V), supports single-precision and double-precision floating-point multiplication and addition instructions that comply with the IEEE 754 binary floating-point arithmetic standard. Floating-point multiplication and addition units are usually set up in high-performance processors to perform floating-point multiplication and addition operations on floating-point numbers. By designing a high-performance floating-point multiplication and addition unit to support the operation of floating-point multiplication and addition instructions, the performance of the processor can be greatly improved.

[0039] Table 1. Floating point encoding format

[0040]

[0041] Table 1 is the floating point encoding format. As shown in Table 1, a floating point number is mainly composed of three parts: the sign bit (S), the exponent (Exp), and the mantissa (Mantissa). The sign bit is used to indicate the positive or negative of the floating point number; the exponent is used to indicate the position of the decimal point in the floating point number, and the exponent is a signed integer; the mantissa is used to indicate the valid value of the floating point number. For example, in the most widely used floating point representation and operation standard IEEE 754, a sign bit of 0 indicates a positive number, a sign bit of 1 indicates a negative number, the exponent is represented in the form of a shifted code, and the mantissa is represented in the original code.

[0042] Floating-point numbers also include multiple formats, namely: normalized numbers, denormalized numbers, positive and negative zero, positive and negative infinity, and non-number. Positive and negative zero, positive and negative infinity, and non-number are collectively referred to as special numbers; among them, the exponent and mantissa of positive and negative zero are all 0, the exponent of positive and negative infinity is all 1 and the mantissa is all 0, the exponent of non-number is all 1 and the mantissa is not 0, the exponent of denormalized numbers is all 0 and the mantissa is not 0, and the rest represent normalized numbers.

[0043] For a normalized number, the decimal value Value1 corresponding to the normalized number is expressed as: ; For denormalized numbers, the decimal value Value2 corresponding to the denormalized number is expressed as: ; Among them, Bias mainly indicates the exponent offset. For single-precision floating-point numbers, Bias is 127; for double-precision floating-point numbers, Bias is 1023, as shown in Table 2, which is the floating-point encoding bit width.

[0044] Table 2. Floating point encoding bit width

[0045]

[0046] The arithmetic unit of the floating-point multiplication and addition unit generally only supports floating-point multiplication and addition operations on floating-point numbers in the format of normalized numbers. When the floating-point unit of the processor obtains a small result from the operation of floating-point numbers, and is smaller than the minimum value that can be represented by the normalized number, it is necessary to use a denormalized number to represent the result. The underflow exception defined by the IEEE 754 standard should use gradual underflow rather than abrupt underflow. When the result of the operation is smaller than the minimum normalized number, the result is represented by a denormalized number. This process is called denormalization. Therefore, the floating-point multiplication and addition unit must involve the processing of denormalized numbers. When the floating-point multiplication and addition unit needs to operate on the result of the operation in the format of denormalized numbers, the denormalized number needs to be preprocessed.

[0047] Floating-point multiply-add instructions include multiply-add, multiply-subtract, negative multiply-add, and negative multiply-subtract operations, such as , , and The three floating-point source operands of the floating-point multiplication and addition unit are src1, src2 and src3. The floating-point multiplication and addition unit calculates When src1 or src2 is 1.0, the addition operation is completed; when src3 is 0, the multiplication operation is completed. , and Represents the exponents of the three floating-point source operands. For double-precision denormalized numbers, the exponent Then it is -1022.

[0048] Figure 1 It is a schematic diagram of the implementation flow of the traditional floating-point multiplication and addition component provided by the prior art, such as Figure 1As shown, the conventional floating-point multiplication and addition operation unit first preprocesses the floating-point source operand. In the preprocessing stage, step 101, the floating-point multiplication and addition operation unit determines the type of the source operand. If it is a special value, an exception judgment should be performed, that is, the source operand is judged to be abnormal, and the exception processing is directly entered; if it is a normalized number, a 1 should be added to the implicit bit of the mantissa of the source operand; if it is a denormalized number, a 0 should be added to the implicit bit of the mantissa of the source operand. Moreover, the floating-point multiplication and addition unit needs to block the pipeline for 1 clock cycle before performing the denormalized number operation, and normalize the mantissa of the denormalized number, that is, the mantissa of the denormalized number is unified into the form of a normalized number by left shifting. Step 102, the floating-point multiplication and addition operation unit performs floating-point multiplication and addition operation on the normalized floating-point number. Step 103, the floating-point multiplication and addition operation unit performs normalization and denormalization shift and rounding processing on the operation result.

[0049] Among them, normalization shift: Since the implicit bit of the calculated mantissa result is not necessarily 1, the IEEE 754 standard requires that the data be represented in a normalized form, that is, Therefore, the mantissa needs to be shifted left according to the number of leading 0s in the result so that its implicit bit is 1, and the exponent is reduced by the left shift amount. This process is called normalization.

[0050] Denormalized shift: When the result of an operation is too small to be represented by a normalized number, the result needs to be represented in a denormalized form, that is, , this process needs to be based on the index of the result and The result is right-shifted to conform to the denormalized number format.

[0051] Rounding: Round the result of the operation according to the specified rounding mode, and determine whether overflow, underflow, or inexact exception rounding mode occurs. It should be noted that the accurate result of the floating-point operation may require data of infinite bit width to represent. Due to the limited precision in the actual hardware, the hardware calculation process needs to retain the extension bits exceeding the mantissa bit width of 3 bits, namely the guard bit (guard(g)), the rounding bit (round(r)), and the sticky bit (sticky(s)), and use these three extension bits to truncate and round the result of the floating-point operation. For example, the RISC-V instruction set requires the implementation of five rounding modes, namely round to the nearest even (RNE, round to nearest even), ties to even, round to the maximum mantissa (RMM, round to nearest even), ties to max magnitude, round to positive infinity (RUP, round to positive infinite), round to negative infinity (RDN, round to negative infinite), and round to zero (RTZ, round to zero). The lowest bit of the mantissa when no rounding is performed is recorded as lsb , the sign bit is sign , then the rounding conditions of the five rounding modes can be expressed in Table 3.

[0052] Table 3. Rounding conditions for different rounding modes

[0053]

[0054] Based on the above description, the floating-point multiplication and addition component needs to perform normalization shift processing on non-normalized data, and needs to block the pipeline for one clock cycle. After the normalization shift processing, floating-point multiplication and addition operations are performed on the normalized numbers. The method of the floating-point multiplication and addition component to process non-normalized data is complicated, which makes the floating-point multiplication and addition component's operation efficiency low, and further leads to low performance of the processor in processing floating-point multiplication and addition instructions.

[0055] Based on this, the present invention provides a floating-point multiplication and addition method for floating-point data. The floating-point multiplication and addition unit does not need to perform normalization shift processing on non-normalized numbers, and directly performs floating-point multiplication and addition operations on non-normalized numbers. A gradual underflow processing method is adopted, so that when the floating-point multiplication and addition unit performs operations on non-normalized source operands, it is not necessary to block the pipeline, and the number of pipeline stages is not increased. The operation efficiency of the floating-point multiplication and addition unit can be improved, and the performance of the processor in processing floating-point multiplication and addition instructions is further improved.

[0056] Combine the following Figure 2-Figure 4 The floating-point data floating-point multiplication and addition operation method of the present invention is described.

[0057] Figure 2FIG. 1 is one of the flow charts of the floating-point data floating-point multiplication and addition operation method provided by the present invention, such as Figure 2 As shown, the method includes the following steps 201-202.

[0058] Step 201: When the type of at least one floating-point source operand is not the target type, preprocess each of the floating-point source operands to obtain a preprocessed operand; the type of the floating-point source operand is normalized data or denormalized data, and the type of the preprocessed operand is normalized data or denormalized data.

[0059] It should be noted that the floating-point data floating-point multiplication and addition operation method provided by the present invention can be applied to the scenario where the floating-point multiplication and addition component in the central processing unit performs floating-point multiplication and addition operations on floating-point data. The execution subject of the method can be a floating-point data floating-point multiplication and addition operation device, such as an electronic device, a processor, or a control module in the floating-point data floating-point multiplication and addition operation device for executing the floating-point data floating-point multiplication and addition operation method.

[0060] Specifically, the target type refers to positive or negative zero, positive or negative infinity or non-number, the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessing operand is normalized data or non-normalized data. In the preprocessing stage, it is necessary to judge the type of the floating-point source operand. In the case where the type of at least one floating-point source operand is not the target type, each floating-point source operand can be preprocessed separately to obtain a preprocessing operand. In the case where the type of at least one floating-point source operand is the target type, an exception judgment should be performed, that is, if the source operand is judged to be abnormal, the exception handling is directly entered.

[0061] Step 202: Perform floating-point multiplication and addition operations on each of the preprocessing operands to obtain operation results.

[0062] Specifically, after the preprocessing operands are obtained, floating-point multiplication and addition operations may be performed on each preprocessing operand, that is, floating-point multiplication and addition operations may be performed on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain operation results.

[0063] After the operation result is obtained, normalization, denormalization, shifting and rounding are performed on the operation result.

[0064] The floating-point data floating-point multiplication and addition method provided by the present invention is to pre-process each floating-point source operand respectively to obtain a pre-processed operand when the type of at least one floating-point source operand is not the target type; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the pre-processed operand is normalized data or non-normalized data; and perform floating-point multiplication and addition operations on each pre-processed operand to obtain an operation result. Since the type of the floating-point source operand is normalized data or non-normalized data, and the type of the pre-processed operand is normalized data or non-normalized data, direct floating-point multiplication and addition operations on normalized data and non-normalized data are realized, and it is not necessary to convert non-normalized data into normalized data, thereby improving the operation efficiency of the floating-point multiplication and addition component, and further improving the performance of the processor in processing floating-point multiplication and addition instructions.

[0065] Optionally, a specific implementation of step 201 includes:

[0066] For each of the floating-point source operands, when the type of the floating-point source operand is denormalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and 1 bit of 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain the preprocessed operand.

[0067] Specifically, for each floating-point source operand, when the type of the floating-point source operand is denormalized data, before the denormalization operation is performed on the mantissa of the floating-point source operand, it is not necessary to block the pipeline for a clock cycle, and it is not necessary to perform normalization on the mantissa of the floating-point source operand, and only one 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain a preprocessed operand. The addition of one 0 is to represent the value of the mantissa of the floating-point source operand, and the denormalized data is smaller than the range represented by the normalized data, so the implicit bit of the mantissa of the denormalized data is 0.

[0068] Optionally, when the type of the floating-point source operand is normalized data, a 1-bit 1 is added to the implicit bit of the mantissa of the floating-point source operand.

[0069] Optionally, performing floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result includes:

[0070] A floating-point multiplication-addition operation is performed on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain the operation result.

[0071] Specifically, the floating-point multiplication-addition component performs floating-point multiplication-addition operations on normalized preprocessing operands and / or non-normalized preprocessing operands, that is, the floating-point multiplication-addition component can perform multiplication-addition operations on both normalized preprocessing operands and non-normalized preprocessing operands to obtain operation results.

[0072] Figure 3 FIG. 2 is a flow chart of the floating-point data floating-point multiplication and addition operation method provided by the present invention. Figure 3 As shown, the method includes steps 301 to 303.

[0073] Step 301, determine the type of the floating-point source operand. If it is a special value, an exception judgment should be performed; if it is normalized data, a 1-bit 1 should be added to the implicit bit of the mantissa of the source operand; if it is non-normalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and a 0-bit is added to the implicit bit of the mantissa of the floating-point source operand.

[0074] Step 302: Perform floating-point multiplication and addition operations on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain operation results.

[0075] Step 303: perform normalization, denormalization shifting and rounding processing on the operation result.

[0076] Optionally, the method further comprises:

[0077] In the process of performing floating-point multiplication and addition operations on each of the preprocessing operands, a right shift operation is performed on the mantissa of the preprocessing operand to be added; when the shift amount of the right shift operation is greater than a preset value, the mantissa exceeding the preset value is determined; based on the mantissa exceeding the preset value, it is determined whether to set a rounding bit; the rounding bit is used to control the rounding of the operation result.

[0078] Specifically, when the floating-point multiplication and addition unit of the present application performs floating-point multiplication and addition operations on floating-point source operands, the difference from the traditional floating-point multiplication and addition unit is that, since the mantissa of the non-normalized floating-point source operand is not normalized, the floating-point source operands involved in the floating-point multiplication and addition operations may contain non-normalized data, resulting in the position of the first 1 of the product result of the mantissa of the floating-point source operand src1 and the floating-point source operand src2 being uncertain in the 106-bit product. Therefore, when the position of the first 1 is in the lower 53 bits of the 106-bit product, adding the order-shifted src3 to the obtained product of src1 and src2 may affect the guard bit, round bit and sticky bit used in the rounding operation. Therefore, the maximum order shift amount of src3 needs to be 164 bits, and the preset value is 164 bits.

[0079] In the process of performing floating-point multiplication and addition operations on each of the preprocessing operands, the mantissa of the preprocessing operand (i.e., src3) to be added can be right-shifted; when the shift amount of the right-shift operation is greater than the preset value, it means that the shift amount is large, and a part of the mantissa of the preprocessing operand (i.e., src3) will be shifted out of the 164-bit range. In order to obtain the part of the mantissa of the preprocessing operand (i.e., src3) that is shifted out of 164 bits during the right-shift operation, the mantissa that exceeds the preset value is recorded, and the mantissa that exceeds the preset value can be determined; based on the mantissa that exceeds the preset value, it can be further determined whether to set the rounding bit; wherein the rounding bit is used to control the rounding of the calculation result.

[0080] Optionally, the determining whether to set a rounding bit based on the mantissa exceeding the preset value includes:

[0081] When the mantissa exceeding the preset value is not all zero, the rounding bit is set.

[0082] Specifically, when the mantissa exceeding the preset value is not all 0, that is, the mantissa of the preprocessing operand (i.e., src3) that is shifted out of 164 bits during the right shift is not all 0, it is necessary to set the rounding bit, for example, set the sticky bit to 1.

[0083] It should be noted that the main function of the rounding mode of floating-point operations is to ensure the accuracy of floating-point operation results while minimizing errors. You can control the rounding behavior of the operation results by setting the rounding mode.

[0084] Optionally, the determining whether to set a rounding bit based on the mantissa exceeding the preset value includes:

[0085] When the mantissa exceeding the preset value is all 0, no rounding bit is set.

[0086] Specifically, when the mantissa exceeding the preset value is all 0, that is, the mantissa of the preprocessing operand (i.e., src3) that is shifted out of 164 bits during the right shift is all 0, there is no need to set the rounding bit, for example, the sticky bit is not set to 1.

[0087] Optionally, the method further comprises:

[0088] In a case where the floating-point source operand is a floating-point single-precision source operand and the type of the floating-point source operand is a denormalized number, the floating-point source operand is converted to a floating-point double-precision source operand.

[0089] Specifically, in order to reuse precious chip resources, the general floating-point multiplication and addition components of the processor support floating-point double-precision multiplication and addition operations, and also support floating-point single-precision multiplication and addition operations. When the floating-point single-precision source operand of the present application is converted to a floating-point double-precision number, since the floating-point multiplication and addition component can directly process the non-normalized data of the floating-point double precision (i.e., 64-bit non-normalized data) and does not need to be normalized, the present application can directly convert the floating-point single-precision source operand (i.e., 32-bit non-normalized data) into a floating-point double-precision source operand (i.e., 64-bit non-normalized number) when the floating-point source operand is a floating-point single-precision source operand and the type of the floating-point source operand is a non-normalized number, that is, converting the 32-bit single-precision floating-point non-normalized data into double-precision floating-point non-normalized data, and there is no need to convert the 32-bit non-normalized data into 64-bit normalized data like the traditional floating-point multiplication and addition component, thereby avoiding the delay and overhead caused by calculating the leading zeros of the 32-bit non-normalized data.

[0090] Figure 4 FIG. 3 is a flow chart of the floating-point data floating-point multiplication and addition operation method provided by the present invention, as shown in FIG. Figure 4 As shown, the method includes steps 401 to 408.

[0091] Step 401, determine whether the type of the floating-point source operand is the target type. If the type of at least one floating-point source operand is the target type, go to step 402; if the type of at least one floating-point source operand is not the target type, go to step 403.

[0092] Step 402: directly enter exception handling.

[0093] Step 403: for each floating-point source operand, when the type of the floating-point source operand is denormalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and a 1-bit 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain a preprocessed operand; when the type of the floating-point source operand is normalized data, a 1-bit 1 is added to the implicit bit of the mantissa of the floating-point source operand to obtain a preprocessed operand.

[0094] Step 404: Perform floating-point multiplication and addition operations on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain operation results.

[0095] Step 405: In the process of performing floating-point multiplication and addition operations on the preprocessing operands, a right shift operation is performed on the mantissa of the preprocessing operands to be added.

[0096] Step 406: When the shift amount of the right shift operation is greater than a preset value, the mantissa exceeding the preset value is recorded to determine the mantissa exceeding the preset value.

[0097] Step 407: When the mantissa exceeding the preset value is not all 0, set the rounding bit.

[0098] Step 408: When the decimals exceeding the preset value are all 0, the rounding bit is not set.

[0099] The floating-point data floating-point multiplication and addition operation device provided by the present invention is described below. The floating-point data floating-point multiplication and addition operation device described below and the floating-point data floating-point multiplication and addition operation method described above can be referred to each other.

[0100] Figure 5 FIG. 1 is a schematic diagram of the structure of the floating-point data floating-point multiplication and addition operation device provided by the present invention. Figure 5 As shown, the floating-point data floating-point multiplication and addition operation device 500 includes: a preprocessing module 501 and an operation module 502; wherein,

[0101] A preprocessing module 501 is used for preprocessing each of the floating-point source operands to obtain a preprocessing operand when the type of at least one floating-point source operand is not the target type; the type of the floating-point source operand is normalized data or denormalized data, and the type of the preprocessing operand is normalized data or denormalized data;

[0102] The operation module 502 is used to perform floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result.

[0103] The floating-point data floating-point multiplication and addition operation device provided by the present invention performs preprocessing on each floating-point source operand respectively to obtain a preprocessing operand when the type of at least one floating-point source operand is not the target type; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessing operand is normalized data or non-normalized data; and performs floating-point multiplication and addition operation on each preprocessing operand to obtain an operation result. Since the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessing operand is normalized data or non-normalized data, direct floating-point multiplication and addition operation on normalized data and non-normalized data is realized, and it is not necessary to convert non-normalized data into normalized data, thereby improving the operation efficiency of the floating-point multiplication and addition component, and further improving the performance of the processor in processing floating-point multiplication and addition instructions.

[0104] Optionally, the preprocessing module 501 is specifically used to:

[0105] For each of the floating-point source operands, when the type of the floating-point source operand is denormalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and 1 bit of 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain the preprocessed operand.

[0106] Optionally, the operation module 502 is specifically configured to:

[0107] A floating-point multiplication-addition operation is performed on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain the operation result.

[0108] Optionally, the floating-point data floating-point multiplication and addition operation device 500 further includes:

[0109] A right shift alignment module, used for performing a right shift alignment operation on the mantissa of the preprocessing operands to be added during the process of performing floating-point multiplication and addition operations on each of the preprocessing operands;

[0110] A first determining module, configured to determine a mantissa exceeding a preset value when a shift amount of a right shift operation is greater than a preset value;

[0111] The second determination module is used to determine whether to set a rounding bit based on the mantissa exceeding the preset value; the rounding bit is used to control the rounding of the operation result.

[0112] Optionally, the second determining module is specifically configured to:

[0113] When the mantissa exceeding the preset value is not all zero, the rounding bit is set.

[0114] Optionally, the second determining module is further configured to:

[0115] When the mantissa exceeding the preset value is all 0, no rounding bit is set.

[0116] Optionally, the floating-point data floating-point multiplication and addition operation device 500 further includes:

[0117] The conversion module is used for converting the floating-point source operand into a floating-point double-precision source operand when the floating-point source operand is a floating-point single-precision source operand and the type of the floating-point source operand is a denormalized number.

[0118] Figure 6 is a schematic diagram of the physical structure of an electronic device provided by the present invention, such as Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute a floating-point data floating-point multiplication and addition operation method, the method comprising: in the case where the type of at least one floating-point source operand is not the target type, preprocessing each of the floating-point source operands to obtain a preprocessing operand; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessing operand is normalized data or non-normalized data; performing a floating-point multiplication and addition operation on each of the preprocessing operands to obtain an operation result.

[0119] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0120] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the floating-point data floating-point multiplication and addition operation methods provided by the above-mentioned methods. The method includes: when the type of at least one floating-point source operand is not the target type, preprocessing each of the floating-point source operands to obtain a preprocessed operand; the type of the floating-point source operand is normalized data or denormalized data, and the type of the preprocessed operand is normalized data or denormalized data; performing floating-point multiplication and addition operations on each of the preprocessed operands to obtain an operation result.

[0121] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0122] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A floating-point data floating-point multiplication and addition operation method, characterized in that: include: When the type of at least one floating-point source operand is not the target type, preprocessing each of the floating-point source operands to obtain a preprocessed operand; The type of the floating-point source operand is normalized data or denormalized data, and the type of the preprocessing operand is normalized data or denormalized data; Performing floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result; The preprocessing of each of the floating-point source operands to obtain a preprocessed operand comprises: For each of the floating-point source operands, when the type of the floating-point source operand is non-normalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and 1 bit of 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain the preprocessed operand; The method further comprises: In the process of performing floating-point multiplication and addition operations on each of the preprocessing operands, a right shift operation is performed on the mantissa of the preprocessing operand to be added; In the case where the shift amount of the right shift right order operation is greater than a preset value, determining a mantissa exceeding the preset value; Based on the mantissa exceeding the preset value, it is determined whether to set a rounding bit; the rounding bit is used to control the rounding of the operation result.

2. The floating-point multiplication and addition method of floating-point data according to claim 1, wherein: The performing floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result includes: A floating-point multiplication-addition operation is performed on the normalized preprocessing operands and / or the non-normalized preprocessing operands to obtain the operation result.

3. The floating-point multiplication and addition operation method of floating-point data according to claim 1, wherein: The determining whether to set a rounding bit based on the mantissa exceeding the preset value comprises: When the mantissa exceeding the preset value is not all zero, the rounding bit is set.

4. The floating-point multiplication and addition operation method of floating-point data according to claim 1, wherein: The determining whether to set a rounding bit based on the mantissa exceeding the preset value comprises: When the mantissa exceeding the preset value is all 0, no rounding bit is set.

5. The floating-point multiplication and addition method of floating-point data according to claim 1 or 2, characterized in that: The method further comprises: In a case where the floating-point source operand is a floating-point single-precision source operand and the type of the floating-point source operand is a denormalized number, the floating-point source operand is converted to a floating-point double-precision source operand.

6. A floating-point data floating-point multiplication and addition operation device, characterized in that: The method for implementing the floating-point multiplication and addition operation of floating-point data according to any one of claims 1 to 5 comprises: A preprocessing module, configured to preprocess each of the floating-point source operands to obtain a preprocessed operand when the type of at least one floating-point source operand is not the target type; the type of the floating-point source operand is normalized data or non-normalized data, and the type of the preprocessed operand is normalized data or non-normalized data; An operation module, used for performing floating-point multiplication and addition operations on each of the preprocessing operands to obtain an operation result; The preprocessing module is specifically used for: For each of the floating-point source operands, when the type of the floating-point source operand is non-normalized data, the pipeline is not blocked for clock cycles, the mantissa of the floating-point source operand is not normalized, and 1 bit of 0 is added to the implicit bit of the mantissa of the floating-point source operand to obtain the preprocessed operand; The floating-point data floating-point multiplication and addition operation device further comprises: A right shift alignment module, used for performing a right shift alignment operation on the mantissa of the preprocessing operands to be added during the process of performing floating-point multiplication and addition operations on each of the preprocessing operands; A first determining module, configured to determine a mantissa exceeding a preset value when a shift amount of a right shift operation is greater than a preset value; The second determination module is used to determine whether to set a rounding bit based on the mantissa exceeding the preset value; the rounding bit is used to control the rounding of the operation result.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the floating-point data floating-point multiplication and addition operation method according to any one of claims 1 to 5 is implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the floating-point data floating-point multiplication and addition method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Floating point fusion multiplication and addition device and method of pipeline structure and processor

    CN116643718A

  • Data processing method and device, electronic equipment and computer readable storage medium

    CN117193707A

  • Floating-point number operation circuit and method

    CN117519638A

  • Floating point multiplication and addition structure applied to FPGA (Field Programmable Gate Array) embedded DSP (Digital Signal Processor)

    CN117891430A

  • Data processing method and apparatus, device, and storage medium

    WO2024120249A1