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

Mac ICPC 12.0.1 floating point exception

Bradley_Lowekamp
Beginner
697 Views
Hello,
I was just trying to upgrade to 12.0.1 and I am running into significant issues! I am running OSX 10.6.5, XCode 3.2.4, and ICPC...
Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.1.122 Build 20101110
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
I was able to narrow down the first issue to the following code:
int main(void )
{
const unsigned int VPointDimension = 3;
double center[3] = {1.0, 1.0, 1.0};
double radius[3];
unsigned int j = 0;
double pnt[3];
for ( unsigned int i = 0; i < VPointDimension; i++ )
{
pnt = center + pow( -1.0, ( (double)( j / ( int( pow(2.0, (double)i) ) ) ) ) ) * radius;
}
std::cout << pnt[0] << " " << pnt[1] << " " << pnt[2] << std::endl;
return 0;
}
compelled simply with "icpc -O3 bug.cxx" or "icpc -O2 bug.cxx"
Output when run:
$ ./a.out
Floating point exception
It work fine with just "-O"
Thanks for help!
0 Kudos
5 Replies
Quoc-An_L_Intel
Moderator
697 Views

I have file a Premier Support issue for this problem. For your reference, it's DPD200164002. I will update this thread once we have a resolution.

0 Kudos
Bradley_Lowekamp
Beginner
697 Views
The other issue I am having a appears to be related to C linking, or library generation. Both from C and C++.
I am trying to build our open source toolkit ITK (http://www.itk.org/ ), repository (git://itk.org/ITK.git) and it's supported and tested across a large number of platforms (http://www.cdash.org/CDash/index.php?project=Insight ).
Some test are just hanging and they are the ones that are utilize certain methods it the netlib library. For example setulb_ here:
I am unable to narrow this down to a small example right now. This is deep under a few layers, down to some old Fortran to C code. It has always just worked. It work fine with out optimization, but with -O2 or -O3 it executes forever.
Any thought on the best way to get this tracked down?
Thanks,
Brad
0 Kudos
Quoc-An_L_Intel
Moderator
697 Views

I don't know if this is a real bug or a floating point issue. For example thecutdown test case in the original thread posting result in a Floating point exception at -O3, -O2. However,if you add the option

-fp-model precise

You will not get the error. You might want to take a look at the documentation on -fp-model and try them.

$ cat test.cpp
#include
#include

int main(void )
{
const unsigned int VPointDimension = 3;
double center[3] = {1.0, 1.0, 1.0};
double radius[3];
unsigned int j = 0;
double pnt[3];
for ( unsigned int i = 0; i < VPointDimension; i++ )
{
pnt = center + pow( -1.0, ( (double)( j / ( int( pow(2.0, (double)i) ) ) ) ) ) * radius;
}

std::cout << pnt[0] << " " << pnt[1] << " " << pnt[2] << std::endl;
return 0;
}

$ icpc -O3 test.cpp; ./a.out
Floating point exception

$ icpc -O3 -fp-model precise test.cpp; ./a.out
1 1 1

0 Kudos
Bradley_Lowekamp
Beginner
697 Views
I am rebuilding things now...
The for loop is required so I thought is was a vectorization issue. Either way I don't understand how precision issues here could result in a numerical exception. I'll see what I can figure out from -fp-model...
0 Kudos
Bradley_Lowekamp
Beginner
697 Views
Thank you,
Adding the "-fp-model precise" made all my tests pass.
I still would like a better understanding of this issue. I was previously using the 89 release of the compiler and I didn't need this flag. Did the default value change between version?
I really don't understand why an exception was generated, an explanation would be appreciated.
Thank you again!
Brad
0 Kudos
Reply