Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEEE exception #57

Closed
dpo opened this issue Jun 21, 2015 · 9 comments
Closed

IEEE exception #57

dpo opened this issue Jun 21, 2015 · 9 comments

Comments

@dpo
Copy link
Contributor

dpo commented Jun 21, 2015

Is there a way to compile the ASL so IEEE exceptions return Inf or NaN instead of producing an error? On some Linux machines, IEEE exceptions results in an error message such as "Error while evaluating
objective.", while on OSX, they seem to simply return Inf or NaN.

Thanks.

@vitaut
Copy link
Contributor

vitaut commented Jun 22, 2015

ASL disables IEEE exceptions unless ASL_FPINIT_KEEP_TRAPBITS is defined:

mp/src/asl/solvers/fpinit.c

Lines 130 to 137 in 446d112

#if defined(_FPU_IEEE) && defined(_FPU_EXTENDED) && defined(_FPU_DOUBLE)
__fpu_control = _FPU_IEEE - _FPU_EXTENDED + _FPU_DOUBLE;
_FPU_SETCW(__fpu_control);
#elif defined(__i386__) || defined(__x86_64__)
__fpu_control = 0x27f;
_FPU_SETCW(__fpu_control);
#elif defined(FE_ALL_EXCEPT)
fedisableexcept(FE_ALL_EXCEPT);

However, the "Error while evaluating objective" is usually reported when a math function returns an error via errno and not because of IEEE exceptions:

if (errchk(rv))

I'm not sure if you can disable this, but you can handle errors yourself via asl->i.err_jmp_.

@dpo
Copy link
Contributor Author

dpo commented Jul 14, 2015

Sorry for the slow reply. I'm observing an erroneous function and gradient values on Linux, but they're ok on OSX. Technically, the evaluation should produce an IEEE error and return +inf. On Linux, I get zero instead.

I'm trying to determine whether the issue comes from ASL or the fact that on Linux, ASL is compiled with gcc (on OSX I use clang by default). When I try to build with gcc 4.9 on OSX, I get the error message

mp-2.0.1/src/os.cc:76:12: error: 'strlen' is not a member of 'std'
     size = std::strlen(&buffer[0]);
            ^

I added #include <cstring> in os.cc and everything compiles, but I get a test failure:

The following tests FAILED:
     14 - os-test (Failed)
Errors while running CTest

I invoke cmake with -DBUILD_SHARED_LIBS=True -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9.

Any ideas?

@vitaut
Copy link
Contributor

vitaut commented Jul 14, 2015

What version do you use? The strlen error should be fixed already :

mp/src/os.cc

Line 29 in 51ae35d

#include <cstring> // for std::strlen
.

Could you post the test log Testing/Temporary/LastTest.log that can be found in the build directory?

@dpo
Copy link
Contributor Author

dpo commented Jul 14, 2015

I use version 2.0.1. Somehow the #include <cstring> isn't there. I'll try a fresh download.

Here's the test log: https://gist.github.com/f8b120d6bc81cb273f5a

EDIT: I confirm that os.cc doesn't have a #include <cstring> in release 2.0.1.

@vitaut
Copy link
Contributor

vitaut commented Jul 15, 2015

I meant it is fixed in the master branch. I can release a minor release with a fix, but let's try to address other issues first.

Strangely I couldn't reproduce the os-test failure on my OS X systems. Could you by any chance post the output of CMake run on a clean mp repo? This could give more info about your setup for me to reproduce the issue.

@mlubin
Copy link

mlubin commented Jul 15, 2015

I just tested with ampl/mp master and the erroneous function value issue isn't resolved on linux.

@mlubin
Copy link

mlubin commented Jul 15, 2015

No apparent difference when compiling with -DASL_FPINIT_KEEP_TRAPBITS.

@vitaut
Copy link
Contributor

vitaut commented Jul 24, 2015

To clean things up a bit here I've moved the os-test failure to a separate issue (#61) and prepared a corrective release 2.0.2 that fixes the compilation error on OS X.

Regarding the main issue, as I mentioned in #59 (comment), ASL has macro WANT_INFNAN which enables Infinity & NaN propagation. However it only works with some operations at the moment.

@vitaut
Copy link
Contributor

vitaut commented Aug 18, 2015

@dpo I'm closing this issue since it is possible to enable Infinity propagation at least for some operations with WANT_INFNAN, but feel free to reopen if you want some specific operation, which currently doesn't handle WANT_INFNAN, to handle it.

@vitaut vitaut closed this as completed Aug 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants