Fused modular multiply-add

The implementation of FMMA operations in computer systems addresses inefficiencies in modular multiply-accumulate operations by reducing memory accesses and instructions, enhancing performance in applications like cryptography and machine learning.

JP2024538668AActive Publication Date: 2024-10-23INTERNATIONAL BUSINESS MACHINE CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
JP2024520060
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2021-10-29
Filing Date
2022-10-11
Publication Date
2024-10-23
Estimated Expiration
2042-10-11

AI Technical Summary

Technical Problem

Existing computer systems face inefficiencies in performing modular multiply-accumulate operations, requiring multiple separate instructions and memory accesses, which are common in applications like cryptography and machine learning.

Method used

Implementing fused modular multiply-accumulate (FMMA) operations using a system with three multiply-accumulate units and an adder to perform the operation in a single instruction, reducing the number of memory accesses and instructions.

Benefits of technology

FMMA operations enhance computational efficiency by minimizing resource usage and latency, improving performance in applications such as cryptography and machine learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024538668000001_ABST
    Figure 2024538668000001_ABST
Patent Text Reader

Abstract

The computer-implemented method comprises performing a fused modular multiply-accumulate operation to compute d=((a*b)+c)%p, where a, b, and c are provided as a set of operands. A first multiply-accumulate unit computes a binary multiplication to compute a*b. A second multiply-accumulate unit computes a first intermediate result by updating a result of the binary multiplication with p. An accumulator of a third multiply-accumulate unit is initialized with c. The third multiply-accumulate unit computes a second intermediate result using the first intermediate result and c. An adder unit subtracts a portion of the second intermediate result from a portion of the result of the binary multiplication. An output of the adder is provided as a result of the fused modular multiply-accumulate operation.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates generally to computer technology, and more particularly to performing arithmetic operations by implementing fused modular multiply-add (FMMA) operations.

[0002] Computers are typically used for applications that perform arithmetic operations. Some applications, such as cryptography, blockchain, machine learning, image processing, computer games, e-commerce, etc., require such operations to be performed efficiently (e.g., fast). Thus, the performance of integer arithmetic has become a focus of both academic and industrial research.

[0003] Several existing techniques are used to improve the performance of computers, particularly processors and / or arithmetic logic units, by implementing arithmetic instructions that exploit or adapt the computation process to the architecture of the hardware. Examples of such techniques include splitting an instruction into multiple operations, where each operation is executed in parallel, combining two or more operations to reduce memory accesses, ordering operations to reduce memory access times, storing operands in a specific order to reduce access times, etc. For applications such as cryptography and machine learning, different types of arithmetic operations may be required. Summary of the Invention

[0004] In accordance with one or more embodiments of the invention, a computer-implemented method comprises receiving, by a processing unit, an instruction to perform a fused modular multiply-accumulate operation to compute d=((a*b)+c)%p, where a, b, and c are provided as a set of operands. The method further comprises computing, by a first multiply-accumulate unit, a binary multiplication to compute a*b. The method further comprises computing, by a second multiply-accumulate unit, a first intermediate result by updating a result of the binary multiplication with p. The method further comprises initializing an accumulator of a third multiply-accumulate unit with c. The method further comprises computing, by the third multiply-accumulate unit, a second intermediate result using the first intermediate result and c. The method further comprises subtracting, by an adder, a portion of the second intermediate result from a portion of the result of the binary multiplication. The method further comprises outputting an output of the adder as a result of the fused modular multiply-accumulate operation.

[0005] According to one or more embodiments of the invention, a system includes a set of multiply-accumulate units having a set of registers and three multiply-accumulate units each including a multiplier and an accumulator. The set of multiply-accumulate units is coupled to the set of registers. The set of multiply-accumulate units is configured to perform a method of performing a fused modular multiply-accumulate operation to compute d=((a*b)+c)%p, where a, b, and c are provided in the set of registers. The method of performing the fused modular multiply-accumulate operation comprises computing, by a first multiply-accumulate unit, a binary multiplication to compute a*b. The method further comprises computing, by a second multiply-accumulate unit, a first intermediate result by updating a result of the binary multiplication using p. The method further comprises initializing an accumulator of a third multiply-accumulate unit with c. The method further comprises computing, by the third multiply-accumulate unit, a second intermediate result using the first intermediate result and c. The method further comprises subtracting, with an adder, a portion of the second intermediate result from a portion of the result of the binary multiplication. The method further comprises outputting an output of the adder as a result of the fused modular multiply-accumulate operation.

[0006] According to one or more embodiments of the invention, a computer program product comprises a computer readable memory having computer executable instructions stored thereon that, when executed by a processor, cause the processor to perform a method of performing a fused modular multiply-accumulate operation to compute d=((a*b)+c)%p, where a, b, and c are provided as operands. The method of performing the fused modular multiply-accumulate operation comprises computing, by a first multiply-accumulate unit, a binary multiplication to compute a*b. The method further comprises computing, by a second multiply-accumulate unit, a first intermediate result by updating a result of the binary multiplication using p. The method further comprises initializing an accumulator of a third multiply-accumulate unit with c. The method further comprises computing, by the third multiply-accumulate unit, a second intermediate result using the first intermediate result and c. The method further comprises subtracting, by an adder, a portion of the second intermediate result from a portion of the result of the binary multiplication. The method further comprises outputting an output of the adder as a result of the fused modular multiply-accumulate operation.

[0007] Additional technical features and advantages are realized through the techniques of the present invention. Embodiments and aspects of the present invention are described in detail herein and are considered a part of the claimed subject matter. For a better understanding, reference is made to the detailed description and drawings. [Brief description of the drawings]

[0008] The particulars of the exclusive rights set forth herein are particularly pointed out and distinctly claimed in the claims at the conclusion of this specification. The foregoing and other features and advantages of embodiments of the present invention will become apparent from the following detailed description when read in conjunction with the accompanying drawings.

[0009] [Figure 1] FIG. 2 illustrates a set of hardware components of a processor used to compute modular multiply-accumulate.

[0010] [Diagram 2] FIG. 2 illustrates an architecture of a modular arithmetic and logic unit that facilitates execution of a fused multiply-accumulate instruction in accordance with one or more embodiments of the present invention.

[0011] [Diagram 3] 1 is a flowchart of a method for executing an FMMA_B instruction in accordance with one or more embodiments of the present invention.

[0012] [Figure 4] FIG. 2 illustrates an architecture of a modular arithmetic and logic unit that facilitates execution of a fused multiply-accumulate instruction in accordance with one or more embodiments of the present invention.

[0013] [Diagram 5] 1 is a flowchart of a method for executing an FMMA_M instruction in accordance with one or more embodiments of the present invention.

[0014] [Figure 6] FIG. 2 illustrates an example scenario in which a fused modular multiply-add instruction improves the efficiency of operations in accordance with one or more embodiments of the present invention.

[0015] [Figure 7] FIG. 2 is a block diagram of a processor in accordance with one or more embodiments of the present invention.

[0016] [Figure 8] FIG. 1 illustrates a computing system in accordance with one or more embodiments of the present invention.

[0017] The drawings shown herein are exemplary. There may be many variations to the drawings or the operations described therein without departing from the scope of the invention. For example, actions may be performed in a different order, or actions may be added, deleted, or modified. Additionally, the term "coupled" and variations thereof describe having a communication path between two elements, and do not imply a direct connection between elements without an intervening element / connection between them. All of these variations are considered part of this specification.

[0018] In the accompanying figures and the following detailed description of the disclosed embodiments, various elements shown in the figures are given two or three digit reference numbers. With few exceptions, the left-most digit of each reference number corresponds to the figure in which the element is first shown. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0019] A technical solution is described herein for improving the efficiency of a computer processor by facilitating the execution of a fused modular multiply-add (FMMA) operation. In computer systems, the arithmetic operations of addition and multiplication are frequently used. The fused multiply-add instruction (FMA) is a common method for performing a multiply-add operation in a single instruction to reduce the number of instructions to be executed and to reduce memory accesses, thus improving execution efficiency. The FMA instruction is a widely used instruction in both integer and floating-point operations.

[0020] The present invention addresses the technical problem of improving performance by performing a fusion operation that reduces the number of instructions and memory accesses when performing modular addition and modular multiplication operations compared to the two operations performed separately. The present invention facilitates a single instruction that performs FMMA operations and techniques for implementing such operations on state-of-the-art hardware.

[0021] Modular arithmetic is frequently used in several computer applications such as cryptography, blockchain, artificial intelligence, etc. Thus, by providing improvements in the execution of such applications by providing FMMA operations / instructions, embodiments of the present invention provide practical applications in the field of computing technology, and at least in fields where such FMMA operations are used. Furthermore, embodiments of the present invention provide improvements to the computing technology itself by improving the execution of modular multiply-add operations.

[0022] Computer systems typically use binary number representation when performing arithmetic operations. Furthermore, computer systems, and in particular processors and their arithmetic logic units (ALUs), have a predefined "width" or "word size" (w), e.g., 32 bits, 64 bits, 128 bits, etc. The width indicates the maximum number of bits that the processor can process at one time. The width of a processor can be indicated by the size of a register, the size of the ALU processing width, or any other such processing constraints of the components associated with the processor.

[0023] Table 1 provides the Barrett modular multiplication algorithm that is typically used to perform modular multiplication in computing systems. Column 1 of Table 1 shows the sequence of calculations that are performed to compute the modular multiplication of operands a, b with a prime number p. Given a, b, and p as inputs, the output of the modular multiplication is: r=(a*b)%p which is calculated as shown in column 1. Column 2 of Table 1 gives the bit width required for the calculation, assuming k is the bit width of the processor. Table 1 [Table 1]

[0024] Table 2 provides the Montgomery modular multiplication algorithm, which is a typical alternative used to perform modular multiplication in computing systems. Column 1 of Table 2 shows the sequence of calculations performed to compute the modular multiplication of operands a, b with a prime number p. Given a, b, and p as inputs, the output of the modular multiplication in this case is c=(a*b*R -1 )%p which is calculated as shown in column 1, where the X(lo) and X(hi) expressions denote the low half of the bits in X and the high half of the bits in X, respectively. Column 2 of Table 2 gives the bit width required for the calculation, assuming k is the bit width of the processor, where w is a value that depends on the word size of the processor. Table 2 [Table 2]

[0025] Furthermore, as can be seen from Tables 1 and 2, existing solutions require at least three separate multiplications to be performed. Embodiments of the present invention, as described herein, fuse such multiplications to reduce data access and instruction execution time. In addition, embodiments of the present invention facilitate the fusing of addition operations.

[0026] 1 illustrates a set of hardware components of a processor used to compute modular multiply-accumulate. Processor 10 may include ALU 15 having one or more components that compute the modular multiply-accumulate. One or more components of ALU 15 may use pipelining to improve efficiency of the computation in one or more embodiments of the invention. Additionally, in some embodiments of the invention, results of one or more components shown may be stored as intermediate values, e.g., in memory, registers, etc. Components that store intermediate (or final) results are also identified in FIG. 1.

[0027] Components of ALU 15 include one or more instances of adder 22, multiplier 24, and accumulator 26. Figure 1 also shows a code array 14 that contains the instructions to be executed, including the operands that will be used for the modular multiply-accumulate.

[0028] 1 further illustrates the bit-width (e.g., 128b, 256b) of one or more components in ALU 15 and the width of the data transferred from one component to another during computation. It is understood that the bit-width may vary in one or more embodiments of the invention. However, the bit-width of the hardware may limit the modular multiply-accumulate that can be performed on that hardware.

[0029] The pipeline shown in Figure 1 is used in an exemplary implementation of Barrett and Montgomery modular multiplication, shown in Tables 1 and 2, respectively. As can be seen, three multipliers 24 are required. Furthermore, the pipeline does not include the addition operation that embodiments of the present invention provide after fusing the multiplications.

[0030] An embodiment of the present invention provides two FMMA instructions. A first FMMA instruction computes a Barrett modular multiplication followed by an addition in a fused manner. The syntax for the first FMMA instruction is fmma_b a, b, c, d. A second FMMA instruction is provided computes a Montgomery modular multiplication followed by an addition in a fused manner. The syntax for the second FMMA instruction is fmma_m a, b, c, d. In the case of the Montgomery algorithm, the operands are in Montgomery format and the generated result is also in Montgomery format. The conversion of numbers to and from Montgomery format can be performed using techniques already known or developed in the future without affecting the technical solution provided by the embodiment of the present invention.

[0031] where a, b, c, and d are operands and may be registers in the processor 10. In both cases the output is to compute d=((a*b)+c)%p. In some embodiments of the present invention, a prime number p may also be an operand in the instruction syntax, but in the description herein p is assumed here to have ALU 15 initialized with a prime number (step 1 in both Barrett / Montgomery) and precomputation is called before the fmma_b / fmma_m instructions.

[0032] 2 illustrates a modular ALU architecture that facilitates execution of FMMA instructions, according to one or more embodiments of the present invention. The modular ALU 25 includes one or more instances of an adder 22, a multiplier 24, and an accumulator 26, and uses a pipeline process similar to that of the ALU 15. However, an accumulator 26 is used instead of the adder 22. The ALU 25 therefore includes three multiply-accumulate (MAC) units 21, 23, 27, with each MAC block including a multiplier 24 and an accumulator 26. Furthermore, an adder 29 having an additional bit width (e.g., 129 bits) is used following the three MAC units 21, 23, 27. In some embodiments of the present invention, the bit width of the adder 29 is one more than the bit width of the multiplier 24 in the three MAC units 21, 23, 27.

[0033] In ALU 25, operands a, b are read and used by MAC 21, and operand c is read by MAC 27, and in particular by accumulator 26 of MAC 27. Adder 29, which has a wider bit width, receives the output from MAC 27.

[0034] 3 illustrates a flow chart of a method for executing an FMMA_B instruction in accordance with one or more embodiments of the present invention. The method 300 includes, at block 301, loading first and second operands a, b into the first MAC 21. The operands are read from the data array 8. At block 302, the first MAC 21 performs a binary multiplication of the first and second operands and accumulates partial products.

[0035] In block 303, the second MAC 23 performs a binary multiplication of the result of block 302 with a predefined constant Mu. In one or more embodiments of the invention, Mu is stored in the second MAC 23.

[0036] In block 304, the third operand c is read to initialize the accumulator 26 in the third MAC 27. The third operand is read into the lower bits of the accumulator 26 of the third MAC 27. For example, if the accumulator 26 is 256 bits wide and the operand c is 128 bits wide, then c is stored in bits 128-255 of the accumulator 26. Note that the third operand can be read into the third MAC in parallel with the binary multiplication in the first MAC 21 and the second MAC 23.

[0037] In block 305, the third MAC 27 multiplies the most significant bits of the result from step 303 with a coefficient p and accumulates the result in a pre-initialized accumulator 26 of the third MAC 27, where the "most significant bits" may represent the first half of the result from step 303 (e.g., the first 128 bits from a 256-bit value).

[0038] In block 306, adder 22 subtracts the least significant bits of the result in step 305 from the least significant bits of the result in step 302. The results of steps 302 and 305 are the values ​​stored in accumulators 26 in the first MAC 21 and third MAC 27, respectively.

[0039] In block 307, a condition correction is performed to ensure that the result from step 306 is within the valid range 0 to p.

[0040] The FMMA_B instruction executed in this manner is more efficient than the current sequential pipeline execution of modular multiply-add operations. Consider using ALU 25 to execute fmma_b on a 512-bit operand in accordance with one or more embodiments of the present invention. As described, the third operand is used to initialize the lower 512 bits of accumulator 26 in third MAC 27. The "Storage MAX OP Size" ensures that the accumulator has a sufficient bit width to write to the third operand. Accumulator 26 in third MAC 27 then operates on the output of multiplier 24, accumulating the data (i.e., adding the output with the pre-initialized third operand). There may be a total of 513 bits in the result of third MAC 27, i.e., 512 bits from the multiplication and an additional bit due to the initial state of accumulator 26. These bits are fed to 129-bit adder 29 to perform step 5 in Table 1.

[0041] Now, since a 512-bit operation is being performed 128 bits wide, the bits are fed over a period of 4 clocks in some embodiments of the invention. The first 3 clocks will have 128 bits each, and the final clock will empty the last 129 bits. In other embodiments, the read can be performed in fewer or additional clocks.

[0042] In this manner, the fused modular multiply-accumulate is performed by ALU 25 using Montgomery modular multiplication. FMMA_M performed in this manner improves efficiency by requiring fewer resources compared to performing the modular multiply-accumulate separately and sequentially.

[0043] 4 illustrates an ALU that facilitates execution of FMMA instructions in accordance with one or more embodiments of the present invention. The modular ALU 35 includes one or more instances of the adder 22, the multiplier 24, and the accumulator 26, and uses a pipeline process similar to that of the ALU 15. Here, the ALU 35 includes three MAC units, namely, a first MAC 31, a second MAC 33, and a third MAC 37. Following the three MAC units 31, 33, 37, an adder 39 having an additional bit width (e.g., 129 bits) is used. In some embodiments of the present invention, the bit width of the adder 39 is one more than the bit width of the multiplier 24 in the three MAC units 31, 33, 37.

[0044] In ALU 35, the third operand c is read and used to initialize the most significant bits of accumulator 26 in first MAC unit 31. An adder 39 having a wider bit width receives the output from MAC 37.

[0045] 5 illustrates a flow chart of a method for executing an FMMA_M instruction in accordance with one or more embodiments of the present invention. The method 500 includes, at block 501, loading first and second operands a, b into a first MAC 31. The operands are read from the data array 8. At block 502, an accumulator 26 of the first MAC 31 is initialized by loading a third operand c into the most significant bits of the accumulator 26.

[0046] In block 503, a binary multiplication of the first and second operands is performed and the result is accumulated in the pre-initialized accumulator 26 of the first MAC 31. The third operand c is accordingly added to the result of the binary multiplication of the first two operands.

[0047] In block 504, the least significant bits of 503 are multiplied with a pre-computed inverse of the coefficient P by a second MAC 33, which in some embodiments of the present invention is initialized with a value of p before invoking method 500.

[0048] In block 505, the third MAC 37 multiplies the least significant bits of step 504 by a coefficient p, which in some embodiments of the invention is stored in the third MAC 37 prior to invoking the method 500.

[0049] Further, in block 506, adder 39 subtracts the most significant bits of the result of step 505 from the most significant bits of the result of step 503. Adder 39 may calculate the subtraction using two's complement, or any other known technique.

[0050] In block 507, a condition correction is performed to ensure that the result from step 506 is within the valid range 0 to p.

[0051] Here, the "higher bits" can represent the first half of the result from one or more steps (e.g., bits 0-127 from a 256-bit value), and the "lower bits" represent the second half of the result (e.g., bits 128-255 from a 256-bit value). The results of steps 503, 504, and 505 are the values ​​stored in accumulators 26 in first MAC 31, second MAC 33, and third MAC 37, respectively.

[0052] The FMMA_M instruction executed in this manner is more efficient than the current sequential pipeline execution of modular multiply-add operations. Consider using ALU 35 to execute fmma_m on a 128-bit operand in accordance with one or more embodiments of the present invention. The third operand is used to initialize the most significant 128 bits of the 256-bit accumulator 26 of the first MAC unit 31. The least significant 128 bits of the result of accumulator 26 are passed to the next, i.e., second and third MAC units 33, 37. In some cases, there may be 129 most significant bits, i.e., 128 due to the multiplication and additional bits due to the initial state of accumulator 26 of the first MAC 31. These 129 bits are then passed to adder 39 to perform step 5 in Table 2.

[0053] The present embodiment improves the support of existing modular arithmetic units to support fused multiply-add with minimal hardware modification. The amount of hardware modification is only to increase the width of the adder by one bit (e.g., adder 29, 39). By initializing the accumulator with a third operand, FMMA can be accomplished using any modular multiplication algorithm that the user may desire. Furthermore, by performing FMMA by initializing the accumulator, the present embodiment improves the processor's operation when modular multiply-add operations are required sequentially. The overall latency of both modular multiplication and fused modular multiply-add operations is exactly the same. Thus, the present embodiment provides an improvement in the number of instructions required and the overall latency of operations that can also leverage FMMA.

[0054] 6 illustrates an example scenario in which the FMMA instruction improves the efficiency of operations in accordance with one or more embodiments of the present invention. Consider an example code 600 of an algorithm that performs an iterative Number Theoretic Transform (NTT) algorithm that includes a butterfly operation. It is understood that any other algorithm / code that requires an FMMA operation can be used instead of the illustrated example, and that the FMMA instruction described herein can be used in any other code. For example 60, assume that A[k+j] is in register R0, A[k+j+m / 2] is in R1, w is in R2, and R3, R4 are temporary scratchpad registers.

[0055] As shown in block 61, an ALU (e.g., ALU15) that cannot execute a fused modular multiply-add instruction uses two scratchpad registers (e.g., R2, R4) and four instruction calls are required to execute the request. By using any one of the fmma instructions described herein, as shown in block 62, the number of scratchpad registers required is reduced from two to one. Furthermore, the overall latency is reduced by at least the time of one modular addition.

[0056] Thus, embodiments of the present invention facilitate improvements to computing technology by providing a practical application for implementing a single instruction that performs a fused modular multiply-add operation. As provided herein, the fused operation can be implemented on current state-of-the-art hardware without significant hardware modifications.

[0057] 7 illustrates a block diagram of a processor in accordance with one or more embodiments of the present invention. Processor 10 may include, among other components, an instruction fetch unit 601, an instruction decode operand fetch unit 602, an instruction execution unit 603, a memory access unit 604, a write-back unit 605, a set of registers 12, and an FMMA executor 606. In one or more embodiments of the present invention, FMMA executor 606 may be part of an arithmetic logic unit (ALU) (not shown).

[0058] In one or more embodiments of the invention, processor 10 may be one of several computer processors in a processing unit, such as a central processing unit (CPU), a graphics processing unit (GPU), a tensor processing unit (TPU), or any other processing unit of a computer system. Alternatively, or in addition, processor 10 may be a computing core that is part of one or more processing units.

[0059] The instruction fetch unit 601 is responsible for organizing program instructions to be fetched from memory and executed in the proper order, and forwarding them to the instruction execution unit 603. The instruction decode and operand fetch unit 602 facilitates parsing the instructions and operands, e.g., address resolution, prefetching, before forwarding the instructions to the instruction execution unit 603. The instruction execution unit 603 performs operations and calculations according to the instructions. The memory access unit 604 facilitates accessing specific locations in a memory device coupled to the processor 10. The memory device may be a cache memory, a volatile memory, a non-volatile memory, etc. The write-back unit 605 facilitates recording the contents of the registers 12 to one or more locations in the memory device. The FMMA executor 606 facilitates executing the FMMA instructions (either fmma_b, or fmma_b) as described herein.

[0060] It should be noted that the components of the processor may vary in one or more embodiments of the present invention without affecting the features of the technical solution described herein. In some embodiments of the present invention, the components of the processor 10 may be combined, separate, or different from those described herein.

[0061] Referring now to FIG. 8, a computer system 1500 is generally shown according to one embodiment. The computer system 1500 may be a target computing system used to perform one or more functions that require a modular multiply-add operation to be performed. The computer system 1500 may be an electronic computer framework that comprises and / or utilizes any number and combination of computing devices and networks that utilize various communication technologies as described herein. The computer system 1500 may be easily scalable, extensible, and modular, with the ability to change to different services or reconfigure some features independently of others. The computer system 1500 may be, for example, a server, desktop computer, laptop computer, tablet computer, or smartphone. In some examples, the computer system 1500 may be a cloud computing node. The computer system 1500 may be described in the general context of computer system-executable instructions, such as program modules, executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer system 1500 may be practiced in a distributed cloud computing environment where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.

[0062] As shown in FIG. 8, the computer system 1500 has one or more central processing units (CPUs) 1501a, 1501b, 1501c, etc. (collectively or generally referred to as processors 1501). The processors 1501 can be single-core processors, multi-core processors, computing clusters, or any number of other configurations. The processors 1501, also referred to as processing circuits, are coupled to a system memory 1503 and various other components via a system bus 1502. The system memory 1503 can include a read-only memory (ROM) 1504 and a random access memory (RAM) 1505. The ROM 1504 is coupled to the system bus 1502 and may include a basic input / output system (BIOS) that controls certain basic functions of the computer system 1500. The RAM is a read-write memory coupled to the system bus 1502 for use by the processors 1501. The system memory 1503 provides temporary memory space for the operation of the above-mentioned instructions during operation. The system memory 1503 may include random access memory (RAM), read-only memory, flash memory, or any other suitable memory system.

[0063] Computer system 1500 includes an input / output (I / O) adapter 1506 and a communications adapter 1507 coupled to a system bus 1502. I / O adapter 1506 may be a small computer system interface (SCSI) adapter that communicates with a hard disk 1508 and / or any other similar components. I / O adapter 1506 and hard disk 1508 are collectively referred to herein as mass storage 1510.

[0064] Software 1511 for execution on computer system 1500 may be stored in mass storage 1510. Mass storage 1510 is an example of a tangible storage medium readable by processor 1501, where software 1511 is stored as instructions executed by processor 1501 to cause computer system 1500 to operate as described herein below with respect to various figures. Examples of computer program products and the execution of such instructions are discussed in more detail herein. Communications adapter 1507 interconnects system bus 1502 with network 1512, which may be an external network, enabling computer system 1500 to communicate with other such systems. In one embodiment, portions of system memory 1503 and mass storage 1510 collectively store an operating system, which may be any suitable operating system, such as z / OS or AIX operating systems from IBM Corporation, for coordinating the functions of the various components shown in FIG. 8.

[0065] Additional input / output devices are shown as connected to the system bus 1502 via a display adapter 1515 and an interface adapter 1516. In one embodiment, adapters 1506, 1507, 1515, and 1516 may be connected to one or more I / O buses that are connected to the system bus 1502 via an intermediate bus bridge (not shown). A display 1519 (e.g., a screen or display monitor) is connected to the system bus 1502 by a display adapter 1515, which may include a graphics controller to improve performance of graphics-intensive applications and a video controller. A keyboard 1521, a mouse 1522, speakers 1523, etc. may be interconnected to the system bus 1502 via an interface adapter 1516, which may include, for example, a Super I / O chip that integrates multiple device adapters into a single integrated circuit. Suitable I / O buses for connecting peripheral devices such as hard disk controllers, network adapters, and graphics adapters typically include common protocols such as Peripheral Component Interconnect (PCI). Thus, as configured in FIG. 8, computer system 1500 includes processing capability in the form of a processor 1501, storage capabilities including system memory 1503 and mass storage 1510, input means such as a keyboard 1521 and a mouse 1522, and output capabilities including speakers 1523 and a display 1519.

[0066] In some embodiments, the communications adapter 1507 can transmit data using any suitable interface or protocol, such as an Internet Small Computer System Interface, among others. The network 1512 can be a cellular network, a wireless network, a wide area network (WAN), a local area network (LAN), or the Internet, among others. An external computing device can connect to the computer system 1500 through the network 1512. In some examples, the external computing device can be an external web server or a cloud computing node.

[0067] It should be understood that the block diagram of Figure 8 is not intended to indicate that computer system 1500 includes all of the components illustrated in Figure 8. Rather, computer system 1500 can include any suitable fewer or additional components (e.g., additional memory components, embedded controllers, modules, additional network interfaces, etc.) not illustrated in Figure 8. Furthermore, the embodiments described herein with respect to computer system 1500 may be implemented with any suitable logic, which as referred to herein, in various embodiments, can include any suitable hardware (e.g., a processor, embedded controller, or application specific integrated circuit, among others), software (e.g., an application, among others), firmware, or any suitable combination of hardware, software, and firmware.

[0068] The present invention may be a system, method, and / or computer program product at any possible level of technical detail of integration. The computer program product may include a computer-readable storage medium (or media) having computer-readable program instructions for causing a processor to perform aspects of the present invention.

[0069] A computer-readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of computer-readable storage media includes the following: portable computer diskettes, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), static random access memories (SRAMs), portable compact disk read-only memories (CD-ROMs), digital versatile disks (DVDs), memory sticks, floppy disks, mechanically encoded devices such as punch cards or ridge structures in grooves that record instructions, and any suitable combination of the foregoing. Computer-readable storage medium, as used herein, should not be construed as a transitory signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., light pulses passing through a fiber optic cable), or an electrical signal transmitted through a wire.

[0070] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to the respective computing / processing device or to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and transfers the computer-readable program instructions to a computer-readable storage medium in the respective computing / processing device for storage.

[0071] The computer readable program instructions for carrying out the operations of the present invention may be either assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state setting data, configuration data for an integrated circuit, or source or object code written in any combination of one or more programming languages, including object oriented programming languages ​​such as Smalltalk, C++, etc., and procedural programming languages ​​such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partially on the user's computer as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be to an external computer (e.g., via the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may execute computer readable program instructions to personalize the electronic circuitry by utilizing state information of the computer readable program instructions to perform aspects of the invention.

[0072] Aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer readable program instructions.

[0073] These computer readable program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, whereby the instructions, executed via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams. These computer readable program instructions can also be stored on a computer readable storage medium, whereby the instructions can instruct a computer, programmable data processing apparatus, and / or other device to function in a particular manner, whereby the computer readable storage medium having stored thereon the instructions includes an article of manufacture including instructions that implement aspects of the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams.

[0074] The computer-readable program instructions may also be loaded into a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be executed on the computer, other programmable apparatus, or other device to generate a computer-implemented process, whereby the instructions executing on the computer, other programmable apparatus, or other device implement the functions / operations specified in one or more blocks of the flowcharts and / or block diagrams.

[0075] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts or block diagrams may represent a module, segment, or portion of instructions that includes one or more executable instructions that implement the specified logical function. In some alternative implementations, the functions described in the blocks may occur in a different order than that described in the figures. For example, two blocks shown in succession may in fact be executed substantially simultaneously, or the blocks may possibly be executed in the reverse order depending on the functionality involved. It should also be noted that each block of the block diagrams and / or flowchart diagrams, and combinations of blocks in the block diagrams and / or flowchart diagrams, may be implemented by a dedicated hardware-based system that executes the specified functions or operations, or executes a combination of dedicated hardware and computer instructions.

[0076] The description of various embodiments of the present invention has been presented for illustrative purposes, but is not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terminology used in this specification has been selected to best explain the principles of the embodiments, practical applications, or technical improvements to the art found in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. receiving, by a processing unit, an instruction to perform a fused modular multiply-add operation to compute d=((a*b)+c)%p, where a, b, and c are provided as a set of operands; computing, by a first multiply-accumulate unit, a binary multiplication to compute a*b; calculating, by a second multiply-accumulate unit, a first intermediate result by updating a result of the binary multiplication using p; initializing an accumulator of a third multiply-accumulate unit with c; calculating, by the third multiply-accumulate unit, a second intermediate result using the first intermediate result and c; subtracting, by an adder, a portion of the second intermediate result from a portion of the result of the binary multiplication; and outputting the output of the adder as a result of the fused modular multiply-add operation. A computer-implemented method comprising:

2. 2. The computer-implemented method of claim 1, wherein the adder has a wider bit-width than a multiplier in the first multiply-accumulate unit.

3. 3. The computer-implemented method of claim 2, wherein the bit-width of the adder is one more than the bit-width of the multiplier in the first multiply-accumulate unit.

4. 2. The computer-implemented method of claim 1, wherein initializing the accumulator of the third multiply-accumulate unit with c comprises storing the value of c in low order bits of the accumulator.

5. 2. The computer-implemented method of claim 1, wherein computing the first intermediate result comprises performing a second binary multiplication of the result of the binary multiplication of a*b with a precomputed constant.

6. 6. The computer-implemented method of claim 5, wherein computing the second intermediate result comprises multiplying most significant bits of the first intermediate result with a coefficient p, a value of p being stored in the third multiply-accumulate unit prior to invoking the instruction.

7. 2. The computer-implemented method of claim 1, further comprising: correcting the output of an adder to ensure that the output is between 0 and p.

8. a set of registers; and A set of multiply-accumulate units having three multiply-accumulate units each including a multiplier and an accumulator. the set of multiply-accumulate units are coupled to the set of registers, the set of multiply-accumulate units are configured to perform a method of performing a fused modular multiply-accumulate operation to compute d=((a*b)+c)%p, where a, b, and c are provided in the set of registers, and performing the fused modular multiply-accumulate operation comprises: computing, by a first multiply-accumulate unit, a binary multiplication to compute a*b; calculating, by a second multiply-accumulate unit, a first intermediate result by updating a result of the binary multiplication using p; initializing an accumulator from a third multiply-accumulate unit with c; calculating, by the third multiply-accumulate unit, a second intermediate result using the first intermediate result and c; subtracting, by an adder, a portion of the second intermediate result from a portion of the result of the binary multiplication; and outputting the output of the adder as a result of the fused modular multiply-add operation. A system comprising:

9. 9. The system of claim 8, wherein the adder has a wider bit width than a multiplier in the first multiply-accumulate unit.

10. 10. The system of claim 9, wherein the bit-width of the adder is one more than the bit-width of the multiplier in the first multiply-accumulate unit.

11. 9. The system of claim 8, wherein initializing the accumulator from the third multiply-accumulate unit with c comprises storing the value of c in least significant bits of the accumulator.

12. 9. The system of claim 8, wherein the step of computing the first intermediate result comprises performing a second binary multiplication of the result of the binary multiplication of a*b with a precomputed constant.

13. 13. The system of claim 12, wherein computing the second intermediate result comprises multiplying most significant bits of the first intermediate result with a coefficient p, a value of p being stored in the third multiply-accumulate unit prior to invoking an instruction to perform the fused modular multiply-accumulate operation.

14. 9. The system of claim 8, further comprising the step of correcting the output of the adder to ensure that the output is between 0 and p.

15. 1. A computer program product comprising a computer readable memory having computer executable instructions stored thereon, the computer executable instructions, when executed by a processor, causing the processor to perform a method of performing a fused modular multiply-add operation to compute d=((a*b)+c)%p, where a, b, and c are provided as operands, and performing the fused modular multiply-add operation comprises: computing, by a first multiply-accumulate unit, a binary multiplication to compute a*b; calculating, by a second multiply-accumulate unit, a first intermediate result by updating a result of the binary multiplication using p; a step of initializing an accumulator from a third multiply-accumulate unit at c; calculating, by the third multiply-accumulate unit, a second intermediate result using the first intermediate result and c; subtracting, by an adder, a portion of the second intermediate result from a portion of the result of the binary multiplication; and outputting the output of said adder as a result of said fused modular multiply-add operation; A computer program product comprising:

16. 16. The computer program product of claim 15, wherein a bit-width of the adder is one more than a bit-width of a multiplier in the first multiply-accumulate unit.

17. 16. The computer program product of claim 15, wherein initializing the accumulator from the third multiply-accumulate unit with c comprises storing the value of c in low order bits of the accumulator.

18. 16. The computer program product of claim 15, wherein the step of computing the first intermediate result comprises performing a second binary multiplication of the result of the binary multiplication of a*b with a precomputed constant.

19. 20. The computer program product of claim 18, wherein the step of calculating the second intermediate result comprises multiplying most significant bits of the first intermediate result by a coefficient p, the value of p being stored in the third multiply-accumulate unit prior to invoking an instruction to perform the fused modular multiply-accumulate operation.

20. 16. The computer program product of claim 15, further comprising: correcting the output of the adder to ensure that the output is between 0 and p.