Community
cancel
Showing results for 
Search instead for 
Did you mean: 
darkfate
Beginner
134 Views

Long double problems.

Hello
I have some problems to configure my Visual Studio with the Intel Compiler for long double calculations.

My Command Settings is as follows:

"ippvm.lib ippvc.lib ippsr.lib ippsc.lib ippr.lib ippm.lib ippj.lib ippgen.lib ippdi.lib ippcv.lib ippch.lib ippcc.lib ippac.lib ippdc.lib ippi.lib ipps.lib ippcore.lib mkl_solver.lib mkl_intel_c_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /OUT:"D:\Documents\Programming\MS Visual Studio C\drixlerpatch\Release\drixlerpatch.exe" /INCREMENTAL:NO /nologo /LIBPATH:"C:\Program Files (x86)\Intel\Compiler\11.1\048\ipp\ia32\stublib" /LIBPATH:"C:\Program Files (x86)\Intel\Compiler\11.1\048\IPP\ia32\stublib" /LIBPATH:"C:\Program Files (x86)\Intel\Compiler\11.1\048\TBB\ia32\vc9\Lib" /LIBPATH:"C:\Program Files (x86)\Intel\Compiler\11.1\048\MKL\ia32\Lib" /MANIFEST /MANIFESTFILE:"Release\drixlerpatch.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /TLBID:1 /SUBSYSTEM:CONSOLE /LARGEADDRESSAWARE /OPT:REF /OPT:ICF /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:\Documents\Programming\MS Visual Studio C\drixlerpatch\Release\drixlerpatch.lib" /MACHINE:X86"

Now i try to assign a variable like:
h2 = 1.+1.7320508075688772935274463415058723669428052538103806280558*I;

In the Output i have following:-1.005971849226870800000000000000000 + 68.010756181572788000000000000000000i
Can anybody help to find me the mistake.

I am very very new user of intel compiler. this program has no functions (only linear calculating).

What can i do better?

Thank you!





0 Kudos
5 Replies
TimP
Black Belt
134 Views

Visual Studio expects long double to be the same as double, and a compatible .exe initializes x87 precision mode accordingly, so the library has no printf() formatting for long double. Look up the ICL options /Qlong-double /Qpc80 and . These change VS compatible defaults so as to give you limited support of 80-bit long double, but not where you depend on the Visual Studio libraries. The options must be set for compilation of main() as well as any functions where you expect to use long double. You might consider whether you also want /arch:ia32 so as to enable faster mixed double/long double, or /arch:SSE2 so as to optimize float-only and double-only expressions.
darkfate
Beginner
134 Views

Quoting - tim18
Visual Studio expects long double to be the same as double, and a compatible .exe initializes x87 precision mode accordingly, so the library has no printf() formatting for long double. Look up the ICL options /Qlong-double /Qpc80 and . These change VS compatible defaults so as to give you limited support of 80-bit long double, but not where you depend on the Visual Studio libraries. The options must be set for compilation of main() as well as any functions where you expect to use long double. You might consider whether you also want /arch:ia32 so as to enable faster mixed double/long double, or /arch:SSE2 so as to optimize float-only and double-only expressions.


Thank you for your answer. I found a problem in my recent post. My compiler commands are:

/c /O3 /Og /Ob2 /Oi /Ot /Qip /GA /I "C:Program Files (x86)IntelCompiler11.1�48IPPia32Include" /I "C:Program Files (x86)IntelCompiler11.1�48TBBInclude" /I "C:Program Files (x86)IntelCompiler11.1�48MKLInclude" /I "C:Program Files (x86)IntelCompiler11.1�48MKLIncludefftw" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "TBB_USE_THREADING_TOOLS" /D "_UNICODE" /D "UNICODE" /MD /GS /Gy /arch:SSE3 /fp:fast=2 /Fo"Release/" /W3 /nologo /Wp64 /QaxSSE4.2 /QxHost /Qparallel /Quse-intel-optimized-headers /fp:extended /Qstd=c99

Do i understand right that i have to add the "/Qlong-double /Qpc80" to the command line and remove /arch:ia32 and /arch:SSE2 ?

I dont include any "math.h" so i dont need the "mathimf.h" right? I only use pow(),sqrt,cpow() and csqrt()
What about the complex.h does it calculate long doubles?

How do i decide which flag is the best one for me? i have a linear calculating code like:

n1 = creal(h1 + d/(3*h7) - (h4*h7)/(3*d));
n2 = creal(h11 + h2*h9);
n3 = creal(h11 + h3*h9);

ew = (n1>n2) ? ((n1>n3) ? n1 : n3) : ((n2>n3) ? n2 : n3);

h8 = -n02*n12 + n01*(n22 - ew);
h9 = n01*n12 + n02*(ew - n11);

TimP
Black Belt
134 Views

Yes, you need for your math functions. Look in there to see if there's any indication about long double complex. Replace all the /Qx and /Qax options with one, either /arch:ia32 or /QxSSE4.2, along with /Qlong-double /Qpc80. Leave IPO et al. until you've succeeded with less ambitious stuff. Likewise, why not start with /fp:source until you have a chance to take risks one at a time? If you're trying to use 80-bit long double, surely you don't need aggressive optimizations elsewhere.
darkfate
Beginner
134 Views

Quoting - darkfate
...

I added "/Qlong-double /Qpc80" to the command line. Now the calculation fails. While reading the file i get something i cant understand.

My coordinate (ASCII) file looks like:

11.146747 10.827060 -0.002419
11.190383 10.873155 -0.245195
11.107672 10.960262 -0.245166
11.081999 11.002660 -0.282117
............... ............... ..............

The code which reads the file is:
-------------------------------------
#include
#include
#include
#include

int main()
{

FILE *stream;

long double t,x,y,z,sumx,sumy,sumz,meanx,meany,meanz,n00,n11,n22,n01,n02,n12;

fopen_s( &stream, "c:\ebene.xyz", "r" );


if ( stream == NULL ) return 1;

long double arrx[n+1], arry[n+1], arrz[n+1] (at this time i already know n)

while ( 0 == feof (stream) )
{
if ( 3 != fscanf_s( stream, "%lf %lf %lfn", &x, &y, &z ) )return 2;
else
{
arrx = x;
arry = y;
arrz = z;

sumx += x;
sumy += y;
sumz += z;

i++;
}
-------------------------------
For the first time and the first row of the coordinate file i get:
x =1815843453
y =1753721046
z =3161645686

Whats wrong with the code and why it works for simple double mode without the "/Qlong-double /Qpc80"
TimP
Black Belt
134 Views

Yes, you might get away with technical incorrectness in standard Microsoft mode where long double and double are identical. Now you've told the library to ignore the difference between long double and double, but forced there to be a difference, in spite of knowing that the library couldn't handle it even if you told it the truth.
Reply