Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

The benefits of Fedora 38 long double transition in ppc64le

May 16, 2023
Tulio Magno Quites Machado Filho
Related topics:
CompilersC, C#, C++LinuxOpen source
Related products:
Red Hat Enterprise Linux

Share:

    Fedora 38 will have a new feature for ppc64le. Clang has begun using the IEEE 128-bit long double by default instead of the IBM 128-bit long double format. This allows Clang to behave the same way as GCC, which switched to IEEE 128-bit long double on ppc64le on Fedora 36. This floating point format benefits from the hardware implementation available on IBM® Power9® processor-based servers and IBM® Power10™ processor-based servers.

    Background of the floating point format

    The IBM System/360 Model 85 was released in 1968 and supported a 128-bit extended precision floating point format. A few decades later this format became known in the open source communities as IBM 128-bit long double or IBM double-double.

    This floating point format provides a mantissa of 106 bits, 11 bits for the exponent and a signal bit. Meanwhile, its 64-bit floating point format provides a matissa of 53 bits, 11 bits as the exponent and a signal bit. According to the IBM® AIX® documentation, this data type can store numbers with more precision than the 64-bit data type, it does not store numbers of greater magnitude.

    In 1985, the IEEE 754 Working Group for binary floating-point arithmetic established the IEEE Standard 754-1985, defining two binary floating point formats: a 32-bit (binary32) and a 64-bit (binary64). The C language was also in the process of standardization, requiring compilers to support at least three different binary floating point types called float, double, and long double.

    The ppc64le architecture on Linux adopted the binary32 format as float, binary64 as double and ibm128 as long double, inheriting the same formats for the newer little endian architecture used on the older big endian ppc64.

    In 2008, the IEEE Computer Society published the IEEE Std 754-2008, introducing an 128-bit binary floating point format (binary128).

    Format Signal bits Exponent bits Mantissa bits Size (Bytes)
    binary32 1 8 24 4
    binary64 1 11 53 8
    binary128 1 15 113 16
    ibm128 1 11 106 16

    In 2017, IBM introduced the Power9 processor with native hardware support for the binary128 format, leading the way to changing the default long double type used in C and C++. However, this transition occurred only on ppc64le because it requires an IBM® Power8® processor or newer. The same transition on ppc64 is more complex because it may run on processors that do not support 128-bit registers from VSX or Altivec, requiring an emulation to happen on 64-bit general purpose registers as well as different rules for argument passing.

    How to transition to IEEE 128-bit long double

    In most cases, programs and libraries will not require any modifications. They must be rebuilt with the Clang provided with Fedora 38 to start using the IEEE 128-bit long double. While IBM Power9 introduced native hardware support for binary128, a long double based on this format also works on IBM Power8. The only difference is the performance improvement that newer processors provide.

    Note that programs built with a previous version of Clang will continue to work using the IBM 128-bit long double.

    Adapting code to IEEE 128-bit long double

    There is a small group of programs that make assumptions about which long double format ppc64le uses. In those cases, these programs have to be modified.

    When rewriting this code, I suggest taking advantage of the features provided by the ISO C standard to write code that will be executed correctly on different processors and operating systems, regardless of the long double format used by the C Library (e.g., using the macro LDBL_MANT_DIG) as follows:

    #include <float.h>
    
    #if LDBL_MANT_DIG == 113
    /* Insert code for IEEE binary128 long double. */
    #elif LDBL_MANT_DIG == 106
    /* Insert code for IBM 128-bit long double. */
    #elif LDBL_MANT_DIG == 64
    /* Insert code for Intel 80-bit long double. */
    #elif LDBL_MANT_DIG == 53
    /* Insert code for IEEE binary64 long double. */
    #endif

    You can still use IBM 128-bit long double

    It is also possible to continue using the IBM 128-bit long double with Clang on Fedora 38. When building the source code, ensure the parameters -mabi=ibmlongdouble -mlong-double-128 are passed to Clang as follows:

    $ clang -c -mabi=ibmlongdouble -mlong-double-128 test.c -o test.o

    The same parameters also work on GCC.

    C++ programs built with Clang must also get linked to libstdc++ because other libraries, such as libc++, do not support both long double formats. The Fedora builds of Clang use libstdc++ by default, but if you would like to enforce the usage of libstdc++, use -stdlib=libstdc++ when calling clang++, as follows:

    $ clang++ -c -mabi=ibmlongdouble -mlong-double-128 -stdlib=libstdc++ test.cc -o test.o

    Benefits of transitioning to IEEE 128-bit long double

    The transition to IEEE 128-bit long double on ppc64le will allow programs to compute numbers with greater magnitude and more precision without causing any performance regressions on IBM Power9 and newer processors. This transition is expected to help scientific and engineering programs as well as improve platform compatibility with well-established standards.

    Feel free to comment below if you have questions or comments. We welcome your feedback.

    Last updated: August 14, 2023

    Related Posts

    • Some notes on porting Delve to PPC64LE

    • GCC 5 in Fedora

    • Customize the compilation process with Clang: Optimization options

    • How C array sizes become part of the binary interface of a library

    • New C features in GCC 13

    Recent Posts

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    • How to integrate vLLM inference into your macOS and iOS apps

    What’s up next?

    Ready to level up your Linux knowledge? Our Intermediate Linux Cheat Sheet presents a collection of Linux commands and executables for developers and system administrators who want to move beyond the basics.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue