Why don't you just take a look at the assembler output from MS's compile of _control87() and then just inline that into your code for gcc? Perhaps too hacky?
alex
At 10:20 AM +0300 11/1/06, Rustam Muginov wrote:
>On Oct 31, 2006, at 10:08 PM, Guillaume POIRIER wrote:
>
>>Hi,
>>
>>On 10/31/06, Rustam Muginov <email@hidden> wrote:
>>>Thank you a lot, Guillaume
>>>
>>>Using the hint with _mm_getcsr/_mm_setcsr i got the application to
>>>raise SIGFPE signal for the SSE floating-point math.
>>>Now i only need to find the same way with 387 math
>>
>>As the doc I pasted you says, there is no way to disable denormar
>>handling on x87, therefore I doubt it's possible to generate a SIGFPE
>>in that case. If however you find a way to do it, please keep me
>>posted :)
>>
>
>As far as I understand, it is unable to make 387 to flush denormals to zero automatically like SSE or Altivec can do.
>The following source code (unfortunately, it is windows-specific) does break into debugger on denormal using 387 FPU:
>>int main ()
>>{
>>
>> _control87(_EM_INVALID, _MCW_EM);
>>
>> float f = 1.0f;
>> while( true )
>> {
>> f = f / 2.0f;
>> printf( "%g\n", f );
>>
>> if( f == 0 )
>> break;
>> }
>> return 0;
>>}
>
>So it looks like x387 architecture does allow some kind of exception to be raised then hitting denormal.
>Now I need to find a way to make it work under gcc on MacOS X and linux.
>
>
>--
>Sincerely,
> Rustam Muginov
>
>
>
>>Guillaume
>>
>>>--
>>>Sincerely,
>>> Rustam Muginov
>>>
>>>On Oct 31, 2006, at 6:59 PM, Guillaume Poirier wrote:
>>>
>>>> Hi,
>>>>
>>>> Rustam Muginov wrote:
>>>>> Hello, all.
>>>>> About a year ago I had asked a question about catching SIGFPE on
>>>>> PowerPC
>>>>> Macs and got help on it.
>>>>>
>>>>> Now i am trying to make MacOS X/86 app to raise SIGFPE on denormals,
>>>>> overflow e.t.c. but can not get application to raise signals.
>>>>> Searching ADC site and list archives but found nothing.
>>>>> For the Windows platform it could be done with
>>>>> _control87(_EM_INVALID, _MCW_EM);
>>>>> function, but this looks like MS/icc specific.
>>>>>
>>>>> Could anyone please help me to set CPU and FPU to raise SIGFPE signals
>>>>> using GCC if some conditions like underflow or overflow are met.
>>>>> preferably on both FPU and SSE?
>>>>> Thank you in advance.
>>>>
>>>> From this link:
>>>> http://developer.apple.com/documentation/Performance/Conceptual/
>>>> Accelerate_sse_migration/migration_sse_translation/
>>>> chapter_4_section_2.html
>>>>
>>>> "Setting and checking other bits in the MXCSR will allow you to take
>>>> an exception if you hit a denormal (DM) and check to see whether you
>>>> have previously hit a denormal (DE) in the vector unit, in addition to
>>>> the typical IEEE-754 exceptions and flags."
>>>>
>>>> "Denormals also cause large stalls on the x87 scalar floating point
>>>> unit. Simply loading and storing denormals in and out of the x87 unit
>>>> may cause a stall. The processor has to convert them to 80-bit
>>>> extended format and back during these operations. There is no way to
>>>> disable denormal handling on x87."
>>>>
>>>> This should also be usefull:
>>>> "To turn denormals off on AltiVec, set the Non-Java bit in the AltiVec
>>>> VSCR. To turn denormals off on SSE, turn on the Denormals Are Zero and
>>>> Flush to Zero (DAZ and FZ) bits in the MXCSR:
>>>>
>>>> #include <xmmintrin.h>
>>>>
>>>> int oldMXCSR = _mm_getcsr(); //read the old MXCSR setting
>>>> int newMXCSR = oldMXCSR | 0x8040; // set DAZ and FZ bits
>>>> _mm_setcsr( newMXCSR ); //write the new MXCSR setting to the MXCSR
>>>>
>>>> ... // do your work with denormals off here
>>>>
>>>> //restore old MXCSR settings to turn denormals back on if they
>>>> were on
>>>> _mm_setcsr( oldMXCSR );
>>>>
>>>> "
>>>>
>>>> from this link: http://developer.apple.com/hardwaredrivers/ve/sse.html
>>>>
>>>> Guillaume
>>>>
>>>
>>
>>
>>--
>>With DADVSI (http://en.wikipedia.org/wiki/DADVSI), France finally has
>>a lead on USA on selling out individuals right to corporations!
>>Vive la France!
>>
>
>_______________________________________________
>Do not post admin requests to the list. They will be ignored.
>PerfOptimization-dev mailing list (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>
>This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden