Quadruple precision on Linux vs. Mac

934 Views Asked by At

I have written a multi-dimensional numerical integration code which is able to run at double, long double or quadruple precision in Linux. All modes compile and work flawlessly but when I try to compile the same code for the quadruple precision case on Mac, I end up with errors of which I am unsure of what they mean.

I am compiling in g++ but I have tried other compilers (I did try clang just to see what it would do, but to my knowledge it cannot support quadruple precision? Correct me if I am wrong).

I link the relevant libraries and headers (including the quadmath.h header) and I end up with these errors coming from quadmath.h:

Unsupported machine mode 'TC'
typedef _Complex float __attribute__((mode(TC))) __complex128
error unknown type name '__float128'

The __float128 errors also reappear for the various mathematical operations such as acosq, asinq etc...

I have never come across the Unsupported machine mode error before. I have looked at the GNU compiler notes GNU compiler notes and GNU floating types.

It would be difficult to make a minimum working example for people to compile and test, so I am just trying to trace the errors to find out what is wrong, but I am unsure of what to do at this stage. What would be the next step given those error messages? Is there something I am missing with regards to Linux vs. Mac? I have always coded in Linux so am unfamiliar with the latter, and it seems as though there is a different way to approach quadruple precision calculations on Mac than I am used to.

Thank you for your help

-Yeti

1

There are 1 best solutions below

0
On

Different architectures (cpu types / operating systems) don't always support the same floating point types. Judging from the error message in your question, '__float128' is not supported on the Mac on which you are trying to compile your code.

There are two different ways to fix this that I would consider. The easiest is adding preprocessor directives to your code to make sure that only certain parts of the code are compiled; namely, the ones for which the floating point types are supported on the target architecture. Unfortunately, this will mean that the Mac version of your program won't be able to use quadruple precision.

The harder solution is to implement a quadruple precision floating point type yourself or find a library that has already implemented it. I guess these custom types won't be as fast as types that are natively supported, but at least you will be able to get the precision you want.