123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- Index: neo/idlib/math/Math.h
- ===================================================================
- --- neo/idlib/math/Math.h (revision 1760)
- +++ neo/idlib/math/Math.h (working copy)
- @@ -776,6 +776,21 @@
- m = ( i & ( ( 1 << IEEE_FLT_MANTISSA_BITS ) - 1 ) ) | ( 1 << IEEE_FLT_MANTISSA_BITS );
- shift = e - IEEE_FLT_MANTISSA_BITS;
- return ( ( ( ( m >> -shift ) | ( m << shift ) ) & ~( e >> 31 ) ) ^ s ) - s;
- +//#elif defined( MACOS_X )
- +#elif 0
- + double ret = __fctiw( f );
- + return *( reinterpret_cast<int *>( &ret ) + 1 );
- +//#elif defined( MACOS_X )
- +#elif 0
- + float c;
- + // c = __fsels( f, -0x1.0p+52, 0x1.0p+52 );
- + __asm__ ("fsel %0,%1,%2,%3"
- + /* outputs: */ : "=f" (c)
- + /* inputs: */ : "f" (f), "f" (-0x1.0p+52), "f" (0x1.0p+52));
- + float result = (f - c) + c;
- + if( f < result ) result -= 1.0;
- + int i = *reinterpret_cast<int *>( &f );
- + return ( i & ( ( 1 << IEEE_FLT_MANTISSA_BITS ) - 1 ) );
- #else
- return (int) f;
- #endif
- Index: neo/idlib/precompiled.h
- ===================================================================
- --- neo/idlib/precompiled.h (revision 1760)
- +++ neo/idlib/precompiled.h (working copy)
- @@ -47,6 +47,10 @@
-
- #endif /* _WIN32 */
-
- +#if defined( MACOS_X )
- +#include <ppc_intrinsics.h>
- +#endif
- +
- //-----------------------------------------------------
-
- #if !defined( _DEBUG ) && !defined( NDEBUG )
- Index: neo/TestSIMD/math/Math.h
- ===================================================================
- --- neo/TestSIMD/math/Math.h (revision 1760)
- +++ neo/TestSIMD/math/Math.h (working copy)
- @@ -143,6 +143,7 @@
- static float Rint( float f ); // returns the nearest integer
- static int Ftoi( float f ); // float to int conversion
- static int FtoiFast( float f ); // fast float to int conversion but rounds to nearest
- + static unsigned int FtouiFast( float f ); // fast float to unsigned int conversion
- static unsigned long Ftol( float f ); // float to long conversion
- static unsigned long FtolFast( float ); // fast float to long conversion but rounds to nearest
-
- @@ -673,11 +674,31 @@
- __asm fld f
- __asm fistp i
- return i;
- +//#elif defined( MACOS_X )
- +#elif 0
- + int i, s, e, m, shift;
- + i = *reinterpret_cast<int *>( &f );
- + s = i >> IEEE_FLT_SIGN_BIT;
- + e = ( ( i >> IEEE_FLT_MANTISSA_BITS ) & ( ( 1 << IEEE_FLT_EXPONENT_BITS ) - 1 ) ) - IEEE_FLT_EXPONENT_BIAS;
- + m = ( i & ( ( 1 << IEEE_FLT_MANTISSA_BITS ) - 1 ) ) | ( 1 << IEEE_FLT_MANTISSA_BITS );
- + shift = e - IEEE_FLT_MANTISSA_BITS;
- + return ( ( ( ( m >> -shift ) | ( m << shift ) ) & ~( e >> 31 ) ) ^ s ) - s;
- #else
- return (int) f;
- #endif
- }
-
- +ID_INLINE unsigned int idMath::FtouiFast( float f ) {
- +#ifdef _WIN32
- + int i;
- + __asm fld f
- + __asm fistp i
- + return i;
- +#else
- + return (unsigned int) f;
- +#endif
- +}
- +
- ID_INLINE unsigned long idMath::Ftol( float f ) {
- return (unsigned long) f;
- }
- Index: neo/TestSIMD/math/Simd.cpp
- ===================================================================
- --- neo/TestSIMD/math/Simd.cpp (revision 1760)
- +++ neo/TestSIMD/math/Simd.cpp (working copy)
- @@ -3886,6 +3886,35 @@
- GetBest( start, end, bestClocks );
- }
- PrintClocks( " idAngles::ToMat3()", 1, bestClocks );
- +
- + int j;
- + int tmp;
- +
- + bestClocks = 0;
- + tst = rnd.CRandomFloat() * 5000.0f;
- + for ( i = 0; i < NUMTESTS; i++ ) {
- + StartRecordTime( start );
- + for ( j = 0; j < NUMTESTS; j++ ) {
- + tmp = idMath::FtoiFast( tst );
- + }
- + StopRecordTime( end );
- + GetBest( start, end, bestClocks );
- + tst = rnd.CRandomFloat() * 5000.0f;
- + }
- + PrintClocks( " idMath::FtoiFast()", NUMTESTS, bestClocks );
- +
- + bestClocks = 0;
- + tst = rnd.CRandomFloat() * 5000.0f + 5000.0f;
- + for ( i = 0; i < NUMTESTS; i++ ) {
- + StartRecordTime( start );
- + for ( j = 0; j < NUMTESTS; j++ ) {
- + tmp = idMath::FtouiFast( tst );
- + }
- + StopRecordTime( end );
- + GetBest( start, end, bestClocks );
- + tst = rnd.CRandomFloat() * 5000.0f + 5000.0f;
- + }
- + PrintClocks( " idMath::FtouiFast()", NUMTESTS, bestClocks );
- }
-
- /*
- @@ -3903,7 +3932,7 @@
- p_generic = generic;
-
-
- -#if 0
- +#if 1
- //patrick : running timing test
- TIME_TYPE s1,s2, best;
- best = 0;
- @@ -3967,8 +3996,9 @@
- idLib::common->Printf( "using %s for SIMD processing\n", p_simd->GetName() );
-
- GetBaseClocks();
- -#if 1
- TestMath();
- +#if 0
- + TestMath();
- TestAdd();
- TestSub();
- TestMul();
|