Handling overflow or underflow of anchor data values

HPA numbers address the non-associative nature of floating point arithmetic by using a fixed anchor value, enabling reproducible and fast summation, thus facilitating parallel processing in high-performance computing.

JP7541526B2Active Publication Date: 2024-08-28ARM LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
JP2021545709
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2019-02-06
Filing Date
2019-11-28
Publication Date
2024-08-28
Estimated Expiration
2039-11-28

AI Technical Summary

Technical Problem

Floating point arithmetic calculations are non-associative, leading to inconsistent results when adding numbers in different orders, making parallelization difficult and reproducibility challenging, especially in high-performance computing.

Method used

The introduction of High Precision Anchor (HPA) numbers, defined by a pair (i, a) with a long two's complement integer i and an anchor integer a, allows for associative and reproducible addition by maintaining a fixed anchor value across operations, enabling efficient parallel processing.

Benefits of technology

HPA numbers ensure reproducible and fast summation of floating-point values, allowing for significant speedups in high-performance computing by eliminating the need for sequential calculations and reducing the burden on programmers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007541526000017
    Figure 0007541526000017
  • Figure 0007541526000021
    Figure 0007541526000021
  • Figure 0007541526000020
    Figure 0007541526000020
Patent Text Reader

Abstract

The processing circuitry may support processing of anchor data values ​​including one or more anchor data elements representing a portion of the bits of a two's complement number. The anchor data processing may depend on anchor information indicating at least one characteristic indicative of a range of values ​​that can be represented by the resulting anchor data element or anchor data value. If an operation causes an overflow or underflow, usage information may be stored indicating the cause of the overflow or underflow and / or instructions on how to update the anchor information and / or the number of elements in the anchor data value to prevent the overflow or underflow. This may support dynamic range adjustment of software algorithms that include anchor data processing.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present technology relates to the field of data processing.

[0002] It is common for data processing systems to use floating-point (FP) representation. Floating-point numbers contain a mantissa and an exponent that indicates the significance of the bits in the mantissa. This allows a wide range of numbers to be represented using a finite number of bits. However, a problem with floating-point arithmetic is that addition is problematic, since the calculations are generally non-associative. In particular, programmers must be careful to get different results even when adding fractional values.

[0003] To solve this associativity problem, a new data type called High Precision Anchor (HPA) numbers has been proposed. High Precision Anchor (HPA) numbers can be constructed from a pair (i,a) containing a long two's complement (e.g. 200 bits) integer i, usually by specifying the significance of the least significant bit of i, and a small anchor integer a, which represents the weight of i's bits. Floating-point values ​​can be converted to the HPA format and then addition can be performed associatively.

[0004] At least some examples provide an apparatus comprising: a processing circuit that performs data processing; and an instruction decoder that controls the processing circuit to perform anchor data processing operations to generate result anchor data elements for an anchor data value including one or more anchor data elements, each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a numerical range that may be represented by the result anchor data element or the anchor data value, wherein in response to an anchor data processing operation where the anchor information indicates that the anchor data processing operation will cause an overflow or underflow of a two's complement number represented by the anchor data value, the instruction decoder is configured to control the processing circuit to store, in a software accessible storage location, usage information indicative of at least one of: a cause of the overflow or underflow and instructions on how to modify a format of the anchor data value to prevent the overflow or underflow.

[0005] At least some examples provide a data processing method including: decoding one or more instructions; and controlling a processing circuit, in response to the decoded instructions, to perform an anchor data processing operation to generate result anchor data elements of an anchor data value including one or more anchor data elements, each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a numerical range that may be represented by the result anchor data element or the anchor data value, wherein in response to an anchor data processing operation where the anchor information indicates that the anchor data processing operation will cause an overflow or underflow of the two's complement number represented by the anchor data value, the processing circuit stores, in a software accessible storage location, usage information indicative of at least one of a cause of the overflow or underflow and instructions on how to modify a format of the anchor data value to prevent the overflow or underflow.

[0006] At least some examples provide a non-transitory storage medium storing a computer program for controlling a host data processing apparatus to provide an instruction execution environment for executing instructions, the computer program including instruction decode program logic for decoding program instructions of a target code to control the host data processing apparatus to perform a data process, the instruction decode program logic including anchor data processing program logic for controlling the host data processing apparatus to perform an anchor data processing operation to generate result anchor data elements of an anchor data value including one or more anchor data elements each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a numerical range that may be represented by the result anchor data element or the anchor data value, and in response to an anchor data processing operation where the anchor information indicates that the anchor data processing operation will cause an overflow or underflow of the two's complement number represented by the anchor data value, the instruction decode program logic is configured to control a processing circuit to store, in a software accessible storage location, usage information indicative of at least one of a cause of the overflow or underflow and instructions on how to modify a format of the anchor data value to prevent the overflow or underflow.

[0007] At least some examples provide a data processing method that includes capturing a checkpoint of an architectural state; performing a portion of a sequence of data processing operations based on the architectural state captured at the checkpoint, the portion including at least one anchor data processing operation for generating a result anchor data element of an anchor data value including one or more anchor data elements representing respective portions of bits of a two's complement number, the anchor data value being associated with anchor information indicating at least one characteristic indicative of a numerical range that can be represented by the result anchor data element or the anchor data value; performing overflow or underflow detection to detect whether the at least one anchor data processing operation caused an overflow or underflow of the anchor data value; restoring the checkpoint of the architectural state if an overflow or underflow is detected; modifying a format of the anchor data value; and retrying the portion of the sequence of data processing operations based on the modified format and the checkpoint of the restored architectural state.

[0008] At least some examples provide a non-transitory storage medium having stored thereon a computer program for controlling a data processing apparatus to perform a method that includes capturing a checkpoint of an architectural state. [Brief description of the drawings]

[0009] Further aspects, features and advantages of the present technology will become apparent from the following description of examples which should be read in conjunction with the accompanying drawings. [Figure 1] FIG. 1 is a schematic diagram of a data processing device. [Diagram 2] FIG. 2 is a diagram showing a schematic diagram of different expressions of numerical values. [Diagram 3] FIG. 3 is a diagram illustrating an example of a relationship between a double-precision floating-point value and a high precision anchor (HPA) value. [Figure 4] FIG. 4 is a diagram showing an example of a redundant HPA value that expresses a numerical value using a redundant expression including multiple N-bit parts with overlapping significance. [Diagram 5] FIG. 5 is a schematic diagram illustrating how HPA integers may be stored in selected lanes across multiple vector registers in one example. [Figure 6] FIG. 6 is a block diagram illustrating a schematic of how floating-point numbers may be converted to HPA format and processed according to one exemplary configuration. [Figure 7] FIG. 7 is a schematic diagram illustrating the form of metadata that may be used in one example. [Figure 8] FIG. 8 illustrates in greater detail the conversion and processing circuitry that may be provided in association with each lane in one example. [Figure 9] FIG. 9 is a diagram illustrating the encoding of an anchor data element that includes type information indicating whether the anchor data element represents a portion of the bits of a two's complement number or represents a special value. [Figure 10] FIG. 10 is a diagram illustrating the encoding of type information. [Figure 11] FIG. 11 is a diagram illustrating different results in setting type information of a result anchor data element based on type information of a first operand and a second operand. [Figure 12] FIG. 12 illustrates a method of processing anchor data that includes storing usage information in response to an overflow or underflow. [Figure 13] FIG. 13 illustrates a method for dynamically adjusting the anchor information and / or the number of elements included in an anchor data value during a sequence of data processing operations that includes at least one anchor data processing operation. [Figure 14] FIG. 14 shows an example of processing a chord sequence using the method of FIG. [Figure 15] FIG. 15 illustrates an example of providing at least one additional element to the most significant end of an anchor data value in response to a detected overflow. [Figure 16] FIG. 16 illustrates an example of providing at least one additional element to the least significant end of an anchor data value in response to a detected underflow. [Figure 17] FIG. 17 shows an example of a simulator that may be used. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0010] As mentioned above, the problem with floating-point arithmetic is that the calculations are generally associative, which is a problem for addition. For example, when adding multiple floating-point values, each time another value is added to the result of the previous addition, the result is rounded and normalized, which means that the overall result will differ depending on the order in which the values ​​are added. This makes parallelization of floating-point arithmetic difficult, since the sum will not be reproducible unless the values ​​are added in exactly the same order. To get a reproducible result, a series of additions or subtractions must usually be performed in succession, which makes floating-point arithmetic relatively slow.

[0011] So programmers use more precision than necessary to avoid these different results, and so programmers cannot easily parallelize their code because the sums are not reproducible unless they are calculated in the same order.

[0012] This problem is especially prevalent in high performance computing (HPC), where a program may need to add millions of values ​​together. Programmers would like to parallelize these problems, but doing so makes them hard to debug because they are not reproducible: even different machine configurations will give different answers, even if they are perfectly reprogrammed for that machine.

[0013] As mentioned above, a new data type called HPA (High Precision Anchor) numbers is proposed to solve the associativity problem. HPA numbers can consist of a pair (i,a) containing a long two's complement (e.g. 200-bit) integer i and a small anchor integer a that represents the weight of i's bits, usually specifying the significance of the least significant bit of i). This pair is somewhat similar to the mantissa and exponent values ​​of FP numbers, except that the long integer i is not normalized and is usually much larger than the FP mantissa, and the anchor value a is fixed for all operands of an HPA operation. Adding FP numbers can change the exponent, but adding HPA numbers does not change the anchor.

[0014] As a trivial example, consider an HPA representation consisting of 10 bits of i and an anchor value a = -4. Some values ​​of this format are shown in Table 1.

[0015] [Table 1]

[0016] Adding two numbers, such as 0.5 and 1.5, does not change the anchor (-4), so the sum is conveniently obtained by adding only the i values. Because HPA summation is just two's complement addition, over sufficient range, HPA summation is associative, exact, and repeatable.

[0017] FP numbers have a wide range. Double precision numbers (FP64) can be less than 2-1000 and greater than 21000, but most accumulations do not span this entire range. In practice, it is hard to imagine a problem where all values ​​in this range can be meaningfully added, and even in HPC most accumulations are limited to this range. 200 bits seem to be sufficient for most applications that require arithmetic larger than double precision arithmetic. Suppose a programmer determines that all the data in a sum are smaller than 2100, and that bits smaller than 2-50 do not meaningfully affect the sum. If we add data in HPA format (i,-50) with i being 200 bits, the accumulation is associative and we can add at least 249 numbers in any order without worrying about overflow.

[0018] Most modern architectures have Single Instruction Multiple Data (SIMD) units that can be used to represent long integers. With some additional logic to facilitate carries between 64-bit lanes, a 256-bit SIMD unit can be used to add 256-bit integers. Alternatively, most additions can avoid carries between lanes by using a redundant representation, as described in more detail below. One approach to representing an HPA (anchor data) value (or a long integer) in a SIMD register is to assign several HPA (anchor data) elements of an HPA value to each vector lane in a single SIMD register. Alternatively, as described below, each anchor data element of an HPA value can be assigned to a corresponding vector lane in several different SIMD registers, with each part of the total anchor data value in a corresponding location in a different vector register, and a single vector register can contain several anchor data elements, each part of a different anchor data value (HPA value).

[0019] In the following technique, an apparatus includes a processing circuit for performing data processing, and an instruction decoder for decoding instructions for controlling the data processing performed by the processing circuit. The instruction decoder may support instructions for controlling the processing circuit to perform an anchor data processing operation that generates a result anchor data element of an anchor data value that is composed of one or more anchor data elements, each of which represents a respective portion of a bit of a two's complement number. The anchor data processing operation depends on anchor information that indicates at least one characteristic that indicates a range of values ​​that can be represented by the result anchor data element or the anchor data value. Using the anchor information, depending on the range of values ​​for a given application that the programmer or compiler expects, the architecture can support a wide range of numbers in the anchor data format while limiting the number of bits used in the calculation. However, sometimes the programmer or compiler may not have set the anchor information properly, and inputs may be provided to a set of operations that cannot be represented in the anchor data format within the allowed range of values ​​defined by the anchor information. Thus, the anchor data processing operation may cause an underflow or overflow of the two's complement number represented by the anchor data value, causing the correct value of the processing result to be larger or smaller than the range of values ​​that can be represented by the anchor data value. One approach to handling such overflows or underflows would be to simply signal an exception that could trigger the software to take some responsive action, but this can be difficult for the software to determine how to respond.

[0020] In the techniques described below, the processing circuitry and instruction decoder may support making available to software usage information indicating at least one of the cause of the overflow or underflow and an indication of how to change the format of the anchor data values ​​to prevent the overflow or underflow. The indication of the format change may be, for example, an indication of the number of additional anchor data elements provided in the anchor data format, an indication of the total number of additional anchor data elements, and / or an indication of updated anchor information.

[0021] Thus, in the event of an overflow or underflow, the hardware returns information about why the overflow or underflow occurred and / or instructions on how to change the format of the anchor data value to prevent the overflow or underflow, to help the software decide how to proceed. This can support software algorithms that may dynamically adjust the format of the anchor data value (e.g., changing the anchor information and / or number of elements), as described below. This makes it much easier for software developers to design software that uses anchor data processing. The storage of usage information in a software-accessible storage location may be performed automatically by the hardware in response to the anchor data processing operation that triggered the overflow or underflow, without requiring a dedicated state storage instruction to control the storage of usage information.

[0022] The anchor information may indicate one or more different characteristics of the anchor data elements or the anchor data values ​​as a whole that are generated in a given anchor data processing operation. For example, the at least one characteristic may comprise at least one of the following: The significance of the portion of the bits represented by the Result Anchor Data Element; the width in bits of the two's complement portion represented by the Result Anchor Data Element, the relative position of the resulting anchor data element with respect to one or more other anchor data elements of the anchor data value, and · The total number of anchor data elements contained in the anchor data value.

[0023] The anchor information does not have to exhibit all of the above properties. In this context, "significance" refers to the particular power of 2 represented in a given bit position. For example, the power of 2 in a 2's complement bit is 4 The bit value representing 3 The most significant bit of a two's complement number representing 0 is considered to have greater significance than the bits of a two's complement number representing 0. That is, the most significant bit of a two's complement number has the highest significance and the least significant bit has the lowest significance.

[0024] As mentioned above, when anchor data processing is performed by a vector operation, it is possible either to distribute different data elements of the same anchor data value across multiple lanes in a single vector register, or to stripe each data element of the same anchor data value across corresponding lanes of multiple vector registers. In the first case, the anchor metadata can specify the total number of anchor data elements for the anchor data value, or a separate variable can define the number of anchor data elements. In the second case, the anchor metadata itself does not need to indicate the total number of anchor data elements, since a given anchor data processing instruction can only see elements of one anchor data value at a time, and therefore the anchor metadata provided as a source operand for the anchor data processing operation does not need to define the total number of anchor data elements. In this case, the total number of anchor data elements can be specified separately using a variable held by the program controlling the anchor data processing. This variable can be used to control how many anchor data processing instructions are executed to process each anchor data element of a given anchor data value, each of which operates on elements of a different register.

[0025] Usage information may be returned for anchor data processing operations that may cause an overflow or underflow of the anchor data value. However, it may be particularly useful when the anchor data processing operation includes a conversion operation that relies on converting a floating-point value into a result anchor data element that represents a portion of the bits of the two's complement equivalent of the floating-point value. A common cause of overflow or underflow of an anchor data value is the possibility that a floating-point value provided as input to a sequence of operations to be performed using the anchor data processing is outside the numerical range defined in the anchor information. Thus, in such a floating-point to anchor data conversion operation, an overflow or underflow is signaled if the exact representation of the numerical value of the floating-point value in the anchor data format requires at least one more significant bit or one less significant bit than can be represented in the allowed numerical range. A float-to-conversion operation may be a single convert operation that converts a floating-point value into an anchor data element but with further processing of the anchor data element, or a convert-and-add operation that converts a floating-point value and also adds the converted anchor data element to a second anchor data element.

[0026] For such floating-point to anchor data conversion operations, in some examples, the usage information may include information derived from the exponent of the floating-point value that causes an overflow or underflow. This helps the software to determine from the usage information what changes are needed to the anchor data value and / or the total number of anchor information elements to accommodate the same floating-point value if the same sequence of operations is later retried. The information derived from the exponent may be expressed in different ways. In some cases, the usage information may simply include the exponent itself. Alternatively, the usage information may include a flag indicating whether the exponent is within an allowed numeric range. Sometimes, processing a floating-point value within an allowed numeric range may cause an overflow or underflow if the result of adding multiple anchor data values, each corresponding to a floating-point value close to the maximum value of the allowed range, exceeds the allowed range. Thus, an indication of whether the exponent of the converted floating-point value is within range helps the software to determine whether a single additional anchor data element may be sufficient for the anchor data value to accommodate the overflow, or whether more elements may be needed. Other examples of usage information (depending on the exponent of the floating-point value being converted) may be an indication of how far the exponent is out of expected range, or an indication of the number of additional elements required in the anchor data value to store a numeric equivalent of the floating-point value in the anchor data value having the allowed numeric range defined in the anchor information. All of these examples allow software to determine how to update the format of the anchor data value to accommodate floating-point values ​​that have caused an overflow or underflow.

[0027] Alternate implementations may select a different software-accessible storage location in which to store the usage information, which may also be a memory location.

[0028] However, in other examples, the software accessible storage location may be: a destination register used to store the result anchor data element; and At least one of a general-purpose register and a special-purpose register in addition to the register in which the result anchor data element is stored Includes at least one of the following.

[0029] It may be useful for the software accessible storage location to include the same destination register that is also used to store the result anchor data element generated by the anchor data processing operation that caused the overflow or underflow. This means that no additional store operations to memory are required, and may also only require a single register write for the anchor data processing instruction, helping to reduce microarchitectural complexity. In an instruction set architecture, there are relatively few instructions that require updating more than one destination register, so many microarchitectural implementations may only provide one register write port. Thus, avoiding the need for a second register write port for returning usage information may contribute to reducing circuit area and power consumption. Alternatively, even if the device has more than one register write port, the second write port may be used to perform different register writes in response to different instructions when processing the anchor data processing operation, rather than being used for the same instruction as the first register write port. Thus, storing the usage information in the same register as the result may improve the efficiency of the microarchitectural implementation.

[0030] The usage information may be written into some bits of the destination register that would normally store part of the two's complement value of the result if no overflow or underflow has occurred. This may seem undesirable as the result itself cannot be fully represented, but in fact if an overflow or underflow occurs the operation will often be repeated at a later time with a different value of the anchor information, so at this point the actual numerical value represented by the anchor data element where the overflow or underflow occurred is no longer important. Therefore the need for additional storage can be avoided by reusing bits that would normally be part of the data value itself to signal the usage information. The usage information may therefore be specified within part of the result anchor data element itself.

[0031] In a subsequent anchor data processing operation, if the input anchor data element for a given operation specifies usage information for some of the anchor data elements, the processing circuitry may also generate a result anchor data element that specifies the usage information. The usage information is therefore said to be sticky in the sense that once set, it persists throughout a series of processing results, so that at the end of a series of processing operations, the software can examine the final results to determine if any operation in the series caused an overflow or underflow, and learn from the usage information the possible causes and / or instructions on how to change the format of the anchor data value to prevent the overflow or underflow. In an implementation in which the usage information includes some information derived from the exponent of the floating-point value that indicates how far the floating-point value is outside the allowed range (e.g., the exponent itself, or the difference between the exponent and a valid exponent that corresponds to the boundary of the allowed numerical range), if, after the input anchor data element specifies usage information, a floating-point value is encountered that is further outside the numerical range already indicated by the usage information in the input anchor data element, a result anchor data element may be generated with updated usage information that is updated based on the exponent of the floating-point value of the latest anchor data processing operation. Thus, over a series of anchor data processing operations, the usage information may be gradually updated to track the floating-point value and / or the number of elements of the anchor data value that is furthest from the tolerance range defined in the anchor information.

[0032] In another example, the software accessible storage location may include at least one of a general purpose register and a dedicated register separate from the register in which the result anchor data element is stored. This may require a second register, but has the advantage that the numerical value of the result anchor data element can be stored along with the usage information. Again, if the usage information indicates how far the inputs of an operation are outside of the expected range, the usage information stored in the separate register may again be updated in successive operations to track the maximum margin of out-of-range seen in the series of operations.

[0033] In some examples, the anchor information associated with a given anchor data element may include element type information indicating whether the element is the most significant, middle, or lowest anchor data element of the anchor data value. This is useful for supporting striping of anchor data values ​​across multiple registers and / or supporting anchor data values ​​of lengths different from the lengths of the individual vector registers. The instruction decoder may use the element type information in the anchor information to control the processing circuitry to determine whether usage information needs to be generated and stored in a software accessible storage location if an overflow or underflow is detected in a given anchor data processing operation. For example, if the current operation is generating the middle or lowest anchor data element of a given anchor data value, an overflow may not only signal that the anchor information is inappropriate to say, but may also indicate that there was a lane overflow in the anchor data value because overlap propagation was not performed sufficiently, as described below. In some cases, more serious response actions, such as triggering an exception, may be required to handle a lane overflow, beyond simply reporting usage information. Thus, in some cases, the usage information generated upon overflow may be limited to cases where the anchor data processing operation is an operation that generates the most significant anchor data element of the anchor data value.

[0034] On the other hand, for an operation that generates the most significant anchor data element of a given anchor data value, it may not be necessary to report usage information because if an underflow occurs there is a lower element calculated by another instruction that can again accommodate the less significant bits of the result. Thus, reporting of underflow via usage information may be limited to anchor data processing operations where the anchor information indicates that the resulting anchor data element is the least significant anchor data element of the anchor data value.

[0035] It is not mandatory to report both overflows and underflows with the usage information. In some systems, underflows may not be important to track since they simply lead to loss of precision, while overflows may be more important since they can lead to values ​​of the wrong magnitude. Therefore, some implementations may set the usage information in response only to overflows and not to underflows.

[0036] As described below, in some examples, the hardware architecture may automatically return usage information to a software-accessible location, but software running on the hardware may then use the usage information to determine how to respond to overflow or underflow, for example, by providing additional elements and / or changing the format of anchor data values ​​by modifying the anchor information.

[0037] However, in other implementations, hardware may be provided to automatically use the usage information to adapt the format of the anchor data value, so that the programmer / compiler does not need to include instructions to check the usage information. Thus, in some examples, the processing circuitry may: extending the anchor data value by at least one additional anchor data element at a most significant end of the anchor data value if an overflow is detected in a portion of the sequence of processing operations which includes the anchor data processing operation; extending the anchor data value by at least one additional anchor data element at a least significant end of the anchor data value if an underflow is detected in the portion of the sequence of processing operations; and extending the anchor data value with at least one additional anchor data element at a most significant end of the anchor data value and at least one additional anchor data element at a least significant end of the anchor data value if both an overflow and an underflow are detected in the portion of the sequence of processing operations. may be operable to perform at least one of:

[0038] In another example, a data processing method can include a sequence of data processing operations including at least one anchor data processing operation. In this method, a checkpoint of the architectural state can be captured prior to executing a portion of the sequence of data processing operations. This checkpoint need not be a complete record of the current architectural state, but can include at least the architectural state that may be overwritten during execution of the portion of the sequence of data processing operations, which portion is then executed including at least one anchor data processing operation that generates a result anchor data element based on the anchor information as described above. Overflow or underflow detection can be performed to detect whether the at least one anchor data processing operation causes an overflow or underflow of the anchor data value. If an overflow or underflow is detected, a previously captured checkpoint of the architectural state can be restored, a format of the anchor data value can be changed, and the same portion of the sequence of data processing operations can be retried based on the changed format and the restored checkpoint of the architectural state.

[0039] This method allows a software routine to automatically detect if an overflow or underflow has occurred, and if so, adjust the anchor data format (e.g., change the number of elements and / or the anchor information) and retry the operation, allowing the program to react and learn from the operations it has performed when the programmer or compiler has set the anchor information improperly. This can significantly reduce the programmer's burden when programming software that performs anchor data processing. For example, a library can have routines that perform such a method and can be called by a given program to process a specific number of floating-point values ​​in an anchor data format that includes a number of conversions and additions. Checkpoints of the architecture state can be captured at intervals throughout the sequence of processing operations that are performed, adding additional lanes or automatically updating the anchor information if an overflow or underflow is detected, allowing previous parts to be retried if necessary, thereby allowing the anchors to be dynamically adjusted and the range of magnitudes of a given floating-point input to be advanced without the programmer having to predict them.

[0040] On the other hand, if, in performing the overflow or underflow detection, it is detected that at least one anchor data processing operation did not cause an overflow or underflow, the method may include capturing a further checkpoint of the architecture state resulting from a portion of the data processing operations before performing a next portion of the sequence of data processing operations, the next portion being processed in the same anchor data format as the previous portion without updating the anchor information or number of elements, and optionally stopping the sequence and converting the result in the anchor data format to a floating point format or other numeric format if the previously completed portion was the last portion.

[0041] It may be particularly useful for the format change made when an overflow or underflow is detected to include extending the number of elements in the anchor data number format to provide at least one additional anchor data element, so that part of the code sequence can be retried in a format capable of expressing a larger range of significance, and to accommodate a range of values ​​that could not be expressed before.

[0042] If an overflow is detected, modifying the format may include extending the anchor data value by at least one additional anchor data element at a most significant end of the anchor data value. If at least one additional element is provided at a most significant end of the anchor data value, when the portion of the sequence is retried with an updated number of elements, the newly added elements may be initially populated with a sign extension of the existing elements of the anchor data value (represented in the checkpoint of the captured architectural state).

[0043] If an underflow is detected, modifying the format may include extending the anchor data value by at least one additional anchor data element at a lowest end of the anchor data value. If the at least one additional element is provided at a lowest end of the anchor data value, the newly added element may be initially populated with zeros when the portion of the sequence is retried.

[0044] Also, both overflow and underflow may have occurred in the immediately preceding processing portion of the code sequence (e.g., processing may be based on one floating point input that is lower than the range represented by the anchor data value and another floating point input that has a greater significance than the range represented by the anchor data value). If both overflow and underflow are detected in that portion of the sequence of data processing operations, modifying the format may include extending the anchor data value with at least one additional anchor data element at the most significant end of the anchor data value and at least one additional anchor data element at the least significant end of the anchor data value.

[0045] The overflow or underflow detection may be performed at any point during the sequence of operations, in some examples the overflow or underflow detection may be performed in response to each anchor data processing operation.

[0046] However, it may be more efficient to check for overflow or underflow at intervals throughout the sequence rather than in response to each anchor data processing, so overflow or underflow detection may be performed at intervals corresponding to a given number of anchor data processings.

[0047] In some examples, the anchor data element may be represented using a redundant representation in which some duplicate bits are allocated within the element to accommodate carries resulting from additions performed on less significant parts of the data element. This may reduce the chance of an overflow of the anchor data element due to a series of anchor data processing operations. The representation may be redundant in the sense that there may be many different patterns of bits in the anchor data value formed by multiple anchor data elements that are different combinations of duplicate and non-duplicate bits and all can represent the same numeric value in two's complement. More details are provided below.

[0048] Thus, in general, an anchor data element may include an N-bit value that includes V overlapping bits and W non-overlapping bits. The particular number of overlapping and non-overlapping bits may be fixed or may be variable, for example as specified by information in the anchor metadata described above.

[0049] In a floating-point to anchor data conversion operation that converts a floating-point value to an anchor data element, if the floating-point value represents a number other than a special number (NaN or infinity) and the number is within the permissible numerical range for the anchor data value that the anchor data element constitutes, the processing circuitry may set the W non-overlapping bits of the anchor data element to represent a portion of the bits of a two's complement number corresponding to the floating-point value. Meanwhile, the V duplicated bits of the anchor data element may be set to a sign extension of the W non-overlapping bits. Thus, initially, the duplicated bits may be set to a sign extension, e.g., all zeros or all ones. However, when the anchor data element produced by the floating-point to anchor data conversion operation is subjected to a series of addition operations, some carries may occur in the duplicated bits. In order to compute the two's complement number represented by the entire anchor data value in a non-redundant representation, a duplicate propagation operation may be performed in which the carry represented by the duplicated bits of one anchor data element is propagated to the non-duplicated bits of the anchor data element next higher in the anchor data value.

[0050] Thus, in some examples, the detection of overflow or underflow (and the restoration of the checkpoint and the change of the format of the anchor data value if an overflow or underflow is detected) may be performed at the time of performing the overlap propagation operation to propagate the carry represented by the V overlapped bits of the first anchor data element to the W non-overlapping bits of the second anchor data element. Performing the check for whether an overflow or underflow has occurred at the time of overlap propagation may be convenient as it means that the detection of overflow or underflow will be performed less frequently, but also means that the overhead of the overlap propagation operation itself can be avoided if an overflow or underflow occurs and an earlier part of the sequence operation needs to be repeated. Thus, in practice the detection of overflow or underflow may be performed before the overlap propagation operation so that the overlap propagation operation can be suppressed if an overflow or underflow occurs.

[0051] In some examples, changing the format of the anchor data value may depend on usage information, as described above, stored in a software accessible location in response to an operation that causes an overflow or underflow. Thus, returning usage information at an architectural level (without requiring dedicated instructions specifying the usage information) can support dynamic anchor information update methods, as described above.

[0052] However, dynamic updating of the format of the anchor data values ​​can also be performed without using the usage information. For example, one possible approach would be that if an overflow is detected, the format change could simply follow some default action, such as extending the width of the anchor data value by one data element, and in the case of an underflow, lowering the significance of the least significant bit of each anchor data element of the anchor data value (in addition to increasing the number of elements). Although the usage information allows for faster arrival at the correct anchor data format for a given set of operands, an architecture that does not return usage information nevertheless allows a software routine to incrementally adjust the total number of elements and / or the anchor information each time an overflow or underflow occurs, until no overflow or underflow occurs.

[0053] Although it is useful to provide dynamic updating of the anchor data format and to retry portions of code sequences that previously caused an overflow or underflow, in some cases such retries may be undesirable, and therefore it is not mandatory to perform a retry every time an overflow or underflow is detected.

[0054] In some examples, if an overflow or underflow is detected, the method may include determining whether the usage information satisfies at least one retry condition, and if the usage information satisfies the at least one retry condition, modifying a format of the anchor data value based on the usage information and retrying a portion of the sequence of data processing operations based on the modified format (similar to the examples above), and if the usage information does not satisfy the at least one retry condition, terminating the sequence of data processing operations or continuing the series of data processing operations without retrying the at least one portion (similar to the examples above).

[0055] If the usage information does not satisfy the at least one retry condition and therefore processing is terminated or continues without retrying, the method may include returning the usage information or other information related to the overflow or underflow to aid in evaluating how to avoid future overflow / underflow.

[0056] For example, at least one retry condition is: the overflow or underflow margin is less than a predetermined amount; The number of additional anchor data elements required to prevent overflow or underflow is no more than a predetermined number; and that the number of previous attempts to retry that portion of the sequence of data processing operations is less than a predetermined threshold; Includes at least one of the following.

[0057] For example, if the overflow / underflow margin is such that a large number of additional anchor data elements are required to prevent overflow / underflow, simply extending the number of elements by that large number may be inefficient, e.g., this may indicate that the significance of the anchors is set improperly, and simply extending the number of elements may risk many wasted processing operations where some elements of the anchor data values ​​are completely filled with zeros or sign bits because the magnitude of the actual input operands being processed is far outside the range defined by the original anchor information. In such cases, it may be more efficient to terminate the sequence and return information about the overflow that occurred, so that the returned information can be examined in more detail to determine how future anchor information and / or lane numbers should be set. Alternatively, rather than terminating, it may be preferable to be able to continue the sequence of processing operations without terminating the sequence of processing operations (and without retrying previously executed parts) in order to gather more information about any further overflows / underflows that may occur in the remainder of the sequence.

[0058] Thus, it is not essential that each case of detecting overflow / underflow is handled by dynamic updating of the lane number and / or anchor information, and the method may include determining whether a particular condition or conditions for dynamic updating are met, and then performing the dynamic update and retrying when at least one retry condition is met.

[0059] Upon completion or termination of the entire sequence of data processing operations, the method comprises storing in a software accessible storage location: A condition that required retrying part of a sequence of data processing operations; the final number of anchor data elements contained in the anchor data value when the sequence of data processing operations is completed; and final anchor information resulting from any updates made during execution of the sequence of data processing operations; The method may include storing information indicative of at least one of the following:

[0060] This helps provide some information as to why a portion of a sequence required a retry, which can help a software developer or compiler determine how to best set the anchor information for a given program in the future, thereby improving performance by reducing the likelihood that many retries will be required to execute a particular portion of a sequence of operations.

[0061] A specific example will now be described with reference to the drawings.

[0062] The following describes the HPA (High Precision Anchor) format. Details regarding the HPA format can be found in U.S. Patent Application Nos. 62 / 074,149, 14 / 582,974, 14 / 582,875, 14 / 582,812, 14 / 582,836, 14 / 582,978, 14 / 606,510, and 14 / 582,968, the contents of which are incorporated herein by reference in their entirety.

[0063] Floating-point numbers Floating-point (FP) is a useful way to approximate real numbers using a small number of bits. The IEEE 754-2008 FP standard proposes several different formats for FP numbers, some of which are binary 64 (also called double precision (DP)), binary 32 (also called single precision (SP)), and binary 16 (also called half precision (HP)). The numbers 64, 32, and 16 refer to the number of bits required for each format.

[0064] expression FP numbers are very similar to the "exponential notation" we learned in science class. Instead of negative 2 million, we have -2.0 x 10 6 The parts that make up this number are the sign (negative in this case), the mantissa (2.0), the exponent base (10), and the exponent (6). All of these parts are similar to FP numbers, with the most important differences being that the components are stored in binary, and the exponent is always base 2.

[0065] More precisely, an FP number includes a sign bit, a number of biased exponent bits, and a number of fraction bits. Specifically, the DP, SP, and HP formats include the following bits:

[0066] [Table 2]

[0067] The sign is 1 for negative numbers and 0 for positive numbers. Every number has a sign, including zero.

[0068] Exponents are biased, that is, the true exponent is different from the one stored in the number. For example, biased SP exponents are 8 bits long and range from 0 to 255. Exponents 0 and 255 are special cases, but all other exponents have a bias of 127, meaning that the true exponent is 127 less than the biased exponent. The minimum biased exponent is 1, which corresponds to the true exponent -126. The maximum biased exponent is 254, which corresponds to the true exponent 127. HP and DP exponents behave in a similar way, and have the biases shown in the table above.

[0069] SP exponent 255 (or DP exponent 2047, HP exponent 31) is reserved for infinity and a special symbol called NaN (not a number). Infinity (which can be positive or negative) has a fraction of zero. Any number with exponent 255 that has a nonzero fraction is NaN. Infinity provides a saturation value, so it actually means something like "this calculation resulted in a number larger than can be represented in this format". NaN is returned for operations that are mathematically undefined on real numbers, such as division by zero or taking the square root of a negative number.

[0070] Exponent zero is reserved for subnormal numbers and zero in any format. Normal numbers represent the following values: -1 符号 x1. Fraction x2 e where e is the true exponent calculated from the biased exponent. The word 1.fraction is called the mantissa, and the 1 is not stored as part of the FP number, but is instead inferred from the exponent. All exponents except zero and the maximum exponent indicate a mantissa of the form 1.fraction. Exponent zero indicates a mantissa of the form 0.fraction and a true exponent equal to 1 bias for the given format. Such numbers are called subnormal (historically such numbers were called denormal, but in modern times the term subnormal is preferred).

[0071] A number with both exponent and fraction equal to 0 is zero.

[0072] The following table is an example of a number in HP format. The entries are in binary, with "_" added for readability. Note that the deregular entry (fourth row of the table, with exponent 0) produces a different mantissa than the regular entry on the previous row.

[0073] [Table 3] Table 3

[0074] Most of the complexity in FP implementations comes from contra-normals, which are often handled in microcode or software. Some processors handle contra-normals in hardware, making these operations 10 to 100 times faster than software or microcode implementations.

[0075] Integer, fixed point, floating point FP's sign handling is called "sign-magnitude" and differs from the way integers are normally stored in computers (2's complement). In sign-magnitude representation, positive and negative versions of the same number differ only in their sign bit. A 4-bit sign-magnitude integer, containing a sign bit and three mantissa bits, represents plus one and minus one as follows: +1=0001 -1=1001

[0076] In two's complement representation, a (n+1)-bit binary integer is the number iS*2 n where i is an n-bit integer, represented by the lowest n bits of an n+1-bit value, and S is the bit value (0 or 1) of the most significant bit of the (n+1)-bit value. Thus, unlike with signed magnitude numbers, where the sign bit modifies the sign of all other bits in the value, for two's complement values ​​the most significant bit is weighted negatively and all other bits are weighted positively. Thus, a 4-bit two's complement integer represents plus 1 and minus 1 as follows: +1=0001 -1=1111

[0077] Two's complement format is the virtually universal format for signed integers because it simplifies computer arithmetic.

[0078] Fixed-point numbers, on the other hand, represent values ​​that look the same as integers, but actually have a specific number of bits. Sensor data is often in fixed-point format, and there is a lot of fixed-point software written before FP was widespread. Fixed-point is very tedious to work with, because the programmer must always keep track of the "binary" system, i.e., where the integer and fractional parts of a number are separated, and they must constantly shift numbers to keep the bits in the correct place. FP numbers do not have these difficulties, so it is desirable to be able to convert between fixed-point and FP numbers. Being able to convert also means that you can continue to use fixed-point software and data, and you are not tied to fixed point when writing new software.

[0079] Rounding FP numbers The IEEE-754 standard requires that most FP operations are computed as if the operation were unrestricted in range and precision, and then rounded to fit into a FP number. If the result of a calculation is an exact FP number, that value is always returned, but usually the result will be between two consecutive floating-point numbers. Rounding is the process of choosing which of two consecutive numbers should be returned.

[0080] There are several ways to round, called rounding modes, of which there are six:

[0081] [Table 4]

[0082] This definition makes it unclear how the rounding actually occurs. One common implementation is to perform the operation, look at the truncated value (i.e., the value that fits into the FP format) as well as all the remaining bits, and adjust the truncated value if certain conditions hold. All of these calculations are based on the following: L - (minimum) the least significant bit of the truncated value G - (Guard) The next most significant bit (i.e., the first bit not included in the truncation) S - (Sticky) The logical OR of all remaining bits that were not part of the truncation Given these three values ​​and the truncated value, we can always calculate the correctly rounded value as shown in the following table:

[0083] [Table 5]

[0084] For example, consider multiplying two 4-bit mantissas and rounding to a 4-bit mantissa. sig1=1011 (decimal 11) sig2=0111 (decimal 7) Multiplying gives us sig1×sig2=1001_101 (77 in decimal) L Gss It becomes.

[0085] The least significant bit of the truncated 4-bit result is labeled L, the next bit is labeled G, and S is the logical OR of the remaining bits labeled s (i.e., S=0|1=1). To round, the 4-bit result (1001) is adjusted according to the rounding mode and the calculations in the table above. For example, with RNA rounding, since G is set, it would return 1001+1=1010. With RX rounding, since G|S is true, it sets L to 1 (no change in this case since it was already 1) and returns 1001.

[0086] Rounding of integers and fixed-point numbers Rounding is also used when converting FP numbers to integers or fixed-point numbers. The idea is basically the same as FP rounding. If the FP number happens to be an integer, it will always be rounded to that integer. Any other FP number lies between two consecutive integers, and rounding will determine which integer is returned. Unfortunately, the logic for rounding integers is made a bit trickier by the differences between two's complement and sign-magnitude formats. When a sign-magnitude number is incremented, it always gets larger in magnitude, so the incremented number gets further away from zero. The same is true for positive two's complement numbers, but negative two's complement numbers get closer to zero when incremented. This means that the logic for rounding must be different depending on whether the integer is positive or negative. It also means that care must be taken with the choice of base value (the value to increment or not). For positive integers, the value is the FP mantissa truncated, so 1.37 has a base value of 1 and the result is either 1 or 2. For negative integers, we again truncate the mantissa and take the one's complement of that result (the one's complement is the original number with all the bits flipped). -1.37 gets truncated to 1 and then inverted, giving us the base value -2. All is well since we want the result to be either -2 or (when incremented) -1.

[0087] To further complicate things, this conversion method requires several calculations to determine L, G, and S for negative integers. Correct rounding requires completing two's complement processing (inverting and adding 1) before calculating L, G, and S, which is slower than just inverting. Ideally, we would like to calculate the actual L, G, and S from the shifted original input (i.e., the input before any sign manipulation) (the floating-point numbers 1.37 or -1.37 are both right-shifted to the integer 1).

[0088] Let L0, G0 and S0 be the least significant bit (lsb), guard and sticky before inversion, Li, Gi and Si be the lsb, guard and sticky after inversion, and finally L, G and S be the lsb, guard and sticky after inversion and adding 1.

[0089] If S0 is zero, then all the bits contributing to Si are 1, and therefore S (obtained by adding 1 to those Si bits) is also zero. If S0 is not 0, then Si is not all 1, and therefore S is not 0. Thus, in all cases, S0=S.

[0090] If G0 is zero, then Gi is 1 and G is 1, except if there is a carry-in from the S bit, which can only occur if S0 is zero. If G0 is 1, then Gi is zero and G is 1, except if there is a carry-in from the S bit, which can only occur if S0 is zero. That is, G=G0^S0.

[0091] By similar logic, L = L0^(G0|S0).

[0092] Now that we know L, G, and S for negative and positive integers, we can consider the rounding rules.

[0093] [Table 6]

[0094] Fixed-point numbers are rounded in exactly the same way as integers. The rules for unsigned conversion (to integer or fixed-point) are the same as the rules for positive conversion.

[0095] Injection rounding A way to make rounding faster is to inject a rounding constant into the mantissa addition that is part of almost every FP operation. To see how this works, consider adding numbers in dollars and cents and rounding to dollars. For example, add:

number

[0096] The sum, $3.62, is closer to $4 than to $3, so we know that any of the round-to-nearest modes will return $4. If we express the numbers in binary, the L, G, and S rounding methods from the previous section would give us the same result. But what if we added 50 cents and then rounded the result down?

number

[0097] If we're just returning the dollar amount ($4) from the sum ($4.12), we'll round correctly using RNA rounding mode. If we're adding $0.99 instead of $0.50, we'll round correctly using RP rounding. RNE is a bit more complicated. We add $0.50, truncate, and look at the cents remaining. If the cents remaining are not 0, then the truncated result is correct. If the cents remaining are 0, then we were exactly halfway between two dollars before the injection, so we choose the even dollar amount. In binary FP, we'll zero out the least significant bit of the dollar amount.

[0098] Adding three numbers is only slightly slower than adding two numbers, so injection rounding allows us to get a rounded result much faster than adding the two mantissas, checking L, G, and S, and incrementing the result depending on the rounding mode.

[0099] Implementing Injection Rounding In FP, injection rounding can be one of three different values, depending on the rounding mode and (sometimes) the sign of the result.

[0100] In both RNA and RNE, you need to inject a 1 into the G position (like adding $0.50 in the dollars and cents example).

[0101] RP and RM rounding depends on the sign as well as the mode. RP rounds up positive results (increasing the mantissa size towards positive infinity) but truncate negative results (selecting the mantissa closer to positive infinity). Similarly, RM rounds up negative results (increasing the mantissa size towards negative infinity) but truncate positive results (selecting the mantissa closer to negative infinity). We therefore separate RM and RP into two cases: round when the sign matches the round direction (RU) and truncate when the sign differs from the injection round (RZ). In the RU case, we inject 1s into the G bit position and all positions that logically contribute to S (like adding $0.99 in our dollars and cents example).

[0102] 0 is injected into RZ mode and RX mode, and into RP mode and RM mode which are reduced to RZ mode.

[0103] For most rounding modes, adding injection rounding and then truncating will give the correct rounded result. The two exceptions are RNE and RX, which require checking G and S after the addition. For RNE, if G and S are both zero, set L to 0. For RX, if G or S is not zero, set L to 1.

[0104] FP numbers are not real numbers Although FP numbers are often thought of as being similar to real numbers, even their most basic properties are fundamentally different.

[0105] The two are not related. For example, in SP you can add three numbers and get back either 1 million or 0, but this is probably not what you would typically think of as a rounding error. (245 +-2 45 )+2 20 =2 20 2 45 +(-2 45 +2 20 )=0 Neither of these obeys the distributive law. Again in SP: 3,000,001*(4.00001+5.00001)=0x4bcdfe83 (3,000,001*4.00001)+(3,000,001*5.00001)=0x4bcdfe82 If an overflow occurs, the situation becomes even worse. 2 50 *(2 78 -2 77 )=2 127 (2 50 *2 78 )-(2 50 *2 77 ) = infinity

[0106] In some implementations, they are not even commutative, unless in the default NaN mode (which converts all NaNs to a single NaN), since in general nanA+nanB != nanB+nanA. Numeric addition and numeric multiplication are commutative.

[0107] Due to the IEEE NaN rule, there are no multiplication or addition identities: 1 and 0 serve as numeric identities.

[0108] One useful way to think of FP numbers is as very long fixed-point numbers with at most a few consecutive bits (53 bits for DP) that are nonzero. For example, a non-infinite DP number has the first bit of the mantissa in one of 2046 locations, followed by 52 other mantissa bits, plus a sign bit, so any finite DP number can be represented as a 2046+52+1=2099-bit fixed-point number. Thinking about it this way makes it clear that adding two FP numbers does not, in general, result in a different FP number, and the result of the addition must be rounded to be a FP number.

[0109] A known problem with floating-point (FP) arithmetic is that it is non-associative, which means that sums are a problem. Programmers need to be aware that even when adding three numbers, the results can be very different. · Programmers use formats that are wider than necessary to avoid wildly different results. · The programmer cannot easily parallelize the code because the sum can only be reproduced in the exact same order.

[0110] For example, in single precision: 2 20 +(-2 44 +2 44 )=2 20 However, (2 20 +-2 44 )+2 44 =0

[0111] Depending on the order in which the operations are performed, you will either get a result of 1 million or 0. This is an extreme example where the exponents differ by 24, but you can get different answers if the exponents differ by 1, or even if you are adding more than three with all the exponents the same. The C programming language deals with the reproducibility problem by evaluating the sums in order from left to right, but this does nothing to improve correctness and cannot be parallelized.

[0112] This problem is especially prevalent in high performance computing (HPC), where millions of operations are executed. Programmers want to parallelize these problems, but they are harder to debug than usual because they are not reproducible. Also, different machine configurations will produce different answers, even if the machine is perfectly reprogrammed.

[0113] HPA Representation (Anchor Data Value) A new data type has been proposed that allows fast and accurate accumulation of floating-point (FP) numbers in a programmer-selectable range. In a reasonable range that covers most problems, the accumulation is faster than FP addition and is associative. Associative addition allows problems to be parallelized with reproducible and correct results, resulting in speedups of, for example, 100x or more compared to existing hardware. These advantages make it attractive for many applications outside of high performance computing (HPC) as well as in the field of high performance computing (HPC).

[0114] FIG. 1 illustrates diagrammatically a data processing apparatus 2 for performing data processing operations under the control of program instructions. The data processing apparatus 2 includes a memory 4 for storing program instructions 6 and data 8 to be processed. A processing core 10 is coupled to the memory 4 and includes a register bank 12, processing circuitry 14, an instruction fetch unit 16, an instruction pipeline unit 18, and an instruction decoder 20. It will be appreciated that in practice the data processing system 2 may include many additional elements and the representation of FIG. 1 has been simplified to aid understanding. In operation, program instructions 6 are fetched from the memory 4 by the instruction fetch unit 16 and fed to the instruction pipeline 18. Once the program instructions reach the appropriate stage in the instruction pipeline 18, they are decoded by the instruction decoder 20 which generates control signals useful for controlling the operation of the register bank 12 and the processing circuitry 14 to perform the processing operation(s) specified by the decoded program instruction. A number of input operands may be read from the register bank 12 and fed to the processing circuitry 14 where they are operated upon before a result value is written back to the register bank 12.

[0115] Register bank 12 can have a variety of different forms. The operands operated on may include, for example, floating point operands, fixed point operands, integer operands, and HPA or RHPA number operands (described below). Register bank 12 may be responsible for storing a mixture of these types of operands, depending on the configuration of register bank 12. The operands can have different levels of precision, either predefined by their format or programmably specified using metadata associated with the registers, as described below in connection with HPA number operands.

[0116] 1, register bank 12 may include metadata registers 22 for specifying metadata associated with HPA or RHPA values ​​stored in corresponding data registers of register bank 12 (examples of metadata content are provided below). In some cases, each data register may have a corresponding metadata register 22, and in other cases, two or more data registers may share metadata specified by a single metadata register 22.

[0117] Figure 2 shows a schematic of a floating-point operand. A floating-point operand is formed by a sign, an exponent, and a mantissa. Floating-point operands can represent values ​​of various magnitudes, indicated by the exponent value. The precision with which numbers can be represented is limited by the size of the mantissa. Floating-point operations are generally more complex and slower than integer arithmetic.

[0118] Figure 2 also shows 64-bit integer operands. Such integer operands range from 0 to (2 64 -1), -2 for signed integers 63 ~2 63 It can represent numbers in the range of -1. Integer arithmetic is characterized by its fast processing speed and relatively low energy consumption for execution (compared to floating-point arithmetic), but it has the disadvantage that it specifies numbers in a relatively limited range compared to the range of numbers that can be expressed by floating-point values.

[0119] FIG. 2 also shows an HPA (High Precision Anchor) number consisting of a vector of components (three in this example) each containing a 64-bit integer. The HPA number has associated metadata. The metadata includes an anchor value indicating the bit significance of each component that is part of the HPA number. The anchor value(s) directly or indirectly specify a lower bit significance limit and an upper bit significance limit. Hereinafter, the term metadata can be considered to correspond to data including anchor value(s) that specify the bit significance of the HPA number. By combining different components, bit values ​​that successively cover a range of bit significance are specified. Depending on the location of the lower bit significance limit and the upper bit significance limit, the range of bit significance can include the location of the binary point. It is also possible that the location of the binary point is outside the range of bit significance specified for a particular HPA value.

[0120] An anchor value or values ​​may be provided that can represent a range of bit significance from the minimum significance representable in a floating-point value (e.g., a double-precision FP value) to the maximum bit significance representable in that floating-point value.

[0121] The number of components that form the HPA number may vary between different implementations. The size of the components is fixed in some implementations, but may vary in others. In some embodiments, the overall width of the bit significance of the range may be constrained to vary in units of a fixed component size (e.g., for a 64-bit component, the bit significance range may have widths of, e.g., 64, 128, 192, 256, ...). It is also possible for the width of the bit significance range to vary continuously in 1-bit-wide steps.

[0122] The anchor value(s) (in the metadata) may be programmable to allow the programmer to set the significance of the corresponding HPA value. The anchor value may specify the bit significance in a variety of different ways. One example is to specify the lower bound bit significance of each vector component. Thus, each vector component may contain an integer value representing the portion of the value's significant bits within the overall range of bit significance, and metadata representing (anchoring) the least significant bit significance within that component. Alternatively, the anchor value(s) may specify the lower bound of the bit significance of the entire HPA number, along with the overall width of the bit significance range. Additionally, the anchor value(s) may contain data specifying the lower and upper bounds of the range representing the bit significance. Additionally, if the components are known to be of fixed width, the anchor value(s) may include variations such as the lower bound of the bit significance range and the number of components.

[0123] Figure 3 shows the relationship between the range of values ​​that can be expressed in double-precision floating-point and the range of significance of HPA numbers. In the case of double-precision floating-point numbers, the range of specifiable bit values ​​is approximately 2 -1074 ~2 +1023 (Non-regular employees are not counted.)

[0124] As shown, the HPA number has a programmable bit significance range that can be thought of as a window of bit significance within the range of bit significance representable using floating-point values. This programmable bit significance is specified by lower and upper boundaries and can be thought of as sliding along the range of bit significance provided by the floating-point value depending on the values ​​of the lower and upper bounds. The width of the window, as well as the start and end points, can be specified by appropriate values ​​of programmable metadata (including anchor values) that specify the bit significance. Thus, the HPA number has a format that can be selected by the programmer to suit the computation being performed.

[0125] The HPA format allows the addition of two or more values ​​to be performed quickly, accurately, and associatively, while still allowing values ​​with a wide range of significance to be represented. Also, because HPA values ​​are simply two's complement numbers, they can be added using integer adders, without the need for rounding or normalization as in floating-point arithmetic, which means that the result is the same regardless of the order in which the values ​​are added, allowing a series of additions to be parallelized. However, by defining metadata that specifies the programmable significance of HPA values, the full range of significance of equivalent floating-point values ​​can be represented, but without the need to have a very wide adder (e.g., adding two two's complement numbers across the full range representable in double-precision floating-point values ​​would require a 2098-bit adder), and instead the programmable significance allows a smaller adder to be focused on a specific window of programmable bit significance within the wide range. In practice, most calculations do not require the full range of significance available in double-precision floating-point. For example, very small values ​​can add up in atomic problems, and very large values ​​in astronomical problems, but adding up the widths of protons to get the distance between galaxies is not typically useful. Even in high-performance computing, most accumulations happen over a limited range.

[0126] Usually, the programmer writing the program knows the range of values ​​(depending on the application) over which useful results are expected to fall. The programmer knows that all the data for a particular sum is 2 60 has a size less than 2 -50 It may be determined that values ​​with a magnitude less than do not significantly affect the sum, in which case the application can add numbers associatively in any order by adding the data using the HPA format with a data width of 128 bits and an anchor value of -50 which specifies the significance of the least significant bit.

[0127] Thus, by using the anchor values ​​to restrict the valid range over which the result is calculated, a relatively small amount of hardware can be used to calculate the result within a programmably defined window. If the addition results in an overflow beyond the upper significance limit of the defined range, or an underflow below the lower significance limit, an exception may be raised, indicating that the programmer has defined the significance bounds incorrectly, and that the process should be repeated using different metadata (e.g., a different anchor value or the overall size of the HPA value) to define a different window of significance for the result.

[0128] When adding or subtracting two HPA values, the anchor value is the same for both HPA values, and the result will have the same anchor value. This differs from floating-point operations where adding or subtracting two values ​​results in a result with a different exponent than either input due to the result being normalized. If inputs are provided with different anchor metadata, they are shifted to match the target significance range required for the result. If the inputs are provided in representations other than HPA (e.g., integer or floating point), they are converted to HPA values ​​with the same anchor value and added to produce a result with the same anchor value. Thus, the metadata for an HPA register can be thought of as defining a target range of significance for result values ​​produced in that register, and bits outside the significance target range are not calculated by the hardware, regardless of the actual significance of the input values.

[0129] RHPA expression Although the HPA format allows for much faster additions than floating-point, adding two HPA values ​​using integer arithmetic can be relatively slow when the size of the HPA values ​​becomes relatively large. For example, the HPA format can require the addition of operands across multiple lanes, which is undesirable for large vector implementations. For example, adding two 256-bit or 512-bit values ​​can be slow because each lane of 64 bits must be added sequentially to accommodate carries coming in from one lane to the next.

[0130] Therefore, by using the redundant high-precision anchor (RHPA) format shown in FIG. 4, addition can be performed more quickly. Similar to the HPA format, an RHPA number includes variable components having metadata that defines an anchor value that enables the processing circuit 14 to identify the significance of each component bit. Here too, the anchor value may be programmable. In the case of RHPA, the metadata may identify the significance of each component in any of the ways described above for HPA. However, in the RHPA format, since numerical values are represented using a redundant representation that includes bits with overlapping significance in adjacent lanes of a vector, addition for a fixed time is possible regardless of the number of lanes being calculated. This redundancy enables operations such as addition, accumulation, and multiplication to be performed without shortening the length of the adder and without propagating carry information between adders. As a result, the processing of data values is significantly accelerated.

[0131] As shown in (1) of FIG. 4, an M-bit data value using the RHPA representation is divided into respective vector lanes (also referred to as components, elements, or parts) each consisting of N bits where N < M. In this example, N is 64 bits, but this is just an example and other lane sizes (such as 32 bits or 128 bits) are also possible. Each N-bit portion is divided into a specific number V of overlapping bits and N - V non-overlapping bits. In this example, the number V of overlapping bits is the same for each N-bit portion, but it is also possible to have N-bit portions with different numbers of overlapping bits.

[0132] When an integer or floating-point number is converted to the RHPA format, some of the non-overlapping bits are filled with unsigned information mapped from the original integer or floating-point number, and the overlapping bits are populated with the sign bit. For lane-based addition and subtraction, each lane behaves like an N-bit signed two's complement number (with carries propagating from the non-overlapping portion to the overlapping portion as necessary), but from a multi-lane perspective, the lanes form a redundant mixed-signed representation of the larger P-bit number. In the example of Figure 4, there are four lanes, so M=256, but the number of lanes can vary depending on the hardware implementation and / or metadata defined for a given RHPA number.

[0133] Part (2) of Figure 4 shows the relative significance of each bit of the RHPA number shown in part (1). The overlapped bit V[0] in the lowest lane has the same significance as the V least significant bits of the non-overlapping bit NV[1] in the next lane. Similarly, overlapped bits V[1] and V[2] have the same significance as the V least significant bits of non-overlapping bits NV[2] and NV[3]. The overlap in significance between lanes means that the entire RHPA number represents a P-bit value that is smaller than the total number of bits stored, M. If V is the same for each N-bit portion (excluding the tip portion), then

number

[0134] For each overlapped portion of a P-bit value, the actual bit value of that P-bit value is the sum of the overlapped bits V in the lower lane and the non-overlapping bits NV in the upper lane (taking into account any carries that may occur when adding the non-overlapping bits NV and the overlapped bits in the lower lane). Therefore, one way to convert an RHPA value to an equivalent integer value is to sign-extend the overlapped bits in each lane and add them to the non-overlapping bits in the upper lane (from lower to higher, adjusting the overlapped bits after each lane addition), as shown in part (3) of Figure 4.

[0135] RHPA numbers are redundant in the sense that there is more than one way to represent a given P-bit number using the M-bit RHPA value. For example, considering overlap of the lowest two lanes, in the example of overlap bit number V=4, if the corresponding bits of the P-bit value are 1111, one way of representing it would be to place the overlap bit V[0]=0b0000 in the lower lane and the non-overlapping bit NV[1]=0b1111 in the next higher lane. However, other ways of representing the same value would be V[0]=0b0101 and NV[1]=0b1010, or V[0]=0b1111, NV[1]=0b0000, etc.

[0136] Note that the overlapping bit V[3] in the top lane is not actually an overlapping bit since there are no overlapping upper lanes. Therefore, it may be useful to think of the upper lanes as having all non-overlapping bits. Thus, in some cases, the top lane can be thought of as being made up of all non-overlapping bits (such that the most significant bit of the P-bit value as a whole corresponds to the most significant bit of the top lane's M-bit value).

[0137] However, in other embodiments, it may be preferable to treat the top lane as having overlapping bits as well, with the most significant bit of the P-bit number represented by the RHPA corresponding to the most significant bit of the non-overlapping portion of the top lane (excluding the overlapping portion). This may facilitate easier circuit implementation if it allows the lanes to be treated more symmetrically (requiring fewer changes in how the top lane is treated compared to the other lanes).

[0138] By representing P-bit numbers redundantly, as in Figure 4, multiple RHPA numbers can be added without carries between lanes because the carry from an addition of the non-overlapping parts in a given lane can be stored in the overlapping parts of the same lane without the need to propagate the carry to the next lane. The additions performed in each lane are added by simply looking at two or more N-bit signed integers and performing a traditional N-bit two's complement addition, and are completely independent of the corresponding N-bit additions in the other lanes. This means that an entire M-bit value can be added in the time it takes to perform an N-bit addition, regardless of the number of lanes, because each N-bit addition can be performed in parallel.

[0139] In reality, at least (2 V-1 −1) such RHPA numbers can be added without carries between lanes, and the carries from adding the non-overlapping parts are collected into the overlapping parts. (If there are lanes with different numbers of overlapping bits, then V in this representation is the minimum number of overlapping bits in any lane that has overlapping bits.) V-1 ) addition is the first one that can potentially generate a carry between lanes. (Because the top duplicate bit is the sign bit, a lane overflow occurs when there is a positive or negative overflow from the second most significant duplicate bit, which can happen at least twice as fast if you start with an RHPA number with all bits 0.) V-1 (This can occur after 8 further additions have been performed). For example, for V=14, at least 8191 RHPA numbers can be added to the accumulator (i.e., 8192 values ​​can be added in total) before there is a risk of overflow from a single lane. This is particularly useful in the field of high performance computing, where adding a large number of input values ​​is common. In practice, not all additions result in a carry into the overflow portion, so that 2 additions can be performed without overflowing the top bit of the N-bit portion. V-1 In some cases, super-accumulation is possible.

[0140] Sometimes, if enough additions are performed from the top bits of an N-bit lane to cause a risk of overflow (or actual overflow), a duplicate reduction operation can be performed to convert the given RHPA value to a second RHPA value whose duplicate bits represent a smaller magnitude than the duplicate bits of the given RHPA value, effectively freeing up the bit space in the duplicated portion to accommodate more carries. Such duplicate reduction may also be performed when converting the RHPA number back to other formats such as integer or floating point. However, in practice, such duplicate reduction operations are rarely necessary, and RHPA can significantly reduce processing time because multiple input M-bit additions can be performed in the time of an N-bit addition. Note that "duplicate reduction" does not necessarily mean that duplicate bits in all lanes must be reduced. It is sufficient to reduce the duplicate bits in at least one lane, and depending on the form of duplicate reduction, the duplicate bits in a given lane may be large.

[0141] Efficient storage and operation of HPA numbers In the following description, it is assumed that the HPA format used is the RHPA format described above in which each portion contains a number of overlapping bits, although the techniques described herein are equally applicable to other HPA formats, e.g., HPA formats in which different portions do not contain overlapping bits. Hereinafter, the term HPA is used to refer to the HPA value being manipulated, regardless of whether the HPA value being manipulated is in redundant form or not.

[0142] As is evident from FIG. 4 above, different HPA parts (anchor data elements) of an HPA number (anchor data value) may be placed in different lanes of a single vector register. However, this has some problems. For example, when creating an HPA format from a floating-point operand, the fraction of the floating-point operand along with the desired anchor value must be propagated to all lanes in the associated vector register. Each lane has a different lane anchor based on the anchor value. Furthermore, if the vector register is significantly larger than the long integer value of the HPA number, e.g., a 1024-bit register holds a 200-bit long integer for the HPA number, this may result in a waste of vector register resources. Also, if the number of bits in the vector register is insufficient to represent all parts of the long integer for the HPA number, e.g., if the width of the vector register is 128 bits and it needs to represent a 200-bit long integer for the HPA number, problems may occur.

[0143] In the example to be described, a different storage arrangement is provided for the various parts of the HPA number. In particular, as shown diagrammatically in FIG. 5, the long integers of the HPA number are arranged to be stored in a common lane across multiple vector registers. In particular, a set of vector registers 100 are arranged, where each vector register may be considered to include multiple sections for storing data values. Further, multiple lanes may be considered to extend (vertically in the orientation shown in FIG. 5) through the vector registers, the first four lanes being indicated in FIG. 5 by reference numerals 102, 104, 106, 108. The long integers of the HPA number may then be stored in a common lane by storing different parts of the HPA integer value in different vector registers. This is shown diagrammatically for an example HPA integer 110, which may be considered to include four parts, one part stored in each of the vector registers Z0, Z1, Z2 and Z3. Furthermore, all parts are stored in the common lane 102. By storing the integers of the HPA number in this manner, this gives rise to a number of important advantages. For example, the size of the integers is not constrained by the width of the individual vector registers. Furthermore, multiple HPA integers can be stored in different lanes of various vector registers, and the integer values ​​can be processed in parallel in a SIMD manner, thus avoiding inefficient use of vector registers. For example, referring to FIG. 5, if each vector register shown in FIG. 5 provides 16 lanes, 16 HPA numbers are stored in four vector registers Z0 to Z3, with each HPA number occupying a different lane. Thus, it can be seen that this technique provides a technique that significantly improves scalability and is independent of the length of the vector. This allows this technique to be adopted in various systems that use vector registers of different sizes. There are many applications that can gain significant performance benefits from adopting such a method of storing HPA values, and one example is a system that adopts the Scalable Vector Extension (SVE) proposed by ARM.

[0144] ARM has announced the Scalable Vector Extension (SVE) of its 64-bit ISA targeted at scientific HPC applications. Currently, SVE does not include HPA support, but SVE continues to evolve and can achieve very high HPA performance with a few modest additions to its instruction set. SVE's "scalable" nature means that it does not require the same vector length on all implementations. SVE vectors can be implemented in hardware with pairs of 64-bit lanes in any multiple between 128 and 2048 bits. A small chip might only be able to implement 128-bit vectors, while a supercomputer might implement 1024- or 2048-bit vectors. While keeping a 200-bit integer in a single SVE register would be impossible in a 128-bit implementation and wasteful in a 2048-bit implementation, keeping a 200-bit integer spread across four registers takes full advantage of SVE's scalability and works well on all hardware implementations, from small to large. Also, programmers can use short or long integers as needed: a 100-bit integer fits into two vector register lanes, a 500-bit integer fits into ten vector register lanes.

[0145] From a performance and area perspective, SVE performs operations in 64-bit lanes. We propose to perform HPA addition by splitting a large HPA number, i, into smaller redundant parts. Each 64-bit lane stores a specified part of i (e.g., p=50 bits, which is programmable), and the remaining 64-p bits are used to hold the carry within the lane. These remaining bits are called "redundant" bits because they have the same numerical weight as the lsb of the next most significant lane. The addition within a lane is a normal 64-bit integer addition. 2 64-p Every cycle (i.e., about every 16,000 cycles for p=50), a redundancy elimination step may be required to prevent lane overflow, and at the end of every computation, lane-by-lane processing is required to obtain a redundancy-free answer.

[0146] To convert the FP input f into the HPA number format (i, a), each 64-bit lane examines the exponent of f, compares it with the anchor <a, and determines whether a part of the mantissa of f should be added to the part of i under consideration. This comparison can be done in parallel for all corresponding lanes. The mantissa of f may span two parts (three parts depending on the value of p in the case of FP64 product), but each part can be created and operate independently.

[0147] An example of converting an FP32 number into a two-part HPA by selecting a = 0 and p = 50 is shown below. In this example, the FP32 number is assumed to occupy the least significant 32 bits on the "right side" of the vector register lane, and the HPA number is assumed to occupy a 64-bit register lane (including a 50-bit value and 14 duplicate bits). For the case of an FP number, f = +1.0110 1011 1010 0010 1111 011×2 60 FP32 mantissa, f[23:0] = 1 0110 1011 1010 0010 1111 011 Part 1 of the HPA number has an adjusted partial anchor = 50 and is calculated as follows. i[1] = f[23:0] shifted left by (exponent - 23) - partial anchor = 37 - 50 = -13 bits (-ve left shift is equivalent to +ve right shift -> i[1] = {{14 0’s}, {39 0’s}, f[23:13] = 1 0110 1011 10}) (The adjustment of the exponent by 23 takes into account the fact that the exponent of the floating-point value represents the significance of the implicit decimal point to the left of the most significant bit of the 23-bit fraction, while the anchor represents the significance of the least significant bit of the fraction.) Part 0 of the HPA number is adjusted to partial anchor = 0 and is calculated as follows. i[0] = f[23:0] shifted left by (exponent - 23) - partial anchor = 37 - 0 = 37 bits. ->i[1]={{14 0's},f[12:0]=10 0010 1111 011,{37 0's}} This results in the HPA form looking like this:

[0148] [Table 7]

[0149] In general, correctly rounding the HPA results into a single FP result requires propagating carry and rounding information from lane to lane, which requires sequential processing. This takes a few cycles, but only needs to be done once per accumulation. Alternatively, if p≦53, we can convert non-redundant HPA numbers occupying multiple 64-bit lanes into a vector of FP64 numbers in parallel. The resulting vector is then "renormalized" so that the most significant element represents a complete HPA number to 0.5 ulp accuracy.

[0150] Having described the basics of HPA processing at high orders, we next provide a more detailed explanation of how to implement an HPA accumulator in SVE.

[0151] SVE currently supports vector register lengths of k × 128 bits (i.e., 1≦k≦16) up to a maximum of 2048 bits, and is based on "vector-length-independent" (VLA) processing, which allows different CPUs with different SVE vector register lengths to all execute the same SVE program. SVE programs read the available vector lengths from the system registers and "self-tune" to utilize the available vector register length, so that SVE programs, along with CPU processing, execute in 128-bit granules for as many parallel granules as the available vector hardware length can support.

[0152] As previously discussed with reference to Figure 5, to achieve vector length independence, the HPA number may be distributed across multiple SVE registers, each of which may hold bits of the same significance for a different HPA number, i.e. each register is associated with a significance that gives the value of the anchor of the number adjusted for the position of each part in the HPA number.

[0153] Returning to our 200-bit HPA number example, if each part holds p=50 bits, then if the HPA number's anchor is -80, then the significance information for the four parts will be (+70, +20, -30, -80) with 14 overlapping bits per 64-bit part. Note that the individual parts of the HPA number do not need to be stored in consecutive registers as in the example in Figure 5.

[0154] The primary benefit of arranging the HPA numbers in this way is that the HPA numbers (or long integers) can be processed in a SIMD fashion even if they span SIMD implementations that are shorter than the long HPA numbers (such as 128-bit vectors). A secondary benefit is that longer SIMD implementations (such as 1024-bit vectors) are not wasted by storing much shorter HPA numbers within each vector. With a sufficient number of integers or HPA numbers, the vectors are fully utilized regardless of the length of the SVE implementation.

[0155] Placing the HPA numbers in multiple registers also allows a vector of FP numbers to be added to each 64-bit lane, making the HPA operation highly parallel. Furthermore, loading large numbers of FP numbers from memory results in a simple and efficient contiguous vector load. Furthermore, this arrangement of HPA numbers allows multiple HPA integers to be processed all in parallel, from low to high bits, so existing SVE instructions can be used to perform important HPA calculations (such as removing redundancies or adding HPA numbers). This scheme also speeds up the conversion or renormalization of HPA numbers to FP, since multiple HPA numbers can be processed all at the same time, from high to low lanes, or from low to high lanes.

[0156] Figure 6 shows how HPA numbers arranged in the manner described in Figure 5 can be processed in a SIMD manner. In this example, it is assumed that a series of floating point numbers have been loaded into a source vector register 165. In this example, it is assumed that each floating point number is a double precision floating point number, and therefore each floating point number occupies a 64-bit section within the source register 165.

[0157] A number of 64-bit lanes 152, 154, 156 may be considered to extend through the set of vector registers, with a separate conversion and processing circuit 170, 172, 174 associated with each lane. The circuits 170, 172, 174 are arranged to operate on a single portion of the HPA number at a time to generate a corresponding result portion to be stored in a destination register 180. It will be appreciated from the above discussion of Figure 5 that each result portion of the HPA result number occupies a different destination register and accordingly, as the circuit processes different portions of the HPA number, corresponding result portions are written to different destination registers.

[0158] As will be described in more detail below, metadata is provided for reference by the conversion and processing circuits 170, 172, 174 as they perform their conversion and processing steps. In particular, in this example, metadata is stored in further source registers 160 for each lane. Within the lane metadata, a metadata portion is provided for each portion of the HPA number processed in that lane. The metadata identifies the significance (adjusted anchor) associated with the corresponding portion and may identify other information such as the number of overlapping bits. When the circuits 170, 172, 174 are processing a particular portion of the HPA number, they retrieve the relevant metadata portion from the lane metadata held in source registers 160.

[0159] In the example shown in Figure 6, each conversion processing circuit receives an input floating-point operand and an associated metadata portion for a portion of the HPA number to be processed, and then generates the associated HPA portion from the input floating-point operand, e.g., using the techniques described above with reference to the example shown in Table 7. The generated HPA portion may then be stored directly in result register 180, or may undergo some processing function to generate the associated result portion. For example, in one embodiment, an accumulation operation may be performed in which a current HPA result portion is obtained from a destination register and then accumulated with the HPA portion generated from the input floating-point operand to generate an updated result portion that is written back to the associated section of destination register 180.

[0160] It can be seen that such an approach allows multiple accumulation operations to be performed in parallel within each lane to generate result portions that represent accumulated results over the execution of multiple iterations, and this process can be repeated for each portion of the HPA number to generate a series of result portions within each lane, which collectively represent a result HPA value.

[0161] In one exemplary configuration, HPA processing requires information ("metadata") about a wide range of anchors, lane overlaps, and lane types or upper, lower, or middle positions. Because the width of HPA numbers is typically 200 bits or less and the range of anchors is similar to IEEE FP32, it is expected that HPA accumulators will typically consist of four or fewer parts. Thus, the HPA metadata for a 200-bit accumulator across four 64-bit parts can be organized as four 16-bit fields, as shown in FIG. 7.

[0162] In particular, a source register 160 may be specified in which, within each lane (e.g., 64 bits), four metadata portions are provided, as indicated by reference numerals 162, 164, 166, 168. Each metadata portion may provide metadata for an associated portion of the accumulator result. As shown in the expanded view of FIG. 7, significance (adjusted anchor) information may be included in a first subpart 192, for example, using 9 bits, while overlap information may be captured in a second subpart 194, including, for example, 5 bits. Optionally, lane type information may also be captured in a third subpart 196 to identify whether the associated portion is the top portion (representing the most significant bits), the bottom portion (representing the least significant bits), or the middle portion.

[0163] Within any particular lane, the HPA values ​​that are aggregated are all arranged to have the same anchor, and accordingly, the metadata for a lane applies equally to all HPA values ​​processed within that lane.

[0164] Essentially, by specifying different metadata for each lane, it is not necessary that a value processed in one lane have the same anchor as a value processed in another lane. However, it is often the case that values ​​processed in all lanes are arranged to all have the same anchor value, in which case the 64-bit metadata can be stored and replicated across vector registers 160. This allows the various HPA results generated in each lane to of course easily be accumulated together to produce a single scalar HPA result.

[0165] In such an arrangement, an SVE instruction for the HPA that needs to reference metadata can specify a metadata register along with a 2-bit pointer to the specific 16-bit metadata for the portion of the HPA being processed.

[0166] Note that while Figure 7 illustrates one mechanism for providing metadata, other schemes can be devised to store the metadata more compactly, for example storing 8 lanes of metadata in 64 bits. In particular, the "lane type" field may not be required, and the sizes of the ovlp and significance fields may be reduced to reflect a limited number of available configurations.

[0167] An important operation of the HPA is to convert FP numbers to HPA format and add them. This operation may be performed for every FP number being added, but other HPA operations (converting to FP, removing redundancies in the HPA, etc.) may be performed less frequently than once in a few thousand. Therefore, hardware support for efficiently converting and adding FP numbers is desirable.

[0168] FIG. 8 illustrates a possible 64-bit data path for this operation repeated across the vector unit, and therefore illustrates in more detail an exemplary configuration for each of the conversion and processing circuits 170, 172, 174 shown in FIG. 6.

[0169] The input floating-point data 210 is comprised of a sign portion 212, an exponent portion 214, and a fraction portion 216. The relevant metadata portion is then extracted from the metadata maintained for the lane as metadata portion 200, including lane type field 202, overlap field 204, and significance field 206. An OR function 220 performs an OR operation on the bits of the exponent to generate the most significant bit of the mantissa, which is then prepended to the fraction bit 216 to form the mantissa. In particular, if the exponent is not zero, this indicates that the floating-point number is a normal floating-point number, and accordingly, the most significant bit of the mantissa will have a logic one value. However, if all the bits of the exponent are zero, this indicates a denormal value, and accordingly, the most significant bit of the mantissa should be set to zero.

[0170] Subtraction block 222 is arranged to subtract significand 206 from exponent 214 (adjusted as necessary for the exponent bias and fraction word length), for example using the techniques described above with reference to Table 7, and generate a shift amount (performing either a right shift or left shift, as appropriate) that is used to control shift circuit 224 to shift the floating-point mantissa by the appropriate amount.

[0171] Next, AND circuit 226 receives overlap information 204 and masks the output from the shift circuit with a specified number of overlap bits (equal to 64-p). XOR circuit 228 then performs a two's complement function on the output from AND circuit 226 if the floating point number was negative, as indicated by sign value 212. At this point, the bits of the input floating point number associated with a particular HPA portion having a given significance and amount of overlap are available as two's complement and can be provided as one input to adder circuit 230 (the adder also takes a carry-in value of one if the floating point operand is negative). As a result, it can be seen that the associated HPA portion can be generated "on the fly" from the input floating point value and then subjected to the appropriate processing operations to generate the corresponding result portion.

[0172] In the illustrated example, it is assumed that the processing operation is a selective add operation. In particular, AND circuit 240 can be selectively used to propagate the current value held in register 235 back as a second input to adder 230, where the previous result portion can be added with the input operand portion output from the transform circuit to generate an updated result portion stored in register 235. Incorporating a 64-bit adder and registers in the illustrated manner supports pipelined execution of back-to-back HPA transform-and-accumulate instructions.

[0173] Although there are a number of ways in which the circuitry depicted in Figure 8 can be triggered to perform the operations described above, in one embodiment, a single instruction is used to initiate the above-described functionality of Figure 8. Such an instruction may be referred to as an FP-to-HPA convert-and-add instruction.

[0174] The opcode for the FP-HPA convert-and-add instruction (mnemonic "FCVTH{A}", where {A} indicates optional accumulation) contains, in one example, an FP source register, a metadata register, a destination accumulator register, and an index to select a subfield of the metadata register. This is consistent with the design principle of the SVE ISA that an opcode references no more than three vector registers.

[0175] Short sequences of existing SVE instructions can also be created to implement other important HPA operations.

[0176] To avoid partial overflow, it is important to periodically remove the redundancy in the HPA number. This can be achieved by simply adding the carry bit accumulated in the overlap area of ​​the lower HPA part to the LSB of the next higher HPA part. In SVE, this can be achieved in three instruction steps. (i) The lower part is arithmetically shifted to the right by p positions. (ii) Add the shifted overlap bit to the next most significant HPA portion. (iii) and AND-immediate the duplicated bits with a mask derived from p in the lower HPA portion to force them to zero.

[0177] This procedure can be applied to all pairs of adjacent HPA moieties, starting from the bottom lane.

[0178] Also, dedicated instructions for duplicate propagation and duplicate elimination may be provided, as described below with reference to FIGS.

[0179] After a large block of FP numbers is accumulated, the result may be stored in multiple accumulators located in multiple SVE lanes. These accumulators may then be added together to return a scalar result for each vector in the HPA lane with the same index. In the SVE, this can be easily achieved by performing vector reduction on the accumulators held in multiple HPA lanes to form a scalar HPA result. Because the resulting scalar HPA number may contain carry bits in the overlapping regions of each part, a redundancy elimination routine may be performed on the scalar HPA number before converting it to FP format.

[0180] Finally, we convert the reproducible HPA sum result into floating-point format. The algorithm for converting the HPA part exactly to a normalized FP64 number (i.e., assuming p >= 53) is as follows: (i) Execute CLZ (count leading zeroes) to identify the position of the first "1". (ii) Calculate the index as significance + (63-CLZ) + FP64 index bias. (iii) For all but the highest-order HPA portion, set bit

[63] of the FP64 result to 0. Set bits[62:52] of the FP64 result to the computed exponent. If the biased exponent > 0, logically left-shift the HPA portion by CLZ-11 places, else set the FP64 result to 0. (iv) For highest-order HPA part only: If the part is negative, set bit

[63] of the FP64 result to 1 and negate the part to get the positive two's complement number. Set bits[62:52] of the FP64 result to the computed exponent. If the biased exponent > 0, logically left-shift the HPA part by CLZ-11 places, else set the FP64 result to 0.

[0181] This transformation algorithm can be implemented with typically 15 SVE instructions per HPA lane.

[0182] If necessary, the above steps (iii) and (iv) can be combined as follows to cover cases where parts other than the most significant part are negative: (iii) If the part is negative, set bit

[63] of the FP64 result to 1 and negate the part to get the positive two's complement. Set bits[62:52] of the FP64 result to the computed exponent. If the biased exponent > 0, logically left-shift the HPA part by CLZ-11 places, else set the FP64 result to 0.

[0183] If desired, a single FP64 result can be created that represents the final integrated value as accurately as possible, for example by applying the algorithm proposed by Y. Hida, XS Lee and DH Bailey, "Algorithms for Quad-Double Precision Floating Point Arithmetic," Proc. 15th IEEE Symposium on Computer Arithmetic, Vail CO, June 2001, pp. 155-162.

[0184] Starting with the bottom pair of lanes, the Fast2Sum operation is applied to the next top lane in succession to produce the top sum obtained by Fast2Sum. Then, working down the most significant pair of values ​​just obtained, the process is repeated to successively apply it to the next bottom value and the bottom sum obtained by Fast2Sum. The most significant element of the resulting vector of FP64 numbers is guaranteed to be within 0.5 ulps of the HPA number.

[0185] An HPA accumulator, consisting of l parts, has a word length of l × p bits and occupies l SVE vector registers. The FCVTH{A} instruction, executed by the k × 128 bit SVE vector unit, can convert and accumulate 2k FP64 or 4k FP32 numbers into 2k HPA accumulator parts. The FCVTH{A} instruction is fully pipelined, so that a block of n FP64 additions can be added to the 2kp × l bit HPA accumulator in n × (l / 2k) + 1 cycles. Typical values ​​of l and k are 2 to 4 (although k can go up to 16), so with l = k, n FP64 numbers (or 2n FP32 numbers) can be added to k parallel accumulators in n / 2 cycles. On the other hand, in ARM's Cortex-A72, the sums must be done in order, and the dependent FMA (Fused Multiply-Add) requires three cycles between adds, so 3n cycles are required to perform the same repeatable sum. In this way, HPA achieves a speedup of about 12 times in FP32 summation processing compared to conventional FP processing.

[0186] As mentioned above, redundancies in the HPA must be periodically removed or resolved. The above method requires 3 × (l-1) instructions and takes 2 64-p For a typical value of p=50, this amounts to a small processing overhead of less than 0.1%. Similarly, reducing the HPA accumulator vectors to a scalar format, eliminating redundancies in the scalar HPA, and converting the scalar HPA back to FP64 format requires n≈10 3 Compared to the ≈n / 4 cycles required to integrate n HPAs as above, for a typical value of l, this requires l+3×(l-1)+15×l ≈ 19×l-3 = 35-73 instructions.

[0187] Figure 9 shows another example of an anchor data element encoding that includes type information specifying whether the anchor data element represents a portion of a two's complement number or a special value. Note that the anchor data element type information is different from the metadata lane type information 196, as shown in Figure 7. This encoding uses the most significant bit (bit 63 in this example) to indicate whether the element represents a standard HPA digit representing a portion of a two's complement number or a special value. If the most significant bit is 0, the HPA element represents a standard HPA digit representing a two's complement number, and the overlap bit has the same significance as the least significant bit of the next most significant digit in the HPA value, as in the example above.

[0188] However, when the most significant bit of an element is 1, the element represents an HPA special value selected from among positive infinity, negative infinity, Not a Number (NaN), and the saturation value. When the most significant bit is 1, the next two most significant bits (e.g., bits 61 and 62, as shown in Figure 9) represent the particular type of special value represented. Figure 10 shows the standard HPA digit and the encoding of bits 63 through 61 for each type of special value.

[0189] Thus, if the most significant bit is 0, the next two bits represent some of the duplicated bits of the HPA digit, or the next two bits may represent the non-duplicated bits of the HPA digit if using a non-redundant HPA variant that has no duplicated bits. This allows bits that would traditionally be used to indicate which particular type of special value is encoded to be reused to represent the bits of a two's complement number, allowing for efficient encoding.

[0190] If the most significant bit is 1 and the three most significant bits are 0, the HPA element represents infinity. The second most significant bit represents the sign of infinity. Thus, bits 63-61 of the element might encode 110 to represent negative infinity, and 100 to represent positive infinity. It is also possible for the encodings of positive and negative infinity to be swapped. When an HPA element is indicated as representing positive or negative infinity, it means that it was produced by a sequence of operations in which at least one operation included converting a floating-point value to HPA format, and that floating-point value was positive or negative infinity.

[0191] An element represents a Not a Number (NaN) if the three most significant bits of the element represent 101. This can happen in two ways: either the element may be produced by a series of operations involving the conversion of a floating-point value that was a NaN, or the element may depend on the addition of two HPA values, one of which is positive infinity and the other negative infinity.

[0192] On the other hand, if the most significant 3 bits of the HPA element are coded as 111, it represents a saturated HPA value. Saturated HPA values ​​have no analogue in the floating-point domain. While positive or negative infinity indicates that the HPA value is the result of converting a positive or negative infinity floating-point value, which is derived from a calculation that results in a number of a larger size than can be represented in floating-point format, a saturated HPA type may indicate that the input floating-point numbers to a series of HPA operations were non-special numbers that were not NaN or infinity, but that saturation occurred due to the HPA arithmetic operations, e.g., when anchor metadata sets a range of significance to be represented by HPA values, and the input floating-point values ​​and / or their processing results produce numbers outside the range defined by the metadata.

[0193] For example, a saturation type may occur if an HPA operation acting on the most significant HPA element of an HPA value (as shown by lane information 196 in FIG. 7 ) results in an overflow from the most significant duplicated bit. Alternatively, a saturation type may occur if the most significant element of an HPA value overflows from the most significant non-duplicate bit to the least significant duplicated bit, if the most significant HPA element and the duplicated bit of the HPA value are not considered part of the two's complement number represented by the HPA value. By definition, encoding the saturation type as 111 in bits 63 through 61 is particularly useful if the duplicated bit of the top element of an HPA value is considered part of the entire two's complement number represented by the HPA value, since by definition, when overflowing from the top duplicated bit, the top two duplicated bits are already both equal to 1, and the overflow itself may cause the corresponding element to have its type information in the top three bits equal to 111, since the most significant bit of the element is switched from 0 to 1 by the overflow. This can simplify the logic for setting the type information, as it may not require specific circuitry to detect overflow and set the type information accordingly. On the other hand, if the overlap bits are not considered part of the two's complement number represented by the HPA value, then some additional logic can detect overflow from the non-overlapping high-order bits into the overlap region and set the top 3 bits of the type information accordingly.

[0194] Also, a saturating type may be used if an underflow occurs during an HPA operation. For example, if a floating-point value being converted to HPA format requires more low-order bits to be represented exactly in the HPA format than can be represented using the HPA format defined in the anchor metadata, this may be detected as an underflow and a saturated data type may be indicated. Also, a type encoding may be used that distinguishes between overflow and underflow. However, in practice, an overflow may be more important to signal than an underflow, since an underflow simply leads to a loss of precision, whereas an overflow may result in an incorrect processing result. Therefore, in some cases, one may choose not to signal an underflow using the data type indicated in the type information.

[0195] In general, providing type information that supports the representation of saturation types for HPA values ​​allows program code, after a sequence of HPA operations, to determine whether any special values ​​resulting from the operations are due to the input floating-point numbers being special numbers, or due to an overflow caused by the HPA processing. This is useful in the second scenario because it allows the program code to adjust the anchor metadata and repeat the sequence of operations to maintain valid results, whereas if the special values ​​occurred because of special numbers in the original floating-point values, repeating the HPA processing with different anchor metadata will not produce a non-special result.

[0196] Although FIG. 10 illustrates one particular encoding of type information that is useful for providing an efficient encoding scheme, other encoding schemes may be used.

[0197] Figure 9 shows the encoding for a single HPA element. If an HPA value is composed of two or more HPA elements, the HPA value is considered to be a special value if any of those HPA elements has its top bit set to 1. In practice, as shown in Figure 5, because the HPA value is striped across several different vector registers, each HPA processing instruction can only see one element at a time, and when processing one of the HPA elements, it may not be obvious that one of the other HPA elements of the same vector value detects a special value or overflow. Also, if the input floating-point value is an infinity or not a number, it is possible that all elements of the HPA value converted to that floating-point value are set to indicate a special value, but if saturation occurs due to the HPA processing, for example, only the most significant HPA element of the HPA value may indicate the saturation type.

[0198] Also, when adding two HPA elements, the type information of the result element can be set according to the type information of the two elements being added. Figure 11 is a table showing the possible data type differences depending on the data types of the first and second operands. The left column of the table shows the different data type choices for the first operand, and the top row of the table shows the different data type choices for the second operand. Num represents standard two's complement, i.e. the data type when the most significant bit of the element is 0.

[0199] As shown in Figure 11, if both input operands are standard two's complement numbers, the result can be either another standard two's complement number, or a saturated value if the most significant element of the HPA value overflows. If at least one of the two operands being added is a special value, the result will also be special. Thus, when an HPA element has its most significant bit set to 1, all subsequent HPA elements that depend on it are sticky in the sense that they are all generated with their most significant bit at 1, making it possible to detect the occurrence of special values ​​at the end of a sequence of operations.

[0200] As shown in Figure 11, if either operand being added is NaN, the result will be NaN. It can also be NaN if one operand being added is positive infinity and the other is negative infinity. If one operand being added is positive infinity and the other is negative infinity or anything other than NaN, the result will be positive infinity. Similarly, if one operand is negative infinity and the other is positive infinity or anything other than NaN, the result will be negative infinity. Finally, if at least one of the operands is a saturation value, the result will also be saturated if the other operand is either standard two's complement or a saturation value.

[0201] In some cases, an exception may be triggered in response to an HPA addition that causes a particular result. An overflow exception may be signaled if an overflow occurs and the result saturates, even though the two operands being added were standard two's complement numbers. For HPA elements other than the most significant element of an HPA value, this exception should not occur after a certain number of HPA additions have been performed, because that number is chosen such that an HPA addition of that number will not cause an overflow beyond the top overlap bit, and the program code should trigger the overlap propagation behavior. However, for the most significant element, an overflow may occur if the anchor metadata is not set correctly.

[0202] If you add a non-signed floating-point infinity and the result is NaN, an invalid operand exception may occur.

[0203] In addition, other kinds of exceptions may occur when converting from floating-point to the HPA or from the HPA to floating-point, depending on the kinds of special values ​​represented.

[0204] In practice, analysis of typical high performance computing workloads shows that in most cases, two or three HPA elements are sufficient. Some HPA implementations may rely on the programmer knowing the anchors and the number of elements. This means that the programmer must know the range and number of values ​​in the problem space. If the programmer gets this wrong, especially if the higher order HPA elements overflow, there is no recourse other than to increase the number of elements and / or change the anchors and rerun the program.

[0205] The following examples show HPA implementations that are much easier for programmers to implement, and in principle allow for any range of integration using hardware that supports HPA.

[0206] Therefore, when processing a sequence of HPA operations, the following steps can be taken: (1) Hold the initial values ​​of the vector elements (i.e. store the first vector registers to be added; these will likely contain zeros). (2) Accumulate FP values ​​into several vector elements and, if overflow occurs, set sticky overflow bits in higher elements (see saturating data types above). (3) Periodically check whether the overflow bit is set (ideally during the redundancy elimination step, and also when accumulation is complete). If there is no overflow, store the new value of the SVE element, capture the checkpoint information into the accumulation flow, and go to step (2). If there is an overflow, increase the number of elements and rerun from the last stored value and the checkpoint information of the SVE element.

[0207] Further enhancements to this idea could include: (a) Use a higher order element to indicate the overflow to hold information about the cause of the overflow (most usefully the exponent of the value that caused the overflow). If the exponent is within the expected range, then adding one element and re-running the partial accumulation as in step (2) above will likely fix the problem. If the exponent is out of range, the partial accumulation may require an additional element. For example, if the expected range is 20 to 2100, then an addition can be done using two elements. If instead, a bit with a value of 2180 is obtained, then two more elements are required (example using 64-bit elements). (b) Detecting and dealing with underflow using a similar scheme for the lower order elements of the sum, again by capturing the offending exponent in an element and re-performing the partial accumulation with the additional element or elements at the lower anchor. (c) Combining (a) and (b) to enable automatic accumulation within any range. (d) Making available to the programmer one or more indications, such as the condition under which a rerun is required, the final number of elements in the accumulator, the final anchor value, etc. These data are captured in general purpose or private registers and made available to the accumulator elements after the reduce operation.

[0208] These extensions allow generic library routines to perform arbitrary floating-point accumulations without any special input from the programmer. In most cases, an accumulation requires only two or three elements, but less-than-promising inputs or ranges can be accommodated in the same associative, reproducible framework.

[0209] Thus, these examples can provide: (1) Dynamic handling of overflow in HPA accumulation (2) Dynamic handling of underflow in HPA accumulation (3) Creating a status of use of HPA accumulators

[0210] More specific examples of these techniques are given below.

[0211] 12 is a flow diagram illustrating a method for generating usage information for anchor data processing operations involving overflow or underflow. While FIG. 12 shows generating this information for both overflow and underflow, in other examples it may also be generated upon overflow.

[0212] At step 300, processing circuitry 14 performs an anchor data processing operation in response to an instruction decoded by instruction decoder 20. The operation may be, for example, a floating point conversion operation, or may include both a floating point conversion and subsequent addition of the converted floating point value to an accumulator in the anchor data format. The anchor data processing operation may also be an HPA addition or other operation involving processing of an HPA value. At step 302, processing circuitry 14 detects whether there was an overflow for the operation that generated the top element of a given HPA value, or whether there was an underflow for the bottom element of the HPA value (in implementations that support underflow detection). Whether the operation generates a top element or a bottom element may be indicated by lane type information 196 of the anchor metadata. If there was no overflow of the top element or underflow of the bottom element, processing continues at step 304. Optionally, an exception may be signaled if there was an overflow of a lane from the middle or bottom element of the HPA value.

[0213] On the other hand, if an overflow of the top element or an underflow of the bottom element is detected, the hardware triggers the storage of the usage information in a software accessible storage location. The software accessible storage location may be a location in memory 4 or a second register in register bank 12, separate from the register that stores the result of the anchor data processing operation. However, it may be most convenient and simple to implement in the microarchitecture if the software accessible storage location is the destination register of the anchor data processing operation itself. For example, if an overflow or underflow is detected, the result data element may be generated with a special value encoding as shown in Figures 9 and 10, with the top bit set to 1. The usage information may be stored in some of the empty bits 0 to 60, as shown in Figure 9. These bits are no longer needed since there is no two's complement value to represent since their values ​​are special. This avoids the need to write to two registers in response to one instruction. Writing usage information to a software-accessible storage location does not require dedicated instructions specifying the usage information or how to store it, but instead may be tightly coupled to the microarchitecture such that the storage of usage information is automatically triggered when an overflow or underflow occurs due to an anchor data processing operation.

[0214] The usage information indicates either the cause of the overflow or underflow (such as the exponent of the floating-point value that was converted as part of the anchor data processing operation, or other information derived from the exponent, such as the margin of the exponent away from the maximum or minimum exponent that can be fully represented within the allowable range of the HPA value), or how to update the number of HPA elements of the HPA value and / or the anchor metadata to change the anchor data format to prevent the overflow or underflow. For example, the usage information may indicate how many HPA elements need to be added to fully represent the required number, or to what value the significance of the lane needs to be set to avoid the overflow / underflow. Some examples may provide more than one type of usage information. After storing the usage information, processing may continue at step 304.

[0215] For further operations performed after the anchor data processing operation that generated the usage information, further result data elements may also specify usage information, resulting in usage information being stored throughout the series of operations regardless of whether the input to the later operation itself caused an overflow. However, after storing usage information for one operation based on the exponent of a floating-point value outside the allowed range, the usage information for the subsequent result may be updated if a larger exponent value is encountered in a subsequent operation.

[0216] Storing this usage information can be very useful to assist software routines that support dynamic adjustment of the number of lanes (HPA elements) of the HPA value, and dynamic adjustment of the anchor information automatically as part of the code, reducing the programmer's burden in knowing what anchor information to set. Figure 13 is a flow diagram showing how such software works. Alternatively, in some implementations, the processing circuitry itself may perform the functions shown in Figure 13 to automatically react to a detected overflow or underflow and change the format of the HPA value.

[0217] In step 400, a checkpoint of the architectural state is captured prior to executing the first part of a sequence of data processing operations to be performed. For example, this may be triggered by a series of store instructions that store the value of a particular register to a location in memory 4.

[0218] At step 402, the software then proceeds to execute a next portion of the sequence of data processing operations that includes at least one anchor data processing operation. For example, it may include a series of instructions to take several floating point inputs, convert them to anchor data values, and perform addition on those anchor data values. The conversion and addition may be performed in separate instructions or may be combined into a combined convert-add instruction. The portion of the sequence may be of a given length, for example corresponding to the number of additions that can be safely performed without performing overlap elimination as described above.

[0219] In step 404, the program code includes instructions for checking whether an overflow or underflow occurred during a previously executed portion of the sequence of data processing operations. For example, the instructions may check whether the result represents a special value, and if so, check the encoding of the special value and / or usage information generated by the hardware to determine whether an overflow / underflow occurred, as shown in FIG. 12. If no overflow or underflow is detected, the portion of the processing was performed correctly and there is no need to update the lane count or anchor information, so in step 406 it is determined whether the sequence of data processing operations performed using the anchor data processing has ended. If not, the method returns to step 400 and takes another checkpoint of the architecture state based on values ​​obtained from a previously executed portion of the sequence, after which the method again loops through steps 400-404.

[0220] If an overflow or underflow is detected in step 404, the method proceeds to step 407, where it is determined whether at least one retry condition is satisfied by the usage information generated by the hardware when the overflow / underflow occurred. For example, the at least one retry condition may include any one or more of the following: A condition that is met when an overflow or underflow margin is less than a predetermined amount. The overflow margin may be the difference in significance between the most significant bit of the input value to be processed or the value generated by the HPA process and the most significant bit that can be represented using the HPA format given the current anchor information and the current number of elements in the HPA value. The underflow margin may be the difference in significance between the least significant bit of the input value to be processed or the value generated by the HPA process and the least significant bit that can be represented using the HPA format given the current anchor information and the current number of elements in the HPA value. The number of additional anchor data elements required to prevent overflow or underflow is no more than a specified number; and · The number of previous attempts to retry that portion of the sequence of data processing operations is below a predetermined threshold.

[0221] Checking whether one or more of these conditions are met and determining whether it is worth retrying an earlier part of the code sequence based on the updated element count and / or updated anchor information helps to limit dynamic updates in cases where the overflow / underflow can be addressed with a relatively small adjustment to the element count or anchor information. If the overflow / underflow margin is large, it may not be efficient to extend the HPA value by a very large element count, and it may be efficient to simply record the fact that an overflow / underflow occurred and terminate processing or continue without retrying. It may also be preferable to avoid performing another retry if a given number of retries have already been performed and the overflow / underflow has failed to be addressed.

[0222] Thus, once at least one retry condition is satisfied by the usage information, in step 408, the lane number (HPA element) and / or anchor information is updated for at least one anchor data value processed in a previous portion of the sequence. In some implementations, this update may be based on the usage information described above in FIG. 12, set by the hardware in response to the operation that caused the overflow or underflow. However, in other examples, the lane number or anchor information may simply be updated in some predefined manner, such as changing the significance of the anchor data value by a certain amount, or extending the number of elements provided in the HPA value by a given increment (e.g., one additional element). In step 410, the most recently captured checkpoint of the architectural state is restored to register 12, for example by the software including a load instruction to load a value into the associated register from the memory location where the checkpoint was previously stored. In step 412, the software triggers a retry of the previously executed portion of the sequence of data processing operations based on the updated lane number and / or anchor information and the checkpoint of the restored architectural state. For example, the code may include a branch that branches back to the beginning of a previously executed portion of the sequence. Once that portion is again completed, the method then returns to step 404 to again detect whether there has been an overflow or underflow as described above. Thus, if the first update to the anchor information is successful, only one retry may be necessary, but if the first update was not sufficient, multiple overflows or underflows may occur, resulting in multiple loops through steps 404-412. Eventually, the current portion of the sequence will complete without an overflow or underflow, after which the method may proceed to step 406 as described above to proceed to the next portion of the sequence.

[0223] On the other hand, if in step 407 at least one retry condition is not satisfied by the usage information, then in step 414 the sequence is terminated or, alternatively, continued without retrying previously executed parts of the sequence. In case of termination, for example, an exception may be indicated. If the sequence is continued, a previous overflow / underflow means that the result of the remaining parts of the sequence may be incorrect, but since a further overflow / underflow may occur in a later part of the sequence where the margin of overflow / underflow may be even larger, if no retry is performed, it may be considered preferable to complete the sequence so that a complete picture of the modifications to the HPA format required to avoid overflow / underflow can be gathered.

[0224] If step 414 terminates or continues processing the sequence without retrying, then step 416 may return information about the overflow or underflow that occurred. For example, this information may specify the exponent of the floating-point value that caused the overflow / underflow, and / or may identify how many overflows / underflows occurred, and / or may specify the point in the sequence at which the overflow / underflow occurred, or may provide other information useful in analyzing why the overflow / underflow occurred.

[0225] In some examples, step 407 may not be included, in which case dynamic updates to the anchor information and / or lane number and automatic retry may be performed according to steps 408-412 regardless of whether the usage information meets the retry condition.

[0226] If at some point the overflow / underflow could be addressed by dynamic retry, then in step 406, each portion is completed without any detected overflow or underflow occurring, either because it was initially successful or because the overflow or underflow no longer occurs after one or more retries, and the end of the sequence data processing operation is reached. Once the end of the sequence is reached, in step 418, the software code may include instructions to trigger the storage of information regarding the final anchor metadata resulting from the sequence, the final number of elements associated with a given HPA value processed in the sequence, or information regarding conditions that may have required a retry of a given portion of the sequence. In general, information may be stored here that allows the software to ascertain why an overflow or underflow occurred, or to identify optimal settings for the anchor metadata, which may improve performance in subsequent runs of the same program since the anchor metadata and number of lanes are set to the desired values ​​from the start, which may improve performance in subsequent runs of the program by not requiring as many retries.

[0227] In FIG. 13, information on the conditions that require a retry is stored in step 418, but it is also possible to store this information when updating the anchor information in step 408, thereby eliminating the need to retain information on the cause of overflow or underflow for a long period of time.

[0228] Figure 14 illustrates a schematic of an example of processing a sequence of program code (including HPA processing operations) according to the method illustrated in Figure 13. At point 450 illustrated in Figure 14, an initial checkpoint of the state of registers is captured. This checkpoint covers any state that may be overwritten as a result of processing the next portion of the program code. The checkpoint is captured by either saving the captured state to memory or by updating the mapping of the architecture to physical registers such that subsequent updates of the register state are made to different physical registers than those storing the previous checkpoint of the register state.

[0229] At point 452, portion 1 of the program code sequence is executed. Upon completion of portion 1, overflow / underflow detection is performed at point 454, which in this example detects that no overflow or underflow occurred. Thus, another checkpoint of the register state is captured at point 456, after which portion 2 of the program code sequence is executed at point 458.

[0230] At point 460 during processing of portion 2, an overflow occurs. The processing hardware automatically stores information regarding the cause of the overflow and / or usage information indicating how to adapt the number of HPA elements to accommodate the overflow in a software accessible storage location. Execution of portion 2 of the sequence continues, and at the end of portion 2, overflow / underflow detection is again performed at point 462, this time determining that an overflow has occurred based on the usage information.

[0231] In this example, if any retry conditions were imposed, it is assumed that those retry conditions were satisfied by the overflow. If any required retry conditions were not satisfied, the code sequence may terminate or may be allowed to continue without retrying. However, in this particular example, the retry conditions are satisfied, so at point 464 the program code extends the number of HPA elements in the HPA format by at least one more to avoid overflow. In the case of overflow, the significance of the lane indicated by the anchor information of the existing lanes in the HPA format does not change, so the bottom element still has the same significance as before. However, because a lane of higher significance has been added, an update of the lane type of the previous top lane is made, changing it to a middle lane. At point 466, the program code restores the checkpoint of the state previously captured in step 456, branches back to the start of portion 2 of the code sequence, and retries execution of portion 2 based on the updated number of HPA elements. This time, since no overflow or underflow occurs during the second attempt to process portion 2, no overflow / underflow is detected at point 468, another checkpoint of the register state is captured, and processing continues with portion 3 of the code sequence at point 470.

[0232] Each portion is then processed in a similar manner, eventually reaching the end of the code sequence at point 472, which returns the final lane number or anchor metadata and / or information regarding the conditions under which a retry is required.

[0233] FIG. 15 shows an example of providing at least one additional HPA element in response to a detected overflow. As shown at the top of FIG. 15, the reason for the overflow can be that the floating-point value 1.F input as an input operand to the HPA processing sequence has a value greater than the value that can be represented in the current HPA format defined by the current number of HPA elements (2 in this example) and the anchor metadata (anchor [0], anchor [1]). In embodiments where the duplicate bits of the most significant element of the HPA value are considered part of the significance range represented by the HPA value, the overflow margin may be like the solid line 480 shown in FIG. 15, while in embodiments where the duplicate bits of the most significant element of the HPA value are not considered part of the significance range represented by the HPA value, the overflow margin may be like the dotted line 482.

[0234] Accordingly, when an overflow occurs, the hardware may record information for evaluating the overflow margin as usage information. For example, the usage information can indicate the exponent E of the floating-point value, the overflow margin, or the number of additional elements required to process the overflow. When the overflow margin is Z, the number J of additional elements required to avoid the overflow may be a value of J that satisfies the condition (J - 1)*(N - V) < Z ≦ J*(N - V), where N is the number of bits per HPA element and V is the number of duplicate bits. For example, if the overflow margin Z is less than or equal to N - V, one additional HPA element at the most significant end may be added, and if the overflow margin Z is greater than N - V, two or more additional elements may be required.

[0235] In the example of FIG. 15, an overflow can be accommodated by providing one additional HPA element, as shown at the bottom of FIG. 15. When retrying previous parts of the code sequence based on the updated lane count and checkpoint of the restored register state, the topmost additional lane is first populated with a sign bit (matching the sign of the most significant bit of the corresponding HPA value in the restored register state). In the case shown in FIG. 15 where only an overflow has occurred, the lane significance 192 (shown in FIG. 7) of the lower lane's anchor metadata may remain the same, but the lane type 196 of HPA element HPA[1] has been updated from indicating the most significant lane (M) to indicating an intermediate lane (I). The anchor metadata of the newly added element HPA[2] ​​indicates the lane type of the top lane (M) and specifies lane significance 192 as the lane significance 192 of the anchor metadata anchor[1] associated with HPA[1] plus NV. Now we can re-execute the part of the code sequence that we executed earlier, and this time, when we encounter a floating-point operand that caused an overflow, we will clamp the number to the range representable by the HPA format.

[0236] FIG. 16 is another example of how underflow is addressed by providing at least one additional HPA element at the lower bound of the HPA value. Unlike the overflow case, the underflow case requires an adjustment to the significance of the anchor metadata of the existing lanes of the HPA value. In this example, two additional lanes are required because of the underflow UM margin. The additional elements HPA[0]' and HPA[1]' are added, defined as lowest (L) and middle (I) lane types in the lane type field 196 of the corresponding anchor metadata. The additional elements HPA[0]' and HPA[1]' are initially populated with zeros when resuming the previous portion of the code sequence that caused the underflow. The restored checkpoint values ​​of the register states corresponding to the HPA elements previously shown as HPA[0] and HPA[1] in the top of FIG. 16 are now treated as HPA elements HPA[2]' and HPA[3]' in the updated HPA format. Thus, the lane significance 192 of HPA[2]' and HPA[3]' in the updated HPA format matches the lane significance 192 specified in the anchor metadata of lanes HPA[0] and HPA[1] before the update. The lane types 196 of elements HPA[2]' and HPA[3]' are the middle element and the top element, respectively. The newly added element HPA[1]' has its lane significance set to anchor[0]-(NV), where anchor[0] is the lane significance of HPA[0] before the dynamic update, and the newly added element HPA[0]' has its lane significance set to anchor[0]-2*(NV). The previous part of the code can then be retried with the updated element count and anchor information.

[0237] Although Figures 15 and 16 show examples where only an overflow or an underflow occurs, it is possible for both to occur in the same part of the code sequence, in which case extending the number of elements may involve adding more elements to both ends of the HPA value.

[0238] It will be appreciated that in embodiments where the HPA value is striped across multiple registers as shown in Figure 5, if the number of HPA elements is expanded as shown in Figures 15 and 16, then a retried portion of the code sequence may require a greater number of instructions to be executed compared to the first attempt to execute that portion, since each HPA element of the overall HPA value is processed by a respective instruction that writes to a different destination register. This may be achieved by defining a variable that defines the total number of elements in the HPA value, and executing a loop of program code (or an alternative program flow control structure, such as using conditional branching) with a number of iterations of instruction execution corresponding to the total number of elements in the HPA value.

[0239] FIG. 17 shows possible implementations of a simulator. While the embodiments described above implement the invention in terms of apparatus and methods for operating specific processing hardware supporting the technology, it is also possible to provide an instruction execution environment according to the embodiments described herein implemented using a computer program. Such computer programs are often referred to as simulators insofar as they provide a software-based implementation of a hardware architecture. Types of simulator computer programs include emulators, virtual machines, models, and binary translators, including dynamic binary translators. Typically, simulator implementations may run on a host processor 530 that supports a simulator program 510 and optionally runs a host operating system 520. In some configurations, there may be multiple simulation layers between the hardware and the instruction execution environment provided, and / or there may be multiple different instruction execution environments provided on the same host processor. Historically, powerful processors have been required to provide simulator implementations that run at reasonable speeds, but in certain situations, such an approach may be justified, such as when one wants to run code native to another processor for compatibility or reuse reasons. For example, a simulator implementation may provide an instruction execution environment with additional features not supported by the host processor hardware, or that are typically associated with a different hardware architecture. An overview of simulation is given in "Some Efficient Architecture Simulation Techniques", Robert Bedichek, Winter 1990 USENIX Conference, pp. 53-63.

[0240] While embodiments have been described above with reference to particular hardware configurations or functions, in the simulated embodiments, equivalent functionality may be provided by appropriate software configurations or functions. For example, particular circuits may be implemented as computer program logic in the simulated embodiments. Similarly, memory hardware such as registers or caches may be implemented in the simulated embodiments as software data structures. In configurations in which one or more of the hardware elements referenced in the previously described embodiments reside on host hardware (e.g., host processor 530), some simulated embodiments may utilize the host hardware where appropriate.

[0241] The simulator program 510 may be stored in a computer readable storage medium (which may be a non-transitory medium) and provides a program interface (instruction execution environment) to the target code 500 (which may include an application, an operating system, a hypervisor) that is the same as the application program interface of the hardware architecture being modeled by the simulator program 510. Thus, the program instructions of the target code 500, including instructions supporting the processing of HPA values ​​as described above, may be executed from within the instruction execution environment using the simulator program 510, allowing a host computer 530 that does not actually have the hardware functions of the device 2 described above to emulate these functions. The simulator program 510 may include instruction decode program logic 412 for decoding the instructions of the target code 500 and mapping them to native instructions supported by the host hardware 530. The instruction decode program logic 512 includes anchor data processing program logic 514 that maps HPA processing instructions to a set of native instructions for performing HPA (anchor data processing) operations, such as FP conversion, addition, or overlap propagate operations as described above.

[0242] In this application, the term "configured to" is used to mean that an element of an apparatus has a configuration that can perform a defined operation. In this context, "configuration" refers to an arrangement or method of interconnection of hardware or software. For example, an apparatus may have dedicated hardware that provides the defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not imply that an apparatus element must be modified in any way to provide the defined operation.

[0243] Although exemplary embodiments of the present invention have been described in detail herein with reference to the accompanying drawings, it should be understood that the invention is not limited to those precise embodiments, and various changes and modifications can be made by those skilled in the art without departing from the scope and spirit of the present invention as defined by the appended claims.

Claims

1. 1. An apparatus comprising: a processing circuit for performing data processing; an instruction decoder for controlling the processing circuit to perform anchor data processing operations to generate resultant anchor data elements for an anchor data value comprising one or more anchor data elements each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a range of values ​​representable by the resultant anchor data element or the anchor data value; Equipped with in response to an anchor data processing operation in which the anchor information indicates that the anchor data processing operation will cause an overflow or underflow of the two's complement number represented by the anchor data value, the instruction decoder is configured to control the processing circuitry to store usage information in a software accessible storage location; the anchor data processing operation depends on converting a floating-point value into an anchor data element representing a portion of the bits of the two's complement number corresponding to the floating-point value; The usage information stored in response to identifying an overflow or underflow is: indicating the exponent of a floating-point value, if the anchor data processing operation also includes addition of anchor data elements obtained by converting the floating-point value to another anchor data element, indicating whether the overflow was caused by the floating-point value being outside the numerical range or by addition when the floating-point value was within the numerical range; indicating how far the exponent of the floating-point value deviates from the numerical range; and indicating a number of additional elements required in the anchor data value to accommodate a numeric value equivalent to said floating-point value.

2. The apparatus of claim 1 , wherein the processing circuitry is configured to specify the usage information within a portion of the resulting anchor data element produced in the anchor data processing operation that causes the overflow or the underflow.

3. 3. Apparatus according to claim 1, wherein in response to an anchor data processing operation in which an input anchor data element specifies said usage information, the processing circuitry is configured to generate a result anchor data element that also specifies said usage information.

4. The apparatus of any one of claims 1 to 3, wherein the anchor information includes element type information indicating whether the resultant anchor data element is a top anchor data element, an intermediate anchor data element, or a bottom anchor data element of the anchor data value.

5. The instruction decoder an anchor data processing operation, the anchor information indicating that the resulting anchor data element is the top anchor data element of the anchor data value, causing an overflow of the resulting anchor data element; and an anchor data processing operation, wherein the anchor information indicates that the resulting anchor data element is the lowest anchor data element of the anchor data value, causing an underflow of the resulting anchor data element; configured to control the processing circuitry to store the usage information in the software-accessible storage location in response to at least one of 5. The apparatus of claim 4.

6. The processing circuitry extending the anchor data value by at least one additional anchor data element at a most significant end of the anchor data value if the overflow is detected in a portion of a sequence of processing operations that includes the anchor data processing operation; if the underflow is detected in the portion of the sequence of processing operations, extending the anchor data value by at least one additional anchor data element at the least significant end of the anchor data value; and if both the overflow and the underflow are detected in the portion of the sequence of processing operations, extending the anchor data value by at least one additional anchor data element at a most significant end of the anchor data value and at least one additional anchor data element at a least significant end of the anchor data value; An apparatus according to any one of claims 1 to 5, operable to perform at least one of:

7. 1. A data processing method comprising: Decoding one or more instructions; controlling a processing circuit, in response to the decoded instructions, to perform an anchor data processing operation to generate resultant anchor data elements of an anchor data value including one or more anchor data elements each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a range of values ​​representable by the resultant anchor data element or the anchor data value; Including, In response to the anchor data processing operation in which the anchor information indicates that the anchor data processing operation will cause the two's complement number represented by the anchor data value to overflow or underflow, the processing circuitry stores usage information in a software accessible storage location; the anchor data processing operation depends on converting a floating-point value into an anchor data element representing a portion of the bits of the two's complement number corresponding to the floating-point value; The usage information stored in response to identifying an overflow or underflow is: indicating the exponent of a floating-point value, if the anchor data processing operation also includes addition of anchor data elements obtained by converting the floating-point value to another anchor data element, indicating whether the overflow was caused by the floating-point value being outside the numerical range or by addition when the floating-point value was within the numerical range; indicating how far the exponent of the floating-point value deviates from the numerical range; and indicating the number of additional elements required in the anchor data value to accommodate a numerical equivalent of said floating-point value.

8. 1. A non-transitory storage medium storing a computer program for controlling a host data processing apparatus to provide an instruction execution environment for executing instructions, the computer program comprising: instruction decode program logic for decoding program instructions of a target code to control said host data processing apparatus to perform data processing; the instruction decode program logic includes anchor data processing program logic for controlling the host data processing apparatus to perform anchor data processing operations to generate resultant anchor data elements of an anchor data value including one or more anchor data elements each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a range of values ​​representable by the resultant anchor data element or the anchor data value; In response to the anchor data processing operation indicating that the anchor information will cause the two's complement number represented by the anchor data value to overflow or underflow, the instruction decode program logic writes, in a software accessible storage location: configured to control the host data processing device to store usage information; the anchor data processing operation depends on converting a floating-point value into an anchor data element representing a portion of the bits of the two's complement number corresponding to the floating-point value; The usage information stored in response to identifying an overflow or underflow is: indicating the exponent of a floating-point value, if the anchor data processing operation also includes addition of anchor data elements obtained by converting the floating-point value to another anchor data element, indicating whether the overflow was caused by the floating-point value being outside the numerical range or by addition when the floating-point value was within the numerical range; indicating how far the exponent of the floating-point value deviates from the numerical range; and indicating the number of additional elements required in the anchor data value to accommodate a numeric value equivalent to said floating-point value.

9. 1. A data processing method comprising: capturing a checkpoint of the architectural state; executing a portion of a sequence of data processing operations based on the architecture state captured at the checkpoint, the portion including at least one anchor data processing operation to generate resultant anchor data elements of an anchor data value including one or more anchor data elements each representing a respective portion of a bit of a two's complement number, the anchor data values ​​being associated with anchor information indicating at least one characteristic indicative of a range of values ​​representable by the resultant anchor data element or the anchor data value; performing overflow or underflow detection to detect whether the at least one anchor data processing operation causes an overflow or underflow of the anchor data value; If the overflow or underflow is detected, restoring the architectural state checkpoint; in response to the at least one anchor data processing operation causing the overflow or the underflow, modifying a format of the anchor data value in accordance with usage information stored in a software accessible storage location, the usage information indicating at least one of a cause of the overflow or the underflow and instructions on how to modify the format of the anchor data value to prevent the overflow or the underflow; retrying the portion of the sequence of data processing operations based on the modified format and the restored architectural state checkpoint; data processing methods, including

10. 10. The data processing method of claim 9, wherein if the at least one anchor data processing operation does not cause an overflow or underflow, the method comprises capturing a further checkpoint of the architectural state resulting from the portion of the data processing operation before executing a next portion of the sequence of data processing operations.

11. 11. The method of claim 9, wherein if the overflow is detected, modifying the format comprises extending the anchor data value by at least one additional anchor data element at a most significant end of the anchor data value.

12. 12. A method according to any one of claims 9 to 11, wherein if the underflow is detected, modifying the format comprises extending the anchor data value by at least one additional anchor data element at the least significant end of the anchor data value.

13. 13. A method according to any one of claims 9 to 12, wherein if both an overflow and an underflow are detected in the portion of the sequence of data processing operations, modifying the format comprises extending the anchor data value by at least one additional anchor data element at a most significant end of the anchor data value and at least one additional anchor data element at a least significant end of the anchor data value.

14. the anchor data element is an N-bit value containing V overlapping bits and W non-overlapping bits; in response to a floating-point to anchor data conversion operation to convert a floating-point value to an anchor data element, if the number represented by the floating-point value is within an allowable range of values, the W non-overlapping bits of the anchor data element are set to represent a portion of the bits of the two's complement number corresponding to the floating-point value, and the V overlapping bits of the anchor data element are set to sign-extend the W non-overlapping bits; the detection of the overflow or the underflow is performed upon execution of an overlap propagation operation that propagates a carry represented by the V overlapped bits of a first anchor data element to the W non-overlapping bits of a second anchor data element. The method according to any one of claims 9 to 13.

15. storing usage information in a software accessible storage location in response to the anchor data processing operation, the anchor information indicating that the anchor data processing operation will cause the two's complement number represented by the anchor data value to overflow or underflow; The usage information is the cause of the overflow or underflow, and instructions on how to change the format of the anchor data value to prevent the overflow or the underflow; and changing the format of the anchor data value is dependent on the usage information; The method according to any one of claims 9 to 14.

16. If the overflow or the underflow is detected, the method comprises: determining whether the usage information satisfies at least one retry condition; if the usage information satisfies the at least one retry condition, modifying the format of the anchor data value based on the usage information and retrying the portion of the sequence of data processing operations based on the modified format; if the usage information does not satisfy the at least one retry condition, terminating the sequence of data processing operations or continuing the sequence of data processing operations without retrying the at least one portion; 16. The method of claim 15, comprising:

17. 17. The method of claim 16, wherein if the usage information does not satisfy the at least one retry condition, the method includes returning the usage information or other information related to the overflow or underflow.

18. Upon completion or termination of said sequence of data processing operations, in a software accessible storage location: a condition under which a portion of said sequence of data processing operations needs to be retried; the final number of anchor data elements contained in said anchor data value when said sequence of data processing operations is completed; and final anchor information resulting from any updates made during execution of said sequence of data processing operations; storing information indicative of at least one of The method according to any one of claims 9 to 17.

19. A non-transitory storage medium storing a computer program for controlling a data processing device to perform the method according to any one of claims 9 to 18.

Citation Information

Patent Citations

  • Structure and method of high performance speculative execution processor providing special functions

    JP1999500551A

  • Data processing apparatus and method using programmable validity data

    JP2018500635A

  • overlap propagation operation

    JP2019500677A

  • An apparatus and method for processing input operand values

    WO2018138469A1