[Cfp-interest] Fw: proposed masked test to categorize floating point values

Robert Enenkel enenkel at ca.ibm.com
Thu Jun 3 10:11:47 PDT 2010




----- Forwarded by Robert Enenkel/Toronto/IBM on 06/03/2010 01:08 PM -----
|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Ian McIntosh/Toronto/IBM                                                                                                                          |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Rajan Bhakta/Toronto/IBM at IBMCA                                                                                                                    |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Cc:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Raymond Mak/Toronto/IBM at IBMCA, Robert Enenkel/Toronto/IBM at IBMCA                                                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |06/02/2010 07:45 PM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: Fw: proposed masked test to categorize floating point values                                                                                  |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|




In:
           Issue:  The _Imaginary types need to be supported.
                         One way would be to say that this same family of
   functions works on imaginary types too; eg, testfpf64x would work on
   _Imaginary _Float64x.
                         Another approach would be to define additional
   functions.
   We can't do this without tgmath support.

Which suggestion can we not do without tgmath support (just using the same
functions?  or defining additional functions?  or doing anything at all?)
What are the implications?
Do we currently have tgmath support?
Do we plan it?
Do others have it?
What wording should I put?



All:  I should send this tomorrow morning.  Since we haven't had time to
come to a single IBM position, it will probably go out roughly as is.  I'm
wondering if I should change the "testfp" suggestion to "classifyfp" or
"fpclassify" (the existing macro name)?

- Ian McIntosh          IBM Canada Lab         Compiler Back End Support
and Development



|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Rajan Bhakta/Toronto/IBM                                                                                                                          |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Ian McIntosh/Toronto/IBM at IBMCA                                                                                                                    |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Cc:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Raymond Mak/Toronto/IBM at IBMCA, Robert Enenkel/Toronto/IBM at IBMCA                                                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |06/02/2010 12:51 PM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: Fw: proposed masked test to categorize floating point values                                                                                  |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|




My preferences in red below.
My comments in bold red below.

Regards,

Rajan Bhakta
z/OS C/C++ Technical Architect
ISO C Standards Representative for Canada, IBM
C Compiler Development
Contact: rbhakta at ca.ibm.com, Rajan Bhakta/Toronto/IBM
Telephone: (905) 413-3995



|------------>
| From::     |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Ian McIntosh/Toronto/IBM                                                                                                                          |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Robert Enenkel/Toronto/IBM at IBMCA, Raymond Mak/Toronto/IBM at IBMCA, Rajan Bhakta/Toronto/IBM at IBMCA                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |06/02/2010 10:54 AM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Fw: proposed masked test to categorize floating point values                                                                                      |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|




A couple of changes, in blue.

- Ian McIntosh          IBM Canada Lab         Compiler Back End Support
and Development

----- Forwarded by Ian McIntosh/Toronto/IBM on 06/02/2010 10:04 AM -----
|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Ian McIntosh/Toronto/IBM                                                                                                                          |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Robert Enenkel/Toronto/IBM at IBMCA, Raymond Mak/Toronto/IBM at IBMCA, Rajan Bhakta/Toronto/IBM at IBMCA                                                   |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |06/01/2010 08:04 PM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |proposed masked test to categorize floating point values                                                                                          |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|




This is based on what Robert and I discussed, with some additional options.
Please comment.

This would offer a capability similar to the fpclassify macro, but with a
mask parameter.  It could, like fpclassify, be a macro instead of a
function.,

Function Name:
    Issue:  What name(s) should be used?
    Proposal 1:
      testfp<suffix>                where <suffix> is null for double, "f"
for float, "ld" for long double, "f128", "f64", "f32" or "f16" for binary,
"f64x", "f32x" etc. for extended binary, "d32", "d64" or "d128" for dfp.
                              This tests one scalar value.
        Issue:  The _Imaginary types need to be supported.
                      One way would be to say that this same family of
functions works on imaginary types too; eg, testfpf64x would work on
_Imaginary _Float64x.
                      Another approach would be to define additional
functions.
We can't do this without tgmath support.
        Issue:  The _Complex types need to be supported.
                      One way would be to define additional functions; eg,
testfpcomplexf64x, with semantics like testfpvectorany below.
                      Another would be to define functions like all three
below.

        The C Standard does not include vector types, but many
implementations do.  The following are included here not to become part of
the standard yet, but to suggest a future approach.
      testfpvector<#><suffix> where <#> is the vector length (number of
values) and <suffix> is as above.
                              This tests a vector of # values of the type
implied by the suffix.
                              Example:  testfpvector4f32 tests 4  32 bit
values and gives 4 results.
      testfpvectorany<#><suffix>    similar to testfpvector, returning a
single result.
      testfpvectorall<#><suffix>    similar to testfpvector, returning a
single result.
        Issue:  What about a vector of complex?
Can be treated as suggested for _Complex types above.
    Proposal 2:
      Same, but using "classify" instead of "test".
    Proposal 3:
      Same, but using "categorize" instead of test".
    Proposal 4:
      Shorten names by abbreviating the verb and/or omitting "fp".
    Proposal 5:
      Make it an overloaded macro, like fpclassify is.
    Proposal 6:
      Overload the fpclassify macro - if there is only one parameter it
acts like now, but if there is a second parameter is is a mask.

Issue:  Should we define macros set by the compiler to indicate which
functions are present and fast/slow, as is done for the fma functions?

Function Parameters:
      value       type double, float, long double, _Float#, _Float#x,
_Decimal#, etc., or a vector of one of those.
      mask        unsigned long, containing zero or more mask bits ored
together:
                  We need to choose macro names for these:

                       Proposal 1:
                        Result is true iff any of the conditions is true.
The sign is ignored.,
                        0x01  zero
                        0x02  normal not equal to zero
                        0x04  subnormal
                        0x08  infinity
                        0x10  quiet NaN
                        0x20  signaling NaN
                        0x40  noncanonical (dfp only)
                        eg, 0x38 means infinities and NaNs.
                      Proposal 2:
                        Result is true iff either of the first two
conditions is true and any of the other conditions is true.
                        0x01  positive
                        0x02  negative
                        0x04  zero
                        0x08  normal not equal to zero
                        0x10  subnormal
                        0x20  infinity
                        0x40  quiet NaN
                        0x80  signaling NaN
                        0x100 noncanonical (dfp only)
                        eg, 0xe3 means negative or positive infinities and
NaNs, 0x1fe means all negatives, 0x15 means positive zero or subnormal.
                      Proposal 3:
                        Same as proposal 2, except that 0x01 means "only
positive" and 0x02 means "only negative", so in the normal case one need
not add/or in 3 to get both signs (simplifies typical usage).
                  Issue:  Which proposal?  Or something else?  I recommend
proposal 3.
                  Issue:  Should the type be int or unsigned int?
I think it should stay unsigned long (for flexibility/expansion), and it
certainly should not be a signed type.
                  Issue:  We should define macros for each of these; for
example, in proposal 3 the way to specify infinities and NaNs might be
"FP_CLASS_INF | FP_CLASS_SNAN | FP_CLASS_QNAN".
I think this would be useful for a programmer.

Function Result:
                  For testfp:       _Bool, true if the condition is true,
false if it is not.
                  For testfpvector:       unsigned long, with # rightmost
bits true or false, corresponding to the vector values
                                    Issue:  Should the type be int or
iunsigned int, like fpclassify returns?
I think it should stay unsigned long (for flexibility/expansion), and it
certainly should not be a signed type.
                  For testfpvectorany:    _Bool, true if f the condition is
true for any of the vector values, false if it is not.
                  For testfpvectorall:    _Bool, true if f the condition is
true for all of the vector values, false if it is not.


- Ian McIntosh          IBM Canada Lab         Compiler Back End Support
and Development




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20100603/37e26b54/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20100603/37e26b54/attachment-0001.gif 


More information about the Cfp-interest mailing list