J3/03-131
To: J3
From: UK Fortran panel
Subject: Edits for UK comment MTC10 (Controlling IEEE underflow)
Date: 10 March 2003
1. Introduction
Comment MTC10 was
Add a facility for controlling IEEE underflow
There should be a standard way of finding out, and setting on
systems that permit it, the underflow handling mode. Many machines
have settable "abrupt underflow" vs. "gradual underflow" and can
run noticeably faster in abrupt underflow mode. We suggest
adding procedures IEEE_SET_DENORMAL_MODE(HANDLED) and
IEEE_GET_DENORMAL_MODE(HANDLED) with HANDLED of type default
logical. The inquiry function IEEE_SUPPORT_DENORMAL_CONTROL() would
also be appropriate.
2. Discussion
Since this actually controls what happens during underflow, calling this the
underflow mode and changing the routines to IEEE_SET_UNDERFLOW_MODE(GRADUAL),
IEEE_GET_UNDERFLOW_MODE(GRADUAL) and IEEE_SUPPORT_UNDERFLOW_CONTROL would
seem to be appropriate.
Since IEEE_SUPPORT_DENORMAL is in IEEE_ARITHMETIC (not IEEE_EXCEPTIONS),
that location would also be appropriate for these routines.
3. Edits to 02-007r3
[359:29-] Insert new section
"14.4A Underflow mode
Some processors allow control during program execution of whether underflow
produces a denormalized number in conformance with the IEEE standard
(gradual underflow) or whether to produce zero instead (abrupt underflow).
On such processors, floating-point performance is typically better in abrupt
underflow mode than in gradual underflow mode.
Control over the underflow mode is exercised by invocation of
IEEE_SET_UNDERFLOW_MODE. The function IEEE_GET_UNDERFLOW_MODE can be used
to inquire which underflow mode is in operation. The function
IEEE_SUPPORT_UNDERFLOW_MODE can be used to inquire whether this facility is
available. The initial underflow mode is processor dependent. In a
procedure other than IEEE_SET_UNDERFLOW_MODE or IEEE_SET_STATUS, the
processor shall not change the underflow mode on entry, and on return shall
ensure that the underflow mode is the same as it was on entry.
The underflow mode only affects floating-point calculations whose type is
that of an X for which IEEE_SUPPORT_UNDERFLOW_CONTROL returns true."
[359:30] After "mode" insert ", underflow mode".
[361:40+] Insert
"IEEE_SUPPORT_UNDERFLOW_CONTROL([X]) Inquire whether the processor supports
control of the underflow mode."
[363:1+] Insert
"IEEE_GET_UNDERFLOW_MODE Get the current underflow mode.
(GRADUAL)"
[363:2+] Insert
"IEEE_SET_UNDERFLOW_MODE Set the current underflow mode.
(GRADUAL)"
[365:37+] Insert new procedure
"14.9.2A IEEE_GET_UNDERFLOW_MODE (GRADUAL)
<> Get the current underflow mode (14.4A).
<> Subroutine.
<> GRADUAL shall be of type default logical. It is an
INTENT(OUT) argument. The value is true if the current underflow mode is
gradual underflow, and false if the current underflow mode is abrupt
underflow."
<> IEEE_GET_UNDERFLOW_MODE shall not be invoked unless
IEEE_SUPPORT_UNDERFLOW_CONTROL(X) is true for some X.
<> After CALL IEEE_SET_UNDERFLOW_MODE(.FALSE.), a subsequent
CALL IEEE_GET_UNDERFLOW_MODE(GRADUAL) will set GRADUAL to false."
[371:18-] Insert new procedure
"14.9.16A IEEE_SET_UNDERFLOW_MODE (GRADUAL)
<> Set the current underflow mode.
<> Subroutine.
<> GRADUAL shall be of type default logical. If it is true,
the current underflow mode is set to gradual underflow. If it is false,
the current underflow mode is set to abrupt underflow."
<> IEEE_SET_UNDERFLOW_MODE shall not be invoked unless
IEEE_SUPPORT_UNDERFLOW_CONTROL(X) is true for some X.
<> To perform some calculations with abrupt underflow and then
restore the previous mode:
USE,INTRINSIC :: IEEE_ARITHMETIC
LOGICAL SAVE_UNDERFLOW_MODE
...
CALL IEEE_GET_UNDERFLOW_MODE(SAVE_UNDERFLOW_MODE)
CALL IEEE_SET_UNDERFLOW_MODE(GRADUAL=.FALSE.)
... ! Perform some calculations with abrupt underflow
CALL IEEE_SET_UNDERFLOW_MODE(SAVE_UNDERFLOW_MODE)"
[376:2+] Insert new procedure
"14.9.22A IEEE_SUPPORT_UNDERFLOW_CONTROL() or
IEEE_SUPPORT_UNDERFLOW_CONTROL(X)
<> Inquire whether the procedure supports the ability to
control the underflow mode during program execution.
<> Inquiry function.
<> X shall be of type real. It may be a scalar or an array.
<> Default logical scalar.
<>
IEEE_SUPPORT_UNDERFLOW_CONTROL(X) has the value true if the
processor supports control of the underflow mode for floating-
point calculations with the same type as X, and false otherwise.
IEEE_SUPPORT_UNDERFLOW_CONTROL() has the value true if the
processor supports control of the underflow mode for all
floating-point calculations, and false otherwise.
<> IEEE_SUPPORT_UNDERFLOW_CONTROL(2.5) has the value true if the
processor supports underflow mode control for calculations of type default
real."
===END===