Click to See Complete Forum and Search --> : Ignoring FPU interrupts from the processor


gustav_a
November 8th, 2005, 09:05 AM
Hi
I am working on a C++ program that generates random machinecode instructions that is stored in an byte-array and then directly executed. The instructions are all FPU-instructions (Floating Point Unit), for example, fadd, fsub, fmul, etc. When the instructions have been executed I read the top value from the FPU-stack, this is my "output".
The problem is that since the instructions are created randomly they often result in illegal values, overflow, NANs, etc. I have masked all the exeptions in the FPU control word but these instructions still take a _very_ long time to handle.
So what I'm asking is if there is a way to tell the processor that it should completely ignore any illegal values in the FPU and just continue with the execution?

/Gustav

SuperKoko
November 8th, 2005, 09:35 AM
I don't understand exactly the purpose of ignoring those instructions.
There are mainly two attitudes to that problem:

Consider than an illegal value must stop the procedure.
In that case you must let the exceptions unmasked and use the signal function of the C standard library to handle the FPU exceptions and exit properly from the procedure.
Consider that it does not matter if NAN, +INF or another is produced as result.
In that case you mask all exceptions.

But i suppose that if an operation fails, ignoring it is not the correct solution, because we are sure that the final result will make no sense!

Perhaps i misunderstood the problem.

gustav_a
November 8th, 2005, 10:00 AM
The thing is that I randomly generate a lot of "programs" consisting of machinecode instructions that manipulates the FPU. These instructions are never illegal, it is only the results of the instructions that may be illegal (NAN, INF etc.). I don't care if I get any illegal values as result of an instruction, because the "programs" that produces illegal values will not be used later on.
My problem is that I want my program to run as fast as possible and each time I get an illegal value from an FPU operation, this operation takes very long time to handle, even though I have masked the exeption.

/Gustav