From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 5D0B43858428; Mon, 13 Dec 2021 22:00:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D0B43858428 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BDKEXMb026604; Mon, 13 Dec 2021 22:00:30 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 3cx9r9yw30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Dec 2021 22:00:30 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BDLwCpA001504; Mon, 13 Dec 2021 22:00:29 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma02wdc.us.ibm.com with ESMTP id 3cvkma8a08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Dec 2021 22:00:29 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BDM0TUJ13893892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Dec 2021 22:00:29 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53EBD11208A; Mon, 13 Dec 2021 22:00:29 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29F5D112081; Mon, 13 Dec 2021 22:00:29 +0000 (GMT) Received: from toto.the-meissners.org (unknown [9.160.34.144]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTPS; Mon, 13 Dec 2021 22:00:29 +0000 (GMT) Date: Mon, 13 Dec 2021 17:00:27 -0500 From: Michael Meissner To: Thomas Koenig Cc: "fortran@gcc.gnu.org" , gcc mailing list , Michael Meissner Subject: Re: [power-ieee128] Which options for libquadmath / native ieee128 Message-ID: Mail-Followup-To: Michael Meissner , Thomas Koenig , "fortran@gcc.gnu.org" , gcc mailing list References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Q-jP4_dVDure2GIK41KqMxjKl2lpXZWJ X-Proofpoint-GUID: Q-jP4_dVDure2GIK41KqMxjKl2lpXZWJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-13_10,2021-12-13_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 clxscore=1015 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112130127 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Dec 2021 22:00:33 -0000 On Mon, Dec 13, 2021 at 09:29:16PM +0100, Thomas Koenig wrote: > > Hi, > > looking at what the REAL(KIND=17) numbers should be compiled for, I see > the following options that should be considered: > > a) xsaddqp and friends are not supported by the CPU; libquadmath should > be called for all operations, including simple arithmetic. Note, we do not use the emulator in libquadmath. Libgcc has support for doing software emulation of the IEEE 128-bit basic support. > b) xsaddqp and friends are supported, but glibc is too old and lacks the > *ieee128 functions. libquadmath should be called for these > functions. Yes, this would be the place to call libquadmath. Or possibly don't use libquadmath at all and don't allow KIND=17. It is probably better for the users if we use libquadmath instead of disabling it all together. > c) xsaddqp and friends are supported, and glibc is new enough. Call > the *ieee128 functions. The necessary support is in the little endian GLIBC 2.32 or newer. I don't recall if you also need Elf abi V2 (which is default on little endian). You could check via: #if (((__GLIBC__ * 1000) + __GLIBC_MINOR__) >= 2032 && \ (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \ (_CALL_ELF == 2)) If you are writing C code for the library, and using _Float128 for the type instead of using long double and using the -mabi=ieeelongdouble switch, you want to define the following macros before math.h or other system include files are included: #define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 #define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 > What is the best way to check in the library config files that the quad > precision instructions are supported (to differentiate between a) on the > one hand and b) and c) on the other? You can check whether long double is IEEE 128-bit via: #if defined(__LONG_DOUBLE_IEEE128__) /* or */ #if __LONG_DOUBLE_IEEE128__ and similarly to check for IBM 128-bit long double: #if defined(__LONG_DOUBLE_IBM128__) /* or */ #if __LONG_DOUBLE_IBM128__ To check whether IEEE 128-bit instructions are enabled: #if defined(__FLOAT128_HARDWARE__) /* or */ #if __FLOAT128_HARDWARE__ To check whether the _Float128 or __float128 keywords are available (whether or not the hardware supports the instructions): #if defined(__FLOAT128_TYPE__) /* or */ #if __FLOAT128_TYPE__ Note, that C++ does not support the _Float128 type (which is in one of the IEC papers), but it does support the non-standard __float128 keyword. Unfortunately, __float128 _Complex does not work. There is a GLIBC macro that gives the appropriate _Complex type for __float128 use in C++, but I don't remember what it is. Alternatively, it might be simpler to build the library parts using long double and build those modules with the appropriate options. > > And which options to the compiler make sure the libquadmath library > is called? The libqaudmath library should always be linked in if it is built. I had actually meant to turn off building it once all of the 2.32 support went in, but I never did. Note, I haven't tested libquadmath in a long time. To compile C/C++ code where long double is IEEE 128-bit use: -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute For Fortran code, I think you have to remove the -Wno-psabi. But it may be buggy. Similarly to force long double to be IBM 128-bit, no matter what the defaults are use: -mabi=iibmlongdouble -Wno-psabi -mno-gnu-attribute The no-gnu-attribute says to disable setting the GNU attribute that says what the default long double type is. It is necessary when building libraries with both 128-bit types. -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meissner@linux.ibm.com