CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Posts
    11

    Ignoring FPU interrupts from the processor

    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

  2. #2
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: Ignoring FPU interrupts from the processor

    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.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  3. #3
    Join Date
    Nov 2005
    Posts
    11

    Re: Ignoring FPU interrupts from the processor

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured