diff -r 000000000000 -r a41df078684a kerneltest/f32test/bench/t_whet.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/f32test/bench/t_whet.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,453 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// f32test\bench\t_whet.cpp +// Whetstone Benchmarks +// +// + + +#include +#include +#include +#include +#include +#include +#include +#include "../server/t_server.h" + +const TInt KSections=9; + +LOCAL_D TReal64 loop_time[KSections]; +LOCAL_D TReal64 loop_mops[KSections]; +LOCAL_D TReal64 loop_mflops[KSections]; +LOCAL_D TReal64 TimeUsed; +LOCAL_D TReal64 mwips; +LOCAL_D TBufC<50> headings[KSections]; +LOCAL_D TReal64 Check; +LOCAL_D TReal64 results[KSections]; + +LOCAL_D TBuf<0x100> buf; +LOCAL_D TBuf8<0x100> buf8; +LOCAL_D const TFileName pathName = _L("C:\\E32-MATH\\"); +#ifdef T_WHET_WITH_VFP +LOCAL_D const TFileName fileName = _L("WHETVFP.RES"); +#else +LOCAL_D const TFileName fileName = _L("WHET.RES"); +#endif +LOCAL_D RFile outfile; + +#ifdef T_WHET_WITH_VFP +GLDEF_D RTest test(_L("TReal64 C/C++ Whetstone Benchmark with VFP")); +#else +GLDEF_D RTest test(_L("TReal64 C/C++ Whetstone Benchmark")); +#endif + +LOCAL_C void appendString(const TDesC& aString) + { + + buf=_L(""); + buf.AppendFormat(_L("%S\n"),&aString); + buf8.Copy(buf); // Unicode + outfile.Write(buf8); + } + +LOCAL_C void pa(TReal64* e,TReal64 t,TReal64 t2) + { + + TInt j; + for (j=0;j<6;j++) + { + e[0]=(e[0]+e[1]+e[2]-e[3])*t; + e[1]=(e[0]+e[1]-e[2]+e[3])*t; + e[2]=(e[0]-e[1]+e[2]+e[3])*t; + e[3]=(-e[0]+e[1]+e[2]+e[3])/t2; + } + } + +LOCAL_C void po(TReal64* e1,TInt j,TInt k,TInt l) + { + + e1[j]=e1[k]; + e1[k]=e1[l]; + e1[l]=e1[j]; + } + +LOCAL_C void p3(TReal64 *x,TReal64 *y,TReal64 *z,TReal64 t,TReal64 t1,TReal64 t2) + { + + *x=*y; + *y=*z; + *x=t*(*x+*y); + *y=t1*(*x+*y); + *z=(*x+*y)/t2; + } + +LOCAL_C void pout(const TDesC& aTitle,TReal64 aOps,TInt aType,TReal64 aChecknum,TReal64 aTime, + TInt aCalibrate,TInt aSection) + { + + TReal64 mops,mflops; + + Check+=aChecknum; + loop_time[aSection]=aTime; + headings[aSection]=aTitle; + TimeUsed+=aTime; + + if (aCalibrate==1) + results[aSection]=aChecknum; + + if (aCalibrate==0) + { + test.Printf(_L("%- 20S%- 18g"),&headings[aSection],results[aSection]); + + if (aType==1) + { + if (aTime>0) + mflops=aOps/(1E+6*aTime); + else + mflops=0.0; + + loop_mops[aSection]=99999.0; + loop_mflops[aSection]=mflops; + test.Printf(_L("%- 34g%- 7g\n"),loop_mflops[aSection],loop_time[aSection]); + } + else + { + if (aTime>0) + mops=aOps/(1E+6*aTime); + else + mops=0.0; + + loop_mops[aSection]=mops; + loop_mflops[aSection]=0.0; + test.Printf(_L(" %- 17g%- 7g\n"),loop_mops[aSection],loop_time[aSection]); + } + } + } + +LOCAL_C void whetstones(TInt xtra,TInt x100,TInt calibrate) + { + + TTime timea,timeb; + TReal64 t=0.49999975; + const TReal64 t0=t; + + TReal64 t1=0.50000025; + TReal64 t2=2.0; + + Check=0.0; + + TInt n1,n2,n3,n4,n5,n6,n7,n8,n1mult; + n1 = 12*x100; + n2 = 14*x100; + n3 = 345*x100; + n4 = 210*x100; + n5 = 32*x100; + n6 = 899*x100; + n7 = 616*x100; + n8 = 93*x100; + n1mult = 10; + + // Section 1, Array elements + TReal64 e1[] = + {1.0,-1.0,-1.0,-1.0}; + TInt i,ix; + + timea.HomeTime(); + for (ix=0; ix2) + j = 0; + else + j = 1; + if(j<1) + j = 1; + else + j = 0; + } + } + timeb.HomeTime(); + time=I64REAL(timeb.Int64()-timea.Int64())/1E+6; + + pout(_L("N3 if then else "),TReal64(n3*3)*TReal64(xtra),2,TReal64(j),time,calibrate,3); + + // Section 4, Integer arithmetic + j=1; + TInt k=2; + TInt l=3; + + timea.HomeTime(); + for (ix=0; ix0) + { + TimeUsed=0; + whetstones(xtra,x100,calibrate); + + test.Printf(_L("%g Seconds %d Passes (x 100)\n"),TimeUsed,xtra); + calibrate++; + count--; + + if (TimeUsed>2) + count=0; + else + xtra*=5; + } + + if (TimeUsed>0) + { + TRealX TimeX(TimeUsed); + TInt TimeInt=TInt(TimeX); + xtra*=duration/TimeInt; + } + if (xtra<1) + xtra=1; + + calibrate=0; + + test.Printf(_L("\nUse %d passes (x 100)\n"),xtra); + + test.Printf(_L("\nTReal64 C/C++ Whetstone Benchmark\n")); + test.Printf(_L("\nLoop content Result MFLOPS MOPS Seconds\n\n")); + + TimeUsed=0; + whetstones(xtra,x100,calibrate); + + test.Printf(_L("\nMWIPS ")); + if (TimeUsed>0) + mwips=(TReal64)(xtra*x100)/(10.0*TimeUsed); + else + mwips=0; + + test.Printf(_L("%- 17g %- 7g\n\n"),mwips,TimeUsed); + + if (Check==TReal64(0.0)) + test.Printf(_L("Wrong answer ")); + + // Add results to output file whets.res + appendString(_L("Whetstone TReal64 Benchmark in C/C++\n")); + appendString(_L("\n\n")); + appendString(_L("Loop content Result MFLOPS MOPS Seconds\n\n")); + + for (section=1; section