07-312r2
To: J3
From: Stan Whitlock
Subject: IEEE elemental intrinsics interpretation request
Date: 2007 November 15
NUMBER: F03/0107
TITLE: Are the IEEE_* elemental routines required
KEYWORDS: IEEE, elemental routines
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress
QUESTION:
The descriptions for all of the IEEE elemental intrinsics listed in
14.9 say something like "shall not be invoked if
IEEE_SUPPORT_DATATYPE(X) is false".
I believe this was to allow a careful programmer to do something
like
if (IEEE_SUPPORT_DATATYPE(x)) then
x = IEEE_SCALB(x,2)
else
x = x*4
endif
and program around partial IEEE support.
But 14.9.2 says that "IEEE_ARITHMETIC contains the following
[routines] for which IEEE_SUPPORT_DATATYPE(X) [is] true"
I'd read that as saying the functions aren't there for cases where
IEEE_SUPPORT_DATATYPE is false. But, then, there is no way to
program around their absence. The example above will fail at load
time because IEEE_SCALEB is absent.
If a processor provides the IEEE_ARITHMETIC module must it
provide versions of all of the intrinsics for all of the available
datatypes, including those for which IEEE_SUPPORT_DATATYPE() is false?
ANSWER:
Yes, edits are provided to make this clear.
DISCUSSION: It was intended that the above coding snippet could be
used by a careful programmer to program portably for processors which
have varying degrees of IEEE support. This might require processors to
provide some stub function for each routine and for each non-IEEE
datatype they support. If a program invokes on of the stub routines,
it is a run-time programming error. Nevertheless, a program which
has references to the routines, but doesn't invoke them, must load
and execute.
EDITS:
[370:8-9] Replace
"for reals X and Y for which IEEE_SUPPORT_DATATYPE(X) and
IEEE_SUPPORT_DATATYPE(Y) are true"
with
"for all reals X and Y"
Insert a note at [369:28+]
"The standard requires that code such as
if (IEEE_SUPPORT_DATATYPE(x)) then
x = IEEE_SCALB(x,2)
else
x = x*4
endif
be executable. The elemental functions in the IEEE_ARITHMETIC
module (14.9.2) must exist for all real kinds supported by the
processor, even if IEEE_SUPPORT_DATATYPE returns false for
some kinds. However, if IEEE_SUPPORT_DATATYPE returns false
for a particular kind, these functions must not be invoked
with arguments of that kind. This allows a careful programmer
to write programs that work on processors that do not support
IEEE arithmetic for all real kinds.
The processor might provide stub routines which allow the program
to link and execute, but which will abort if they are invoked."
SUBMITTED BY: Dick Hendrickson
HISTORY: 07-312 m182 F03/0107 Submitted
07-312r2 m182 Answer