How to use quadruple precision (_Quad) data type?

How to use quadruple precision (_Quad) data type?


Hi, guys

I want to use the quadruple (128 bits) precision floating number data type in my C language programme by Intel C++ compiler 16.0 with the Visual Studio 2015 on the Windows 7 system. The intel c++ compiler has already been integrated to the Visual Studio and I have already switched to "use the Intel Compiler".

But I just can't identity the quadruple data type variables, i.e. when I code like " _Quad a; ",  the compiler just would not pass, with the error reads " error : identifier "_Quad" is undefined".

So should I set any options for the compiler to enable the use of quadruple precision data type ? 

I have already set the "Floating Point Model" to "Precise"; and set "Floating Point Expression Evaluation" to "Extended".

Or should I include any thing in the header?

I attached my very simple C language code, can anyone help me with this problem? 

THANK YOU VERY MUCH !!! 

Tony

 

11 posts / novo 0

You should specify compiler option /Qoption,cpp,--extended_float_types to recognize _Quad type.


Thank you Olga Malysheva! 

Could u please tell me how to set this "/Qoption,cpp,--extended_float_types" ?

since I could not find the corresponding options in the VS IDE.

Should it be set in 'command line' way or something? and how to enable this compiler option?

THANK U!

Tony

 


Quote:

Olga Malysheva (Intel) wrote:

You should specify compiler option /Qoption,cpp,--extended_float_types to recognize _Quad type.

Thank you!

could u please tell me how to enable this option? since i couldnt find the corresponding option item in VS2015 IDE

should this be set by 'command line' or something? and how?

thanks again~

Tony

 


Yes, you just need to add that switch to command line. Some more info on _Quad, as there is little online documentation for that.

To specify quadruple constant explicitly, use 'q' suffix (3.1415926q).

Intel compiler do support arithmetic and comparison operations on quad-precision floating point nubmers, and conversions to/from all integer/floating point data types. However, there is no native scanf/printf support for quad-precision on Windows (on Linux you may rely on libquadmath from GCC to do that). One quick and easy way to get around that is to explicitly down convert the numbers to double or long double precision.

Quad precision math function are available in Intel math library (libm), however they are not declared in the header files. If you need to use any of them, you would have to declared the prototype yourself (otherwise you may get segfault). Quadruple precision analogs of libm functions have '__' prefix (double underscore) and 'q' suffix. For example, _Quad __sqrtq (_Quad x); is quadruple analog for double 'sqrt'.

Please let me know if you have any more question.

Thanks,

Jingwei


Quote:

Jingwei Z. (Intel) wrote:

Yes, you just need to add that switch to command line. Some more info on _Quad, as there is little online documentation for that.

To specify quadruple constant explicitly, use 'q' suffix (3.1415926q).

Intel compiler do support arithmetic and comparison operations on quad-precision floating point nubmers, and conversions to/from all integer/floating point data types. However, there is no native scanf/printf support for quad-precision on Windows (on Linux you may rely on libquadmath from GCC to do that). One quick and easy way to get around that is to explicitly down convert the numbers to double or long double precision.

Quad precision math function are available in Intel math library (libm), however they are not declared in the header files. If you need to use any of them, you would have to declared the prototype yourself (otherwise you may get segfault). Quadruple precision analogs of libm functions have '__' prefix (double underscore) and 'q' suffix. For example, _Quad __sqrtq (_Quad x); is quadruple analog for double 'sqrt'.

Please let me know if you have any more question.

Thanks,

Jingwei

Jingwei, 

Thank you so much for providing these useful information on use of the _Quad floating point number data type in Intel C++ compiler. As u just said, there is little documents on the _Quad even in Intel C++ compiler official user handbook and forum (or if I have just missed any documents mentioning the _Quad? I read the "Intel C++ compiler 16.0 user and reference guide"), so is there any other documents covering this _Quad data usage in Intel C compiler topic?

The reason I wanna to use the 128 bits _Quad floating point number is for the computation of the satellite orbit, where the double floating point number may not meet the very high precision computation requirement sometimes. I have several more specific questions:

1. as u said, "there is no native scanf/printf support for quad-precision on Windows", so if I compiler and run my C/C++ language program by VS IDE in the Windows 7 platform, is there any way for me to output the calculation results in the quadruple way ? (i.e. keeping the output number at the level of quadruple significant digits. for example to output the quadruple variable as 0.999999999999999999999999 in Ascii or binary form) . What if writing a specific function to print them? and how?

2. "on Linux you may rely on libquadmath from GCC to do that", so can the Intel C++ compiler support the scanf/printf on Linux?

3. I learnt that Intel ifort supports the REAL (16) data type in Fortran language, so whether or not the Intel ifort or Fortran language is more supporting and convenient for the usage of quadruple precision data than the Intel C++ compiler or C/C++ language?

4. could u recommand any Math library u know that supports the high precision (like quadruple) computation? it would be better if the library can enable the matrix computation in higher precision than double data type. Like NAG math library or anything?

5. the use of quadruple precision can be "over-shooting" sometimes, does Intel compiler (Fortran or C/C++ language) support any data type between double precision and quadruple precision? like extended-double data type or decimal data type as in C#? (long double type seems to give no much improvement in the significant digits)

So many questions, I would appreciate it if u could take time helping me with them.

Thanks again!

Tony 


Well, I have used the highly-efficient Intel MKL for matrix computation, but as I learnt MKL doesnt support the quadruple data type.


 if I compiler and run my C/C++ language program by VS IDE in the Windows 7 platform, is there any way for me to output the calculation results in the quadruple way ?

You probably want to try Boost.Multiprecision library - http://www.boost.org/doc/libs/1_65_1/libs/multiprecision/doc/html/index.html

2. "on Linux you may rely on libquadmath from GCC to do that", so can the Intel C++ compiler support the scanf/printf on Linux?

Using libquadmath (and quadmath_snprintf() to convert a quad-precision float to a string) is described here - https://gcc.gnu.org/onlinedocs/libquadmath/quadmath_005fsnprintf.html. See the example there. You can change it to use _Quad instead of __float128 but formatting and printing will still work with ICC. Don't forget to link with libquadmath (add -lquadmath) and add -Qoption,cpp,--extended_float_types to the command line to use _Quad.

does Intel compiler (Fortran or C/C++ language) support any data type between double precision and quadruple precision?

ICC supports 'long double' type that is enabled by using /Qlong-double option.


Quote:

Olga Malysheva (Intel) wrote:

 if I compiler and run my C/C++ language program by VS IDE in the Windows 7 platform, is there any way for me to output the calculation results in the quadruple way ?

You probably want to try Boost.Multiprecision library - http://www.boost.org/doc/libs/1_65_1/libs/multiprecision/doc/html/index.html

2. "on Linux you may rely on libquadmath from GCC to do that", so can the Intel C++ compiler support the scanf/printf on Linux?

Using libquadmath (and quadmath_snprintf() to convert a quad-precision float to a string) is described here - https://gcc.gnu.org/onlinedocs/libquadmath/quadmath_005fsnprintf.html. See the example there. You can change it to use _Quad instead of __float128 but formatting and printing will still work with ICC. Don't forget to link with libquadmath (add -lquadmath) and add -Qoption,cpp,--extended_float_types to the command line to use _Quad.

does Intel compiler (Fortran or C/C++ language) support any data type between double precision and quadruple precision?

ICC supports 'long double' type that is enabled by using /Qlong-double option.

Thank you very much, Olga!

I will try them in my program ~

Tony

 


Dear Olga (or anyone),

Could you please let us know on how to use complex _Quad type of Intel C++ compiler on Windows? What is the complex _Quad type name and compilers options required (if any)? I have tried several variants, including "_Complex _Quad", and similar - without success.

Would appreciate any help.


>>3. I learnt that Intel ifort supports the REAL (16) data type in Fortran language, so whether or not the Intel ifort or Fortran language is more supporting and convenient for the usage of quadruple precision data than the Intel C++ compiler or C/C++ language?

Are you aware that you can write a mixed language program? Front-end in C++/C#/... and computational back-end in Fortran.

Jim Dempsey

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo