Browse Prior Art Database

Use of fused multiply-add instructions in Java Virtual Machines

IP.com Disclosure Number: IPCOM000126145D
Original Publication Date: 2005-Jul-04
Included in the Prior Art Database: 2005-Jul-04
Document File: 7 page(s) / 122K

Publishing Venue

IBM

Abstract

The Java* programming language, which uses a subset of the IEEE 754-1985 floating-point standard, appears to prohibit the use of fused multiply-add instructions available on some processors. This disclosure explains how fused multiply-add instructions can be used in some circumstances to perform Java programming language compliant floating-point arithmetic. The ideas can also be used for other languages such as C or C++ operating in a mode where fused multiply-add instructions could not normally be used.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 25% of the total text.

Page 1 of 7

Use of fused multiply-add instructions in Java Virtual Machines

The Java* programming language requires compliance of the Java Virtual Machine with a subset of the IEEE 754-1985 floating-point standard. http://standards.ieee.org/reading/ieee/std_public/description/busarch/754-1985_desc
.html

    Each Java floating-point operation (addition, subtraction, multiplication, division) must be completed according to the standard. There is a minor exemption for the double-extended-exponent value set and float-extended-exponent value set. http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html This exemption allows certain intermediate results to be calculated with an extended exponent range, although the mantissa is rounded to the result precision. This maps the behaviour of Intel x87 floating-point hardware operating in a reduced precision mode.

    Modern processors such as IBM's** PowerPC***processors, z/Architecture****processors and Intel's IA-64 processors provide a fused multiply-add (FMA) instruction, which multiplies two operands to full accuracy without any rounding, overflow or underflow, then adds the third operand before then rounding the result to the final precision. The whole operation is done at the same speed as a single add or a single multiply can be done, and for many applications actually gives higher accuracy. This instruction cannot in general be used to evaluate a Java multiply followed by a Java add in just one instruction as it would give different answers than required by the Java standard, which requires the result of the multiply to be correctly rounded before the add is performed.

    In certain situations a fused multiply-add instruction can be used for Java programs.

    If the multiply would not have been subject to any rounding if done as a separate operation, i.e. the intermediate result was exact when expressed in the final precision, then using a fused multiply-add would have the same effect as doing the multiply and then the add.

    If the intermediate result would not have been subject to any rounding of the mantissa, but could overflow the exponent range then the Java extensions for extended-exponent value sets can be used, and a fused multiply-add can be used in more situations.

    The fused multiply-add could be quicker, with a shorter instruction sequence and use fewer registers and so be an advantage over using a separate multiply instruction followed by an add instruction.

    When a Java method or methods contains a floating-point add (or subtract) operator acting upon the result of a floating-point multiply then this is a candidate for the application of this invention

    Precision of an operand is here defined as the number of bits (inclusive) between the most significant and least significant set bits of a number, with the additional definition of the precision of an exact power of two as zero.

    The range and maximum precision of the operands of the specific multiply instruction are ascertained. The...