Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Fixed-point arithmetic


  • Please log in to reply
5 replies to this topic

#1 aalmada

aalmada

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts
  • LocationPortugal

Posted 04 May 2012 - 08:43 AM

Hi, I implemented a fixed-point arithmetic class hoping to get some performance boost on my apps. I did some benchmarking on the Netduino and found that it actually slows down considerably. It's a fully managed implementation and that may be the problem. Any feedback is welcome. Here is the code: https://bitbucket.or...ed/Fixed1516.cs aalmada

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 04 May 2012 - 11:29 AM

Your effort is valuable, but...why did you create a fixed point math when there is a full-featured set of primitives working very well? BTW, I'm not sure at all, but the "Single" (float) type should be treated directly from the CPU. Instead, the "Double" is much heavier to treat, and should be avoided in the MF. That's for either performance and memory occupation. Thanks for sharing, anyway. Cheers
Biggest fault of Netduino? It runs by electricity.

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 May 2012 - 11:32 AM

Hi aalmada, You wrote a fully-managed floating-point arithmetic class? That is very cool. Chris

#4 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 04 May 2012 - 11:35 AM

Hi aalmada,

You wrote a fully-managed floating-point arithmetic class? That is very cool.

Chris


Nope: it's *fixed* point...that's the oddity.
Biggest fault of Netduino? It runs by electricity.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 May 2012 - 12:01 PM

Nope: it's *fixed* point...that's the oddity.

Aah. I read that wrong. Makes sense.

Chris

#6 aalmada

aalmada

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts
  • LocationPortugal

Posted 04 May 2012 - 01:06 PM

Your effort is valuable, but...why did you create a fixed point math when there is a full-featured set of primitives working very well?
BTW, I'm not sure at all, but the "Single" (float) type should be treated directly from the CPU. Instead, the "Double" is much heavier to treat, and should be avoided in the MF. That's for either performance and memory occupation.
Thanks for sharing, anyway.
Cheers


Having the "full-feature set" doesn't always mean that that's the best performing solution. Just ask the game development people. They usually go out of their way just to save one clock cycle. They are the kind of people that use fixed-point arithmetic: http://netwinder.osu...nw/fix1FAQ.html

I found the following at the TinyCLR forum: "floating point is supported in NETMF, not matter if the processor supports it or not. ARM7 do not have floating point"

I know I should have benchmarked the performance of native types first but I was curious how fixed point works anyway. I was surprised to find that the performance on a Netduino for the multiplication of Int16, Int32, Single or Double, is exactly the same. Unlike you state above, or I'm doing something wrong then...

I found in my recent research that TinyCLR has a native compilation of MathEx for better performance: http://www.tinyclr.c...28/#/1/msg11672

Anyway, it was a great ride and I'm back to my Single-based arithmetic...

aalmada




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.