Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Changing floating point state (Was: double vs float performance)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing floating point state (Was: double vs float performance)




On Jun 11, 2007, at 12:30 PM, Ian Ollmann wrote:

We request that you use fesetenv( FE_DFL_DISABLE_SSE_DENORMS_ENV ) to turn on FTZ mode...

We have a bug. We're going to try to get this fixed, but in the mean time (for the Tiger time frame), here is the workaround:


#include <fenv.h>
#include <stdint.h>
#pragma STDC FENV_ACCESS ON

#if defined( __SSE__ )
	#include <xmmintrin.h>
#endif

	static void 		TurnOffDenornmals( void )
	{
#if defined( __i386__ ) || defined( __x86_64__ )
		fesetenv( FE_DFL_DISABLE_SSE_DENORMS_ENV );

#if defined( __SSE__ )
//make sure that worked
uint32_t mxcsr = _mm_getcsr();
if( 0x8040 != (mxcsr & 0x8040) )
_mm_setcsr( mxcsr | 0x8040 ); //set 0x40 bit only on P4 or later
#endif
#else
//for PowerPC denormals are already off by default in AltiVec.
//The scalar units can be turned off by setting the non-IEEE bit in the fpscr,
// but there isn't a very large performance win for doing that so we don't bother.
#endif
}


The problem is that fesetenv on only allows you to change IEEE-754 masks, flags and rounding modes. The fix will be to allow you to access everything.

Ian
_______________________________________________
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


References: 
 >double vs float performance (From: Jonathan Taylor <email@hidden>)
 >Re: double vs float performance (From: Paul Russell <email@hidden>)
 >Re: double vs float performance (From: Jonathan Taylor <email@hidden>)
 >Re: double vs float performance (From: "Guillaume POIRIER" <email@hidden>)
 >Changing floating point state (Was: double vs float performance) (From: Ian Ollmann <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.