[Mono-dev] Floating point on arm

FALE(Leopold Faschalek) FALE at skidata.com
Fri Oct 14 09:48:23 EDT 2005


Hi,

I wrote a simple benchmark to test my mono arm (v1.1.9.2)
and got wrong results for float and double values

under windows I got following:
D:\test\nbench\nbench\bin\Debug>nbench.exe 1
int loop 00:00:00 1 7
float loop 00:00:00 1 0,0001
double loop 00:00:00 1 1E-07

under linux I got:
/var # mono nbench.exe 1
int loop 00:00:00.2826320 1 7
float loop 00:00:00.0003050 1 -2.681562E+154
double loop 00:00:00.0002740 1 -6.9127818972463E-180

<source>
using System;

namespace nbench
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: Add code to start application here
			//
			int i;
			int count = 1000000;
			DateTime startTime;
			DateTime endTime;
			if (args.Length > 0)
				count = Int32.Parse(args[0]);
			int a = 3;
			int b = 7;
			int s = 0;
			startTime = DateTime.Now;
			for (i=0; i<count; i++)
			{
				s = s * a + b;
			}
			endTime = DateTime.Now;
			System.Console.WriteLine("int loop {0} {1} {2}",endTime-startTime,count,s);

			float fa = 1.0001F;
			float fb = 0.0001F;
			float fs = 0;
			startTime = DateTime.Now;
			for (i=0; i<count; i++)
			{
				fs = fs * fa + fb;
			}
			endTime = DateTime.Now;
			System.Console.WriteLine("float loop {0} {1} {2}",endTime-startTime,count,fs);

			double da = 1.0000001;
			double db = 0.0000001;
			double ds = 0;
			startTime = DateTime.Now;
			for (i=0; i<count; i++)
			{
				ds = ds * da + db;
			}
			endTime = DateTime.Now;
			System.Console.WriteLine("double loop {0} {1} {2}",endTime-startTime,count,ds);
		}
	}
}
</source>
the mono build system is linux 2.4.21-99 SUSE with scratchbox 1.0.1 and the target system is
Arm9tdmi (v4t) little endian with linux 2.4.27 and mono 1.1.9.2
I compiled mono with 'make -k CFLAGS=-g' according to lupus, but saw also the -O2 option is set

Any idea what went wrong?

PS: the timings for 10^8 loops int computation are:
.NET 1.1	P4 	2.6GHz/5200BogoMips	0,62 	seconds
Mono		ARM9 	180MHz/89,7BogoMips	9,2	seconds
Mono		P3	500MHz/985 BogoMips	2,2	seconds

greetings
Leopold Faschalek
-------------------------
Research & Development / Senior Software Developer

SKIDATA AG
Untersbergstraße 40
A-5083 Gartenau
[P] +43(0)6246/888-0
[F] +43(0)6246/888-7
[e] fale at skidata.com
[w] www.skidata.com







More information about the Mono-devel-list mailing list