[Mono-dev] Arm9 NS9215 floating point troubles

2010-06-17 Thread Trevor Ackerman
I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu 
afaik) and I'm having trouble with floats when executing code.

I 
thought I had correctly specified soft-float and indeed mono tells me so

~
 # /usr/local/bin/mono -V
Mono JIT compiler version 2.6.4 (tarball 
Wed Jun 16 14:55:33 MDT 2010)
Copyright (C) 2002-2010 Novell, Inc and
 Contributors. www.mono-project.com
   
 TLS:   normal
    GC:    Included Boehm (with 
typed GC and Parallel Mark)
    SIGSEGV:   normal
    
Notifications:
 epoll
    Architecture:  arm,soft-float
    
Disabled:  none
~ # 

However the following code produces 
grossly wrong results

using System;

public class FloatTest
{
   
 static public void Main()
    {
    
Console.WriteLine("0.0f literal is " + 0.0f);
    
Console.WriteLine("1.0f literal is " + 1.0f);
    
Console.WriteLine("12.3f literal is " + 12.3f);
    
Console.WriteLine("32f
 literal is " + 32f);
    Console.WriteLine("1024f 
literal is " + 1024f);
    Console.WriteLine("32768f 
literal is " + 32768f);
    }
}

Here are the results

~
 # /usr/local/bin/mono FloatTest.exe
0.0f literal is 0
1.0f 
literal is 5.299809E-315
12.3f literal is -1.491669E-154
32f 
literal is 5.325712E-315
1024f literal is 5.351615E-315
32768f 
literal is 5.377519E-315

my configure command is
./configure 
--host=arm-linux --with-tls=pthread --with-moonlight=no 
--with-mcs-docs=no

summary from running config is

    
mcs source:    $(top_srcdir)/mcs
    olive source: 
 

    GC:    included
    GLIB:  
system
    TLS:   pthread
    SIGALTSTACK:   yes
   
 Engine:    Building and using the JIT
    2.0 Profile:   yes
   
 Moon Profile:  no
    4.0 Alpha: no
    
MonoTouch: no
    JNI support:   IKVM
 Native
    libgdiplus:    assumed to be installed
    
zlib:  system zlib
    oprofile:  no
    
BigArrays: no
    DTrace:    no
    Parallel Mark:
 yes
    LLVM Back End: no

My CFLAGS and CPPFLAGS environment variables are
 both
-DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1

Any insight 
would be greatly appreciated, I've looked at some of the code in the 
mono/mini directory but cannot make sense of how float values are 
getting generated.

TIA


  ___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-17 Thread Robert Jordan
On 17.06.2010 18:07, Trevor Ackerman wrote:
> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
> afaik) and I'm having trouble with floats when executing code.

...

> My CFLAGS and CPPFLAGS environment variables are
>   both
> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1

-DNO_UNALIGNED_ACCESS is probably needed as well.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-17 Thread Trevor Ackerman
Good suggestion but that did not change the results.

--- On Thu, 6/17/10, Robert Jordan  wrote:

From: Robert Jordan 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list@lists.ximian.com
Date: Thursday, June 17, 2010, 10:53 AM

On 17.06.2010 18:07, Trevor Ackerman wrote:
> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
> afaik) and I'm having trouble with floats when executing code.

...

> My CFLAGS and CPPFLAGS environment variables are
>   both
> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1

-DNO_UNALIGNED_ACCESS is probably needed as well.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



  ___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-17 Thread Geoff Norton
Trevor,

 I tested your testcase on a:

Processor   : ARMv7 Processor rev 0 (v7l)
Features: swp half thumb fastmult vfp edsp thumbee vfpv3 vfpv3d16 

I tested:

Mono JIT compiler version 2.4.2.3 (Debian 2.4.2.3+dfsg-2)
Architecture:  armel,soft-float

Mono JIT compiler version 2.7 (/trunk/mono r158961 Tue Jun 15 17:26:35 EDT 2010)
Architecture:  armel,vfp

Mono JIT compiler version 2.7 (/trunk/mono r158961 Thu Jun 17 13:58:00 EDT 2010)
Architecture:  armel,soft-float

and all 3 produce the correct results.  I dont have a 2.6.4 build handy, but 
nothing really significant in this regard has changed.  Could you try trunk?  
It might be something else with your board as well.

-g


On 2010-06-17, at 12:07 PM, Trevor Ackerman wrote:

> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu afaik) 
> and I'm having trouble with floats when executing code.
> 
> I thought I had correctly specified soft-float and indeed mono tells me so
> 
> ~ # /usr/local/bin/mono -V
> Mono JIT compiler version 2.6.4 (tarball Wed Jun 16 14:55:33 MDT 2010)
> Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com
> TLS:   normal
> GC:Included Boehm (with typed GC and Parallel Mark)
> SIGSEGV:   normal
> Notifications: epoll
> Architecture:  arm,soft-float
> Disabled:  none
> ~ # 
> 
> However the following code produces grossly wrong results
> 
> using System;
> 
> public class FloatTest
> {
> static public void Main()
> {
> Console.WriteLine("0.0f literal is " + 0.0f);
> Console.WriteLine("1.0f literal is " + 1.0f);
> Console.WriteLine("12.3f literal is " + 12.3f);
> Console.WriteLine("32f literal is " + 32f);
> Console.WriteLine("1024f literal is " + 1024f);
> Console.WriteLine("32768f literal is " + 32768f);
> }
> }
> 
> Here are the results
> 
> ~ # /usr/local/bin/mono FloatTest.exe
> 0.0f literal is 0
> 1.0f literal is 5.299809E-315
> 12.3f literal is -1.491669E-154
> 32f literal is 5.325712E-315
> 1024f literal is 5.351615E-315
> 32768f literal is 5.377519E-315
> 
> my configure command is
> ./configure --host=arm-linux --with-tls=pthread --with-moonlight=no 
> --with-mcs-docs=no
> 
> summary from running config is
> 
> mcs source:$(top_srcdir)/mcs
> olive source:  
> 
> GC:included
> GLIB:  system
> TLS:   pthread
> SIGALTSTACK:   yes
> Engine:Building and using the JIT
> 2.0 Profile:   yes
> Moon Profile:  no
> 4.0 Alpha: no
> MonoTouch: no
> JNI support:   IKVM Native
> libgdiplus:assumed to be installed
> zlib:  system zlib
> oprofile:  no
> BigArrays: no
> DTrace:no
> Parallel Mark: yes
> LLVM Back End: no
> 
> My CFLAGS and CPPFLAGS environment variables are both
> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1
> 
> Any insight would be greatly appreciated, I've looked at some of the code in 
> the mono/mini directory but cannot make sense of how float values are getting 
> generated.
> 
> TIA
> 
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-17 Thread Trevor Ackerman
I have more to report.

I wrote a quick native C program to print out the bytes of a float and double 
variable that were assigned the literal value 1.0f. 

Then in the mono 2.6.4 routine mono_method_to_ir in source code file 
mono/mini/method_to_ir.c I dumped out the bytes of ip (instruction pointer) 
used for the double value in the case for CEE_LDC_R8.

I discovered that the bytes in the double value used on mono had the high and 
low 32 bits swapped compared to those produced by the native C program. I 
hacked the routine decompose_soft_float to swap the high and low words and now 
I have no troubles and the basic-float regression test passes 100%.

Although this happens to work, I have a hard time believing that this is the 
correct solution to my problem. I feel that others are probably using ARM9 
without
 floating point issues and that I am probably missing something in how I built 
mono for my platform. If anyone can shed some light on what I did wrong with 
building mono that'd be great. Of course if this is the correct action to take 
please let me know that too and how I may contribute the change back to the 
trunk (assuming that the trunk doesn't work which I haven't had time to test 
yet).

In the meantime here's my hack to decompose_soft_float in method-to-ir.c


 5073 case OP_R8CONST: {
 5074 unsigned char *ucp = (unsigned char *) ins->inst_p0;
 5075 unsigned char rawval[8];
 5076 printf("decompose_soft_float OP_R8CONST\n");
 5077 rawval[0] =
 ucp[4];
 5078 rawval[1] = ucp[5];
 5079 rawval[2] = ucp[6];
 5080 rawval[3] = ucp[7];
 5081 rawval[4] = ucp[0];
 5082 rawval[5] = ucp[1];
 5083 rawval[6] = ucp[2];
 5084 rawval[7] = ucp[3];
 5085 DVal d;
 5086
 //  d.vald = *(double*)ins->inst_p0;
 5087 d.vald = *(double*)rawval;
 5088 MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
 5089 break;
 5090 }

--- On Thu, 6/17/10, Trevor Ackerman  wrote:

From: Trevor Ackerman
 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list@lists.ximian.com
Date: Thursday, June 17, 2010, 11:31 AM

Good suggestion but that did not change the results.

--- On Thu, 6/17/10, Robert Jordan  wrote:

From: Robert Jordan 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list@lists.ximian.com
Date: Thursday, June 17, 2010, 10:53 AM

On 17.06.2010 18:07, Trevor Ackerman wrote:
> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
> afaik) and I'm having trouble with floats when executing
 code.

...

> My CFLAGS and CPPFLAGS environment variables are
>   both
> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1

-DNO_UNALIGNED_ACCESS is probably needed as
 well.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list









  
-Inline Attachment Follows-

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



  ___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-17 Thread Geoff Norton
Is your system armeb or armel?

It could be a endian bug in our softfloat impl somewhere.

-g

On 2010-06-17, at 7:54 PM, Trevor Ackerman wrote:

> I have more to report.
> 
> I wrote a quick native C program to print out the bytes of a float and double 
> variable that were assigned the literal value 1.0f. 
> 
> Then in the mono 2.6.4 routine mono_method_to_ir in source code file 
> mono/mini/method_to_ir.c I dumped out the bytes of ip (instruction pointer) 
> used for the double value in the case for CEE_LDC_R8.
> 
> I discovered that the bytes in the double value used on mono had the high and 
> low 32 bits swapped compared to those produced by the native C program. I 
> hacked the routine decompose_soft_float to swap the high and low words and 
> now I have no troubles and the basic-float regression test passes 100%.
> 
> Although this happens to work, I have a hard time believing that this is the 
> correct solution to my problem. I feel that others are probably using ARM9 
> without floating point issues and that I am probably missing something in how 
> I built mono for my platform. If anyone can shed some light on what I did 
> wrong with building mono that'd be great. Of course if this is the correct 
> action to take please let me know that too and how I may contribute the 
> change back to the trunk (assuming that the trunk doesn't work which I 
> haven't had time to test yet).
> 
> In the meantime here's my hack to decompose_soft_float in method-to-ir.c
> 
> 
>  5073 case OP_R8CONST: {
>  5074 unsigned char *ucp = (unsigned char *) ins->inst_p0;
>  5075 unsigned char rawval[8];
>  5076 printf("decompose_soft_float OP_R8CONST\n");
>  5077 rawval[0] = ucp[4];
>  5078 rawval[1] = ucp[5];
>  5079 rawval[2] = ucp[6];
>  5080 rawval[3] = ucp[7];
>  5081 rawval[4] = ucp[0];
>  5082 rawval[5] = ucp[1];
>  5083 rawval[6] = ucp[2];
>  5084 rawval[7] = ucp[3];
>  5085 DVal d;
>  5086 //  d.vald = *(double*)ins->inst_p0;
>  5087 d.vald = *(double*)rawval;
>  5088 MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
>  5089     break;
>  5090 }
> 
> --- On Thu, 6/17/10, Trevor Ackerman  wrote:
> 
> From: Trevor Ackerman 
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 11:31 AM
> 
> Good suggestion but that did not change the results.
> 
> --- On Thu, 6/17/10, Robert Jordan  wrote:
> 
> From: Robert Jordan 
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 10:53 AM
> 
> On 17.06.2010 18:07, Trevor Ackerman wrote:
> > I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
> > afaik) and I'm having trouble with floats when executing code.
> 
> ...
> 
> > My CFLAGS and CPPFLAGS environment variables are
> >   both
> > -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1
> 
> -DNO_UNALIGNED_ACCESS is probably needed as well.
> 
> Robert
> 
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 
> -Inline Attachment Follows-
> 
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-18 Thread Trevor Ackerman
I believe it is armel, here's what 'file' reports for a natively compiled C 
program.

hello_world_c: ELF 32-bit LSB executable, ARM, version 1, dynamically linked 
(uses shared libs), not stripped.

Let me know if you still believe it is a bug and how I may contribute a 
solution, whether the example change I posted is appropriate or not.

Thanks

--- On Thu, 6/17/10, Geoff Norton  wrote:

From: Geoff Norton 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: "Trevor Ackerman" 
Cc: mono-devel-list@lists.ximian.com
Date: Thursday, June 17, 2010, 9:54 PM

Is your system armeb or armel?
It could be a endian bug in our softfloat impl somewhere.
-g
On 2010-06-17, at 7:54 PM, Trevor Ackerman wrote:
I have more to report.

I wrote a quick native C program to print out the bytes of a float and double 
variable that were assigned the literal value 1.0f. 

Then in the mono 2.6.4 routine mono_method_to_ir in source code file 
mono/mini/method_to_ir.c I dumped out the bytes of ip (instruction pointer) 
used for the double value in the case for CEE_LDC_R8.

I discovered that the bytes in the double value used on mono had the high and 
low 32 bits swapped compared to those produced by the native C program. I 
hacked the routine decompose_soft_float to swap the high and low words and now 
I have no troubles and the basic-float regression test passes 100%.

Although this happens to work, I have a hard time believing that this is the 
correct solution to my problem. I feel that others are probably using ARM9 
without
 floating point issues and that I am probably missing something in how I built 
mono for my platform. If anyone can shed some light on what I did wrong with 
building mono that'd be great. Of course if this is the correct action to take 
please let me know that too and how I may contribute the change back to the 
trunk (assuming that the trunk doesn't work which I haven't had time to test 
yet).

In the meantime here's my hack to decompose_soft_float in method-to-ir.c


 5073 case OP_R8CONST: {
 5074 unsigned char *ucp = (unsigned char *) ins->inst_p0;
 5075 unsigned char
 rawval[8];
 5076 printf("decompose_soft_float OP_R8CONST\n");
 5077 rawval[0] =
 ucp[4];
 5078 rawval[1] = ucp[5];
 5079 rawval[2] = ucp[6];
 5080 rawval[3] = ucp[7];
 5081 rawval[4] = ucp[0];
 5082 rawval[5] = ucp[1];
 5083 rawval[6] = ucp[2];
 5084 rawval[7] = ucp[3];
 5085 DVal d;
 5086
 //  d.vald = *(double*)ins->inst_p0;
 5087 d.vald = *(double*)rawval;
 5088 MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
 5089 break;
 5090 }

--- On Thu, 6/17/10, Trevor Ackerman  wrote:

From: Trevor Ackerman
 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list@lists.ximian.com
Date: Thursday, June 17, 2010, 11:31 AM

Good suggestion but that did not change the results.

--- On Thu, 6/17/10, Robert Jordan  wrote:

From: Robert Jordan 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: mono-devel-list@lists.ximian.com
Date: Thursday, June 17, 2010, 10:53 AM

On 17.06.2010 18:07, Trevor Ackerman wrote:
> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
> afaik) and I'm having trouble with floats when executing
 code.

...

> My CFLAGS and CPPFLAGS environment variables are
>   both
> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1

-DNO_UNALIGNED_ACCESS is probably needed as
 well.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list









  
-Inline Attachment Follows-

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



  ___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




  ___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-18 Thread Geoff Norton
The change you posted is certainly not correct as soft float works on
all our dev boards. Could you send us the contents of /process/cpuinfo
please?


On Friday, June 18, 2010, Trevor Ackerman  wrote:
> I believe it is armel, here's what 'file' reports for a natively compiled C 
> program.
>
> hello_world_c: ELF 32-bit LSB executable, ARM, version 1, dynamically linked 
> (uses shared libs), not stripped.
>
> Let me know if you still believe it is a bug and how I may contribute a 
> solution, whether the example change I posted is appropriate or not.
>
> Thanks
>
> --- On Thu, 6/17/10, Geoff Norton  wrote:
>
> From: Geoff Norton 
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: "Trevor Ackerman" 
> Cc: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 9:54 PM
>
> Is your system armeb or
>  armel?
> It could be a endian bug in our softfloat impl somewhere.
> -g
> On 2010-06-17, at 7:54 PM, Trevor Ackerman wrote:
> I have more to report.
>
> I wrote a quick native C program to print out the bytes of a float and double 
> variable that were assigned the literal value 1.0f.
>
> Then in the mono 2.6.4 routine mono_method_to_ir in source code file 
> mono/mini/method_to_ir.c I dumped out the bytes of ip (instruction pointer) 
> used for the double value in the case for CEE_LDC_R8.
>
> I discovered that the bytes in the double value used on mono had the high and 
> low 32 bits swapped compared to those produced by the native C program. I 
> hacked the routine decompose_soft_float to swap the high and low
>  words and now I have no troubles and the basic-float regression test passes 
> 100%.
>
> Although this happens to work, I have a hard time believing that this is the 
> correct solution to my problem. I feel that others are probably using ARM9 
> without
>  floating point issues and that I am probably missing something in how I 
> built mono for my platform. If anyone can shed some light on what I did wrong 
> with building mono that'd be great. Of course if this is the correct action 
> to take please let me know that too and how I may contribute the change back 
> to the trunk (assuming that the trunk doesn't work which I haven't had time 
> to test yet).
>
> In the meantime here's my hack to decompose_soft_float in method-to-ir.c
>
>
>  5073 case OP_R8CONST: {
>  5074 unsigned char *ucp = (unsigned char *) ins->inst_p0;
>  5075 unsigned char
>  rawval[8];
>  5076 printf("decompose_soft_float OP_R8CONST\n");
>  5077 rawval[0] =
>  ucp[4];
>  5078 rawval[1] = ucp[5];
>  5079 rawval[2] = ucp[6];
>  5080 rawval[3] = ucp[7];
>  5081 rawval[4] = ucp[0];
>  5082 rawval[5] = ucp[1];
>  5083 rawval[6] = ucp[2];
>  5084 rawval[7] = ucp[3];
>  5085 DVal d;
>  5086
>  //  d.vald = *(double*)ins->inst_p0;
>  5087 d.vald = *(double*)rawval;
>  5088 MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
>  5089     break;
>  5090 }
>
> --- On Thu, 6/17/10, Trevor Ackerman 
> http://mc/compose?to=t_acker...@yahoo.com>> wrote:
>
> From: Trevor Ackerman
>  http://mc/compose?to=t_acker...@yahoo.com>>
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 11:31 AM
>
> Good suggestion but that did not change the results.
>
> --- On Thu, 6/17/10, Robert Jordan 
> http://mc/compose?to=robe...@gmx.net>> wrote:
>
> From: Robert Jordan http://mc/compose?to=robe...@gmx.net>>
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 10:53 AM
>
> On 17.06.2010 18:07, Trevor Ackerman wrote:
>> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
>> afaik) and I'm having trouble with floats when executing
>  code.
>
> ...
>
>> My CFLAGS and CPPFLAGS environment variables are
>>   both
>> -DARM_FPU_NONE=1 -DMONO_ARCH_SOFT_FLOAT=1
>
> -DNO_UNALIGNED_ACCESS is probably needed as
>  well.
>
> Robert
>
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
> -Inline Attachment Follows-
>
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
>  <http://lists.ximian.com/mailman/listinfo/mono-devel-list>
>
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-06-18 Thread Trevor Ackerman
~ # cat /proc/cpuinfo 
Processor   : ARM926EJ-S rev 5 (v5l)
BogoMIPS    : 74.34
Features    : swp half fastmult edsp java 
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part    : 0x926
CPU revision    : 5

Hardware    : ConnectCore 9P 9215 on a JSCC9P9215 Devboard
Revision    : 
Serial  : 


--- On Fri, 6/18/10, Geoff Norton  wrote:

From: Geoff Norton 
Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
To: "Trevor Ackerman" 
Cc: "mono-devel-list@lists.ximian.com" 
Date: Friday, June 18, 2010, 9:41 AM

The change you posted is certainly not correct as soft float works on
all our dev boards. Could you send us the contents of /process/cpuinfo
please?


On Friday, June 18, 2010, Trevor Ackerman  wrote:
> I believe it is armel, here's what 'file' reports for a natively compiled C 
> program.
>
> hello_world_c: ELF 32-bit LSB executable, ARM, version 1, dynamically linked 
> (uses shared libs), not stripped.
>
> Let me know if you still believe it is a bug and how I may contribute a 
> solution, whether the example change I posted is appropriate or not.
>
> Thanks
>
> --- On Thu, 6/17/10, Geoff Norton  wrote:
>
> From: Geoff Norton 
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: "Trevor Ackerman" 
> Cc: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 9:54 PM
>
> Is your system armeb or
>  armel?
> It could be a endian bug in our softfloat impl somewhere.
> -g
> On 2010-06-17, at 7:54 PM, Trevor Ackerman wrote:
> I have more to report.
>
> I wrote a quick native C program to print out the bytes of a float and double 
> variable that were assigned the literal value 1.0f.
>
> Then in the mono 2.6.4 routine mono_method_to_ir in source code file 
> mono/mini/method_to_ir.c I dumped out the bytes of ip (instruction pointer) 
> used for the double value in the case for CEE_LDC_R8.
>
> I discovered that the bytes in the double value used on mono had the high and 
> low 32 bits swapped compared to those produced by the native C program. I 
> hacked the routine decompose_soft_float to swap the high and low
>  words and now I have no troubles and the basic-float regression test passes 
>100%.
>
> Although this happens to work, I have a hard time believing that this is the 
> correct solution to my problem. I feel that others are probably using ARM9 
> without
>  floating point issues and that I am probably missing something in how I 
>built mono for my platform. If anyone can shed some light on what I did wrong 
>with building mono that'd be great. Of course if this is the correct action to 
>take please let me know that too and how I may contribute the change back to 
>the trunk (assuming that the trunk doesn't work which I haven't had time to 
>test yet).
>
> In the meantime here's my hack to decompose_soft_float in method-to-ir.c
>
>
>  5073 case OP_R8CONST: {
>  5074 unsigned char *ucp = (unsigned char *) ins->inst_p0;
>  5075 unsigned char
>  rawval[8];
>  5076 printf("decompose_soft_float OP_R8CONST\n");
>  5077 rawval[0] =
>  ucp[4];
>  5078 rawval[1] = ucp[5];
>  5079 rawval[2] = ucp[6];
>  5080 rawval[3] = ucp[7];
>  5081 rawval[4] = ucp[0];
>  5082 rawval[5] = ucp[1];
>  5083 rawval[6] = ucp[2];
>  5084 rawval[7] = ucp[3];
>  5085 DVal d;
>  5086
>  //  d.vald = *(double*)ins->inst_p0;
>  5087 d.vald = *(double*)rawval;
>  5088 MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
>  5089 break;
>  5090 }
>
> --- On Thu, 6/17/10, Trevor Ackerman 
> http://mc/compose?to=t_acker...@yahoo.com>> wrote:
>
> From: Trevor Ackerman
>  http://mc/compose?to=t_acker...@yahoo.com>>
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 11:31 AM
>
> Good suggestion but that did not change the results.
>
> --- On Thu, 6/17/10, Robert Jordan 
> http://mc/compose?to=robe...@gmx.net>> wrote:
>
> From: Robert Jordan http://mc/compose?to=robe...@gmx.net>>
> Subject: Re: [Mono-dev] Arm9 NS9215 floating point troubles
> To: mono-devel-list@lists.ximian.com
> Date: Thursday, June 17, 2010, 10:53 AM
>
> On 17.06.2010 18:07, Trevor Ackerman wrote:
>> I have been able to cross-compile Mono 2.6.4 for the NS9215 (no fpu
>> afaik) and I'm having trouble with floats when executing

Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-08-16 Thread jaekim

I'm having a similar problem.  I'm using a Freescale mc9328mxs processor
(ARM920T core) that doesn't have hardware floating point.  I've tried
Trevor's C# test code and the console outputs incorrect floating point
values.  I have also tried Trevor's hack to method-to-ir.c and it doesn't
help for me. 

Example: 
Console.WriteLine("0.0f literal is " + 0.0f); 
Console.WriteLine("1.0f literal is " + 1.0f); 
Console.WriteLine("12.3f literal is " + 12.3f); 
Console.WriteLine("32f literal is " + 32f); 
Console.WriteLine("1024f literal is " + 1024f); 
Console.WriteLine("32768f literal is " + 32768f); 

Also when the application exits main(), I get an exception. 

Unhandled Exception: System.TypeInitializationException: An exception was
thrown 
 by the type initializer for System.Runtime.Remoting.Contexts.Context --->
Syste 
m.ArgumentOutOfRangeException: load factor 
Parameter name: loadFactor 
  at System.Collections.Hashtable..ctor (Int32 capacity, Single loadFactor,
IHas 
hCodeProvider hcp, IComparer comparer) [0x0] 
  at System.Collections.Hashtable..ctor (Int32 capacity, Single loadFactor)
[0x0 
] 
  at System.Collections.Hashtable..ctor () [0x0] 
  at System.Runtime.Remoting.Contexts.Context..cctor () [0x0] 

I've spent days trying to figure this out.  Any help is appreciated. 

Thanks.
-- 
View this message in context: 
http://mono.1490590.n4.nabble.com/Arm9-NS9215-floating-point-troubles-tp2259090p2327103.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-08-16 Thread jaekim

There seems to be an endianness problem when the floating point value goes to
the JIT.  I used Trevor's code and changed the byte order and my problems
disappeared.

In method-to-ir.c:

case OP_R8CONST: {
DVal d;

// ORIGINAL CODE
//d.vald = *(double*)ins->inst_p0;
//MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);

// NEW CODE TO CHANGE ENDIANNESS

unsigned char *ucp = (unsigned char *) ins->inst_p0;
unsigned char rawval[8];

rawval[0] = ucp[7];
rawval[1] = ucp[6];
rawval[2] = ucp[5];
rawval[3] = ucp[4];
 rawval[4] = ucp[3];
 rawval[5] = ucp[2];
rawval[6] = ucp[1];
rawval[7] = ucp[0];

d.vald = *(double*)rawval;

MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);

break;
}
case OP_R4CONST: {
DVal d;

// ORIGINAL CODE
/* We load the r8 value */
//d.vald = *(float*)ins->inst_p0;
//MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);

// NEW CODE TO CHANGE ENDIANNESS

unsigned char *ucp = (unsigned char *) ins->inst_p0;
unsigned char rawval[4];
rawval[0] = ucp[3];
rawval[1] = ucp[2];
rawval[2] = ucp[1];
rawval[3] = ucp[0];
d.vald = *(double*)rawval;

MONO_EMIT_NEW_I8CONST (cfg, ins->dreg, d.vall);
break;
}

Thanks Trevor!
-- 
View this message in context: 
http://mono.1490590.n4.nabble.com/Arm9-NS9215-floating-point-troubles-tp2259090p2327614.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Arm9 NS9215 floating point troubles

2010-08-25 Thread jaekim

I'm having a similar problem.  I'm using a Freescale mc9328mxs processor that
doesn't have hardware floating point.  I've tried Trevor's C# test code and
the console outputs incorrect floating point values.  I have also tried
Trevor's hack to method-to-ir.c and it doesn't help for me. 

Example:
Console.WriteLine("0.0f literal is " + 0.0f);
Console.WriteLine("1.0f literal is " + 1.0f);
Console.WriteLine("12.3f literal is " + 12.3f);
Console.WriteLine("32f literal is " + 32f);
Console.WriteLine("1024f literal is " + 1024f);
Console.WriteLine("32768f literal is " + 32768f);

Also when the application exits main(), I get an exception.

Unhandled Exception: System.TypeInitializationException: An exception was
thrown
 by the type initializer for System.Runtime.Remoting.Contexts.Context --->
Syste
m.ArgumentOutOfRangeException: load factor
Parameter name: loadFactor
  at System.Collections.Hashtable..ctor (Int32 capacity, Single loadFactor,
IHas
hCodeProvider hcp, IComparer comparer) [0x0]
  at System.Collections.Hashtable..ctor (Int32 capacity, Single loadFactor)
[0x0
]
  at System.Collections.Hashtable..ctor () [0x0]
  at System.Runtime.Remoting.Contexts.Context..cctor () [0x0]

I've spent days trying to figure this out.  Any help is appreciated.

Thanks.
-- 
View this message in context: 
http://mono.1490590.n4.nabble.com/Arm9-NS9215-floating-point-troubles-tp2259090p2324899.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list