[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: no quadmath.h on ppc64 ?



On 17/04/18 09:53 AM, Gabriel F. T. Gomes wrote:
Hi, Dennis.

On Tue, 17 Apr 2018, Dennis Clarke wrote:

nix$ cat pq.c

Where does this test case file come from?

Here, there, my head, where ever.
It was a long day and I had been trying all manner of variations
in order to get something anything that was trivial and worked.
To be even more clear, worked everywhere.

Let's toss that mess away and try this :


#define _XOPEN_SOURCE 600
#include <quadmath.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <locale.h>
#include <sys/utsname.h>

#define BUFLEN 128
int main ( int argc, char *argv[] ) {

    int n, j, precision = FLT128_DIG + 2;
    struct utsname uname_data;
    long double pi = 3.1415926535897932384626433832795028841971693993L;

    char buf[BUFLEN];
    char *obuf;
    size_t buf_len = (size_t) BUFLEN;
    __float128 pi_quad = M_PI;

    setlocale( LC_MESSAGES, "C" );
    if ( uname( &uname_data ) < 0 ) {
        fprintf ( stderr,
                 "WARNING : Could not attain system uname data.\n" );
        perror ( "uname" );
    } else {
        printf ("        system name = %s\n", uname_data.sysname );
        printf ("          node name = %s\n", uname_data.nodename );
        printf ("            release = %s\n", uname_data.release );
        printf ("            version = %s\n", uname_data.version );
        printf ("            machine = %s\n", uname_data.machine );
    }
    printf ("\nsizeof(long double) = %i\n\n", sizeof(long double) );

    /* correct 128 bit big endian hex representation of pi is
     *   0x40 00 92 1f b5 44 42 d1 84 69 89 8c c5 17 01 b8 */

    printf("\naddr \"pi\" is %p\n", &pi );
    printf("\ncontents : " );
    for ( j=0; j<sizeof(long double); j++ )
        printf("%02x ", ((unsigned char *)&pi)[j] );
    printf("\n" );

    printf("%+42.38Lf\n", pi );
    printf(" +3.1415926535897932384626433832795028841971 <- pi\n" );

    printf("\nLets try the supposedly 128-bit __float128 type.\n\n" );

    pi_quad = strtoflt128("3.1415926535897932384626433832795028841971",
                                                                NULL );

    n = quadmath_snprintf( buf, buf_len, "%Qg", pi_quad );

    if ( (size_t)n < buf_len ) {
        printf ( "%s\n", buf );
    }

    n = quadmath_snprintf( NULL, 0, "%+-#46.*Qe", precision, pi_quad );

    if ( n > -1 ) {
        obuf = calloc ( (size_t) (n+1), (size_t)sizeof(unsigned char));
        if ( obuf ) {
            n = quadmath_snprintf ( obuf, (n+1), "%+-#46.*Qe",
                                                  precision, pi_quad );
            printf ( "%s\n", obuf );
            printf ( "also n = %i\n", n );
        } else {
            fprintf ( stderr, "ERROR : calloc failed??.\n" );
            return ( EXIT_FAILURE );
        }
        free ( obuf );
    }
    printf("\n\n&pi_quad addr %p is :\n", &pi_quad );
    printf("\ncontents : 0x" );
    for ( j=0; j<sizeof(__float128); j++ )
        printf("%02x ", ((unsigned char *)&pi_quad)[j] );
    printf("\n" );
    printf("pi value : ");
    printf("0x40 00 92 1f b5 44 42 d1 ");
    printf("84 69 89 8c c5 17 01 b8\n");
    printf("\n or the exact reverse order on little endian boxen\n");

    return ( EXIT_SUCCESS );

}

First test on some very old old pentium boxen ( HP Kayak XU ) running
Debian sid with gcc 7.3.0 thus :


i686$ cat /proc/version
Linux version 4.16.0-genunix (dclarke@phobos) (gcc version 7.3.0 (Debian 7.3.0-13)) #1 SMP Tue Apr 3 06:37:32 GMT 2018

i686$ grep -E "^processor|^vendor|^cpu|^model|^physical" /proc/cpuinfo | sed 's/processor/\nprocessor/'

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 5
model name      : Pentium II (Deschutes)
cpu MHz         : 399.017
physical id     : 0
cpu cores       : 1
cpuid level     : 2

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 5
model name      : Pentium II (Deschutes)
cpu MHz         : 399.017
physical id     : 0
cpu cores       : 1
cpuid level     : 2
i686$

* yes really *


i686$ gcc --version
gcc (Debian 7.3.0-14) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

i686$ which gcc
/usr/bin/gcc
i686$


i686$ /usr/bin/gcc -m32 -std=iso9899:2011 -pedantic \
> -march=i386 -mno-fancy-math-387 -mno-80387 \
> -mno-fp-ret-in-387 -mno-align-double \
> -m128bit-long-double -mlong-double-128 \
> -o foo foo.c -lquadmath
i686$
i686$ ./foo
        system name = Linux
          node name = phobos
            release = 4.16.0-genunix
            version = #1 SMP Tue Apr 3 06:37:32 GMT 2018
            machine = i686

sizeof(long double) = 16


addr "pi" is 0xbfaf0e60

contents : b8 01 17 c5 8c 89 69 84 d1 42 44 b5 1f 92 00 40
 +0.00000000000000000000000000000000000000
 +3.1415926535897932384626433832795028841971 <- pi

Lets try the supposedly 128-bit __float128 type.

3.14159
+3.14159265358979323846264338327950280e+00
also n = 46


&pi_quad addr 0xbfaf0dd0 is :

contents : 0xb8 01 17 c5 8c 89 69 84 d1 42 44 b5 1f 92 00 40
pi value : 0x40 00 92 1f b5 44 42 d1 84 69 89 8c c5 17 01 b8

 or the exact reverse order on little endian boxen
i686$


works as expected and the output data looks just fine.


Let's try that on a PowerPC machine with ye 970 procs :

nix$ cat /proc/version
Linux version 4.15.0-2-powerpc64 (debian-kernel@lists.debian.org) (gcc version 7.3.0 (Debian 7.3.0-11)) #1 SMP Debian 4.15.11-1 (2018-03-20)


nix$ cat /proc/cpuinfo
processor       : 0
cpu             : PPC970MP, altivec supported
clock           : 2500.000000MHz
revision        : 1.1 (pvr 0044 0101)

processor       : 1
cpu             : PPC970MP, altivec supported
clock           : 2500.000000MHz
revision        : 1.1 (pvr 0044 0101)

processor       : 2
cpu             : PPC970MP, altivec supported
clock           : 2500.000000MHz
revision        : 1.1 (pvr 0044 0101)

processor       : 3
cpu             : PPC970MP, altivec supported
clock           : 2500.000000MHz
revision        : 1.1 (pvr 0044 0101)

timebase        : 33333333
platform        : PowerMac
model           : PowerMac11,2
machine         : PowerMac11,2
motherboard     : PowerMac11,2 MacRISC4 Power Macintosh
detected as     : 337 (PowerMac G5 Dual Core)
pmac flags      : 00000000
L2 cache        : 1024K unified
pmac-generation : NewWorld
nix$


nix$ which gcc
/usr/bin/gcc
nix$ /usr/bin/gcc -m64 -std=iso9899:2011 -mcpu=970 -maltivec -mfull-toc -mregnames -o foo foo.c
foo.c:3:10: fatal error: quadmath.h: No such file or directory
 #include <quadmath.h>
          ^~~~~~~~~~~~
compilation terminated.
nix$


Dead in the water.


Let's try with the gcc I just bootstrapped :


nix$
nix$ /usr/local/gcc7/bin/gcc -v -m64 -std=iso9899:2011 -mcpu=970 -maltivec -mfull-toc -mregnames -o foo foo.c
Using built-in specs.
COLLECT_GCC=/usr/local/gcc7/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc7/libexec/gcc/powerpc64-unknown-linux-gnu/7.3.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ../gcc-7.3.0/configure --build=powerpc64-unknown-linux-gnu --target=powerpc64-unknown-linux-gnu --host=powerpc64-unknown-linux-gnu --prefix=/usr/local/gcc7 --disable-nls --enable-threads=posix --enable-shared --enable-bootstrap --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-__cxa_atexit --with-system-zlib --disable-objc-gc --with-long-double-128 --enable-stage1-languages=c,c++ --enable-stage1-checking=misc --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld --enable-languages=c,c++,fortran,go,lto,objc,obj-c++ --with-pkgversion='genunix Mon Apr 16 00:04:56 GMT 2018'
Thread model: posix
gcc version 7.3.0 (genunix Mon Apr 16 00:04:56 GMT 2018)
COLLECT_GCC_OPTIONS='-v' '-m64' '-std=c11' '-mcpu=970' '-maltivec' '-mfull-toc' '-mregnames' '-o' 'foo' /usr/local/gcc7/libexec/gcc/powerpc64-unknown-linux-gnu/7.3.0/cc1 -quiet -v -imultiarch powerpc64-linux-gnu -D__unix__ -D__gnu_linux__ -D__linux__ -Asystem=linux -Asystem=unix -Asystem=posix foo.c -quiet -dumpbase foo.c -m64 -mcpu=970 -maltivec -mfull-toc -mregnames -auxbase foo -std=c11 -version -o /var/tmp/dclarke/ccanbRNm.s GNU C11 (genunix Mon Apr 16 00:04:56 GMT 2018) version 7.3.0 (powerpc64-unknown-linux-gnu) compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/powerpc64-linux-gnu"
ignoring nonexistent directory "/usr/local/gcc7/lib/gcc/powerpc64-unknown-linux-gnu/7.3.0/../../../../powerpc64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc7/lib/gcc/powerpc64-unknown-linux-gnu/7.3.0/include
 /usr/local/include
 /usr/local/gcc7/include
 /usr/local/gcc7/lib/gcc/powerpc64-unknown-linux-gnu/7.3.0/include-fixed
 /usr/include/powerpc64-linux-gnu
 /usr/include
End of search list.
GNU C11 (genunix Mon Apr 16 00:04:56 GMT 2018) version 7.3.0 (powerpc64-unknown-linux-gnu) compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4128dcdbf8336d61e21fa946bc1dc074
foo.c:3:10: fatal error: quadmath.h: No such file or directory
 #include <quadmath.h>
          ^~~~~~~~~~~~
compilation terminated.
nix$


Dead in the water.


There is no quadmath here.  At all.

However there is a lovely info file :

nix$ find /usr/local/gcc7 -type f | grep -i "quadmath"
/usr/local/gcc7/share/info/libquadmath.info
nix$


However the sources are in the gcc 7.3.0 tree :

nix$ ls /usr/local/build/gcc-7.3.0/libquadmath
COPYING.LIB Makefile.in config.h.in libquadmath.info math quadmath-rounding-mode.h quadmath_weak.h ChangeLog acinclude.m4 configure libquadmath.texi printf quadmath.h strtod Makefile.am aclocal.m4 configure.ac libtool-version quadmath-imp.h quadmath.map
nix$


So anyways ... with coffee in hand and a bit more awake now I can say that there is no quadmath.h nor libquadmath on ppc64.


Dennis






















Reply to: