Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

mathimf and windows

Petros_Mamales
Beginner
3,252 Views

Hi,

I have a couple of questions on the usage of the math library in windows (64bit, vs2010).

In the documentation of the intel c++ compiler (12.1), in the article "Using Intel Math Library" a simple program appropriate for windows is presented and then the user is instructed to add the compilation flags /Qlong-double /Qpc80 . After adding them in the Additional Compile Options of project properties (there is no visual entry for this), I got a warning that the options are not recognized and therefore ignored . What am I doing wrong ?

Also, tried to go through the mathimf.h file and so some ppc macro __INTEL_COMPILER (or something very similar). Where is this defined ? Should I define it ? Also there seems to be __ICL etc. where can one obtain a list of the meaning of these macros ? Unfortunately the documentation shipped with the product (Parallel Studio 2011) leaves some to be desired..

Thank you in advance for your help,

Petros

0 Kudos
97 Replies
SergeyKostrov
Valued Contributor II
1,064 Views
>>.../Qlong-double /Qpc80. After adding them in the Additional Compile Options of project properties (there is no visual >>entry for this), I got a warning that the options are not recognized and therefore ignored. You could read a statement about support for long double floating point values on a page 707 in a Intel C++ compiler User and Reference Guide ( PDF Document number: 304968-023US ). Here is a quote: ... Note that the Microsoft compiler and Microsoft-provided library routines (such as printf) do not provide support for 80-bit floating-point values. As a result, this option should only be used when referencing symbols within parts of your application built with this option or symbols in libraries that were built with this option. ... >>...macro __INTEL_COMPILER (or something very similar). Where is this defined? __INTEL_COMPILER is internal predefined macro of Intel C/C++ compiler.
0 Kudos
SergeyKostrov
Valued Contributor II
1,064 Views
>>...Unfortunately the documentation shipped with the product (Parallel Studio 2011) leaves some to be desired... If you found some error or some subject is not clearly described ( in a PDF file or Online ) please provide a feedback. Thanks in advance.
0 Kudos
TimP
Honored Contributor III
1,064 Views

You can access the .chm including description of the options you mentioned from the Start menu, in case you have difficulty with the installation of ICL documentation under the VS GUI.  Start>all programs>intel parallel studio....>documentation>

The ability to support long-double as wider than double, which was always incompatible with the Microsoft library/header usage, appears to have been removed, and /Qpc80 would then apply only to the IA32 compiler in /arch:IA32 mode.

As Sergey hinted, you should check the Additional Predefined Macros category in the documentation, and maybe file an issue to request restoration of fuller documentation on __INTEL_COMPILER.

0 Kudos
Petros_Mamales
Beginner
1,064 Views

imP and Sergey,

Thank you for your comments. However- Sergey- the documentation indeed says that the long double in printf is not supported. aturally, since MS crt does not -really-know long doubles  . However this in no way means, that the option to the compiler should not be recognized ! This has nothing top do with what I use it for .Also, I do not know the page reference you are offering since I only have the chm which I view from the Help menu in vs2010.However, (if this were somewhere else, then I don't know how to get to it - I have no pdf file with the compiler reference as you seem to suggest - would though be strange since  this is the place where the usage of the math library is described ).

At the end of the day, I still don't know how to use the 80bit long-double from the 12.1 intel c++ compiler within the vs2010 environment.

Also, TimP, I see in the documentation, under compiler reference, a topic named "Macros". I do not see any Additional Predefined Macros entry. Where is it ? (again, looking at the chm in vs2010)

Thank you in advance for the help (indebted that you came back to me on a Sunday!! -;)))

PS: Apologies if all this is too naive/pedantic, but the vs2010 help facility is the only documenattion I have. Is there something more that I could see on the internet ?

0 Kudos
Bernard
Valued Contributor I
1,064 Views

I would like to add that Microsoft compilers and run-time libraries provide backward compatibility for long double primitive type.This compatability is intended mainly to be used by 16-bit compiled code.

Here is the link :http://msdn.microsoft.com/en-us/library/9cx8xs15.aspx

0 Kudos
Petros_Mamales
Beginner
1,064 Views

Apologies: to TimP for mis-spelling his name ( the evils of wireless keyboard ;-)).

Clarification: I only tried to compile the program that is presented in the documentation .Apparently I do not have documentation that responders refer to.

Question: Is there a more complete documentation for the intel c++ 12.1 compiler I could download ? Could it be that it is the C++ Compiler XE 2011 that supports this ?  (are they different ?)

0 Kudos
TimP
Honored Contributor III
1,064 Views

XE 2011 and 12.0/12.1 are the same thing.  Current versions are 13.0, but 12.1 remains fully supported (but as you say, not strongly documented as to features which may have been dropped since earlier versions).

Perhaps you could quote a URL of documentation to which you refer.

0 Kudos
TimP
Honored Contributor III
1,064 Views

XE 2011 and 12.0/12.1 are the same thing.  Current versions are 13.0, but 12.1 remains fully supported (but as you say, not strongly documented as to features which may have been dropped since earlier versions).

Perhaps you could quote a URL of documentation to which you refer.

0 Kudos
SergeyKostrov
Valued Contributor II
1,064 Views
>>...At the end of the day, I still don't know how to use the 80bit long-double from the 12.1 intel c++ compiler within the vs2010 environment. Please do a very simple test: - Enable all compiler options related to 'long double' ( even if they will be ignored, or unsupported, etc ) - Try that code: ... printf( "Size of [ long double ] in bytes is: %d", sizeof( long double ) ); ... What is a result? Here is my question: If the result is 8 bytes ( 64 bits ) or 10 bytes ( 80 bits ) how in these two cases 80-bit precision could be supported? At least 12 bytes ( 96-bits ) are needed. Note: MinGW is the only C/C++ compiler I know ( actually it could be more... ) that allocates 12 bytes ( 96-bits ) when a long double variable is declared.
0 Kudos
Petros_Mamales
Beginner
1,064 Views

TimP,

I use the chm documentation that comes in vs2010. I checked it against the document Sergey suggested and is pretty much identical (especially when it comes to the specific topic) maybe a bit more skewed to Linux.

Sergey,

It is pretty clear to me that printf being a function from the ms rt will have no concept of an 80 bit long double. This is besides the point, though.

The compiler tells me that the options are NOT supported. As I mentioned before, I am using the example from the documentation, where in the printf line the 80bit floater is casted down. So the printf is not the problem. And the intel documentation does a very good job to warn the user, when it says that this has to be internal to the his/hers application.

Thank you for your help TimP and Sergey .

0 Kudos
TimP
Honored Contributor III
1,064 Views

"Note: MinGW is the only C/C++ compiler I know ( actually it could be more... ) that allocates 12 bytes ( 96-bits ) when a long double variable is declared."

As far as I know, icc for linux follows the same practices as gcc: for 32-bit compilation, 80-bit long double is padded to 96 bits; for 64-bit mode, it's padded to 128 bits for (sometimes) improved performance.

0 Kudos
Bernard
Valued Contributor I
1,064 Views

>>>It is pretty clear to me that printf being a function from the ms rt will have no concept of an 80 bit long double. This is besides the point, though.>>>

For what kind of mathematical calculation do you need 80-bit long double primitive precision?

0 Kudos
Bernard
Valued Contributor I
1,064 Views

@Petros

If you are interested in arbitrary precision calculation(elementary functions mainly trigo) please let me know.I will kindly share with you my work.

0 Kudos
SergeyKostrov
Valued Contributor II
1,064 Views
>>...It is pretty clear to me that printf being a function from the ms rt will have no concept of an 80 bit long double. This is besides the >>point, though. Petros, We're trying to help you and the test I've provided simply checks how many bytes will be allocated on your platform for a long double variable. Once again, could you run the test and tell us result, please: ... printf( "Size of [ long double ] in bytes is: %d", sizeof( long double ) ); ...
0 Kudos
TimP
Honored Contributor III
1,064 Views

If your include files are in order (by no means assured), the contents of <float.h> would enable you to figure out how much of the storage space is padding.  If <float.h> is incorrect, http://homepages.cwi.nl/~steven/enquire.html would show you how to generate entries which match what your compiler actually implements for a given option set.

0 Kudos
Petros_Mamales
Beginner
1,064 Views

Sergey,

Apologies if I made your efforts more difficult. I followed your suggestion and ran the following little snippet :

(vs2010, intelc++ 12.1, win7 64bit)

#include "mathimf.h"
#include <iostream>

int main() {
    long double ld = (long double)(0) ;
    std::cout << sizeof( ld ) << std::endl ;
    return 1;
}

The result I got was 8 - i.e. like an ordinary double. My understanding is that if the 80bit long double was used, it would be 10.

I linked with libm.lib - and, of course, during the compilation phase I got the warnings :

1>  Building with Intel(R) C++ Compiler 12.1
1>ClCompile:
1>  ***** ClCompile (Win32 - Intel C++)
1>icl : warning #10148: option '/Qlong-double' not supported
1>icl : warning #10148: option '/Qpc80' not supported

Ilyapolak

Thank you very very much for your kind offer. Will not be needing it, but really thank you ! I mainly need this featutre for 2 reasons:

a) porting libraries from Linux that need a long double for their own thing

b) for reduction methods of very long arrays .

TimP

Not sure I understood.

I would like to thank everyone who has contributed to help ;-)

0 Kudos
Bernard
Valued Contributor I
1,064 Views

>>>Ilyapolak

Thank you very very much for your kind offer. Will not be needing it, but really thank you ! I mainly need this featutre for 2 reasons:

a) porting libraries from Linux that need a long double for their own thing

b) for reduction methods of very long arrays>>>

@Petros

I have forgotten to add that my arbitrary precision library is written in Java and is based on BigDecimal class.

Does Linux support long double primitive?

0 Kudos
Petros_Mamales
Beginner
1,064 Views

Ilyapolak

I think so - not a Linux person, so please don't quote me - oh, I forgot I just put this in writting ;-))

Again, thank you very much  for the kind offer to share your work.

0 Kudos
Petros_Mamales
Beginner
1,064 Views

Could it be possible that I would have to ignore one of the microsoft librray in order for libm to "pick" the right long double ?

I am thinking, maybe it is the sizeof from the ms crt that is somehow giving always 8 for long double (say was implemented as a template and this  is a specialization for pod-s ). And also, if I was to use a function, say exp (for an orinary double), from libm, why the linker would not complain that there is a required function found in two different input libraries ?

Does switching to the intel compiler tools take care of it ? Am I missing something/talking nonsense ?

0 Kudos
Bernard
Valued Contributor I
956 Views

>>>Again, thank you very much  for the kind offer to share your work.>>>

No problem.We are here to help each other.

0 Kudos
Reply