OCCRA
Go to Post Lunacy was "space-themed" to about the same extent that Froot Loops are "fruit-themed." - Oblarg [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 07-05-2018, 04:52 PM
Chadfrom308's Avatar
Chadfrom308 Chadfrom308 is offline
Slave to the bot
AKA: Chad Krause
FRC #7226 (Error 404)
Team Role: College Student
 
Join Date: Jan 2013
Rookie Year: 2011
Location: East Lansing
Posts: 323
Chadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to behold
Re: Decimal precision in consts and use of double vs float

ARM uses NEON for floating point numbers

It can execute up to 16 instructions for floating point at the same time (actual robot use cases would be 4 or 2 based on float or double. The 16 instructions is for specialized instructions)

Basically, it's so fast that you really don't have to worry about it. You would make much better use of your time optimizing somewhere else.

Not sure if this would make any difference on FIRST Robots, maybe vision, but here is an open multithreading library that can help execute code faster:
https://en.wikipedia.org/wiki/OpenMP
__________________
//TODO: make signature
Reply With Quote
  #17   Spotlight this post!  
Unread 07-05-2018, 06:07 PM
Foster Foster is offline
Engineering Program Management
VRC #8081 (STEMRobotics)
Team Role: Mentor
 
Join Date: Jul 2007
Rookie Year: 2005
Location: Delaware
Posts: 1,550
Foster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by Chadfrom308 View Post
ARM uses NEON for floating point numbers
Not all ARM chips use NEON, and it's not clear to me that the existing RoboRIO's have the NEON instructions.

And I'm a fan of optimizing as we go. It's like "swiss cheesing" robots. I'd rather design to not to, but if I have to, I'd like to cheese as I go, I hate to cheese on the eve of stop build day.

Are you advocating Pi for hundreds of places or doubles vs floats?
__________________
Foster - VEX Delaware - 17 teams in 2016/17 -> 62 teams 2017/18 -- Chief Roboteer STEMRobotics.org
2010 - Mentor of the Year - VEX Clean Sweep World Championship
2006-2017, over a decade of doing VEX, time really flies while having fun
Delmarva Robotics and VEXMen Team Site come see what we can do for you.
Reply With Quote
  #18   Spotlight this post!  
Unread 07-05-2018, 07:00 PM
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,226
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by Foster View Post
Not all ARM chips use NEON, and it's not clear to me that the existing RoboRIO's have the NEON instructions.

And I'm a fan of optimizing as we go. It's like "swiss cheesing" robots. I'd rather design to not to, but if I have to, I'd like to cheese as I go, I hate to cheese on the eve of stop build day.

Are you advocating Pi for hundreds of places or doubles vs floats?
The RoboRIO does have NEON, and the compiler, at least for C++ definitely has it enabled. It does use the Soft Float ABI however, but the actual floating point calculations are definitely performed in hardware.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #19   Spotlight this post!  
Unread 07-05-2018, 09:55 PM
Chadfrom308's Avatar
Chadfrom308 Chadfrom308 is offline
Slave to the bot
AKA: Chad Krause
FRC #7226 (Error 404)
Team Role: College Student
 
Join Date: Jan 2013
Rookie Year: 2011
Location: East Lansing
Posts: 323
Chadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to behold
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by Foster View Post
Are you advocating Pi for hundreds of places or doubles vs floats?
I'm just saying don't worry about either. PI to 50 decimal places isn't going to have an effect on the speed any more than 4 decimal places

The reason it's there is because it was copied and pasted from another library (or is part of that other library) and they include it 'just because'

If you were doing sine/cosine calculations that depended on each other, the error would add up. In a 2 minute match? Probably not enough, but in a 2 month application, you probably would start to see something

You are right that floats *most of the time* execute faster (depends on application, of course)

http://nicolas.limare.net/pro/notes/...12_arit_speed/

https://www.anandtech.com/show/6971/...arm-processors

but remember you're splitting hairs at that point (for FIRST Robots, anyways)

I'm not saying abuse doubles, but don't be afraid of them. Trying to destroy every instance of a double will probably lead to more harm than good.

Like I said, there more places than just datatypes where you can explore efficiency
__________________
//TODO: make signature
Reply With Quote
  #20   Spotlight this post!  
Unread 07-06-2018, 12:35 AM
CarlosGJ CarlosGJ is offline
418 alumnus, 696 mentor
AKA: Carlos Gross Jones
FRC #0696 (Circuit Breakers)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: La Canada Flintridge, CA
Posts: 53
CarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to behold
Re: Decimal precision in consts and use of double vs float

I was a bit put off by this at first, too. The thing is, the roboRIO really is much more like a slightly dated desktop than an embedded system in the traditional sense (well, excluding the FPGA, but we don't get to play with that...). It has 256 MB of memory; it's difficult to burn through that unless you're doing something like vision processing. While it kind of offends my perfectionism, it really is usually more efficient to throw doubles at everything; you're far more likely to be limited by build season time than computational resources.

Although, I have to say, it does slightly make me wish for the days of the PIC18-based IFI controllers, so that I could teach clever microcontroller tricks. (Bitfields! Inline assembly! Stack manipulation!)
Reply With Quote
  #21   Spotlight this post!  
Unread 07-06-2018, 07:07 AM
marshall's Avatar
marshall marshall is offline
Online Stripe & Drape Sales
FRC #0900 (The Zebracorns)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2003
Location: North Carolina
Posts: 2,808
marshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by CarlosGJ View Post
It has 256 MB of memory; it's difficult to burn through that unless you're doing something like vision processing.
Yeah, vision processing - thatís what does it.
__________________
"La mejor salsa del mundo es la hambre" - Miguel de Cervantes
"The future is unwritten" - Joe Strummer
"Simplify, then add lightness" - Colin Chapman
Clarke's Laws
Reply With Quote
  #22   Spotlight this post!  
Unread 07-06-2018, 08:16 AM
Jaci's Avatar
Jaci Jaci is offline
http://imjac.in/ta/name
AKA: Jaci R Brunning
FRC #5333 (Can't C#) #5663 (Ground Control) | (OpenRIO, FRC West Aus)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 598
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by Chadfrom308 View Post
ARM uses NEON for floating point numbers

It can execute up to 16 instructions for floating point at the same time (actual robot use cases would be 4 or 2 based on float or double. The 16 instructions is for specialized instructions)

Basically, it's so fast that you really don't have to worry about it. You would make much better use of your time optimizing somewhere else.

Not sure if this would make any difference on FIRST Robots, maybe vision, but here is an open multithreading library that can help execute code faster:
https://en.wikipedia.org/wiki/OpenMP
The Cortex A9 family only supports single-precision NEON VFP operations (floats). Doubles and other exclusions are not supported on ARMv7 C9 NEON.

That being said, unless you're using intrinsics, you won't see much benefit in most FRC applications, since to outweigh other bottlenecks you need to calculate a LOT of values in a short amount of time, all of which follow the same calculation, which is not very typical of FRC control applications.

TL;DR fp math is light speed compared to other facets of the RoboRIO and user program, except for limited uses. Here is one such example:
http://imjac.in/ta/post/2016/11/14/r...sm-vision.html
__________________
Jacinta R Brunning

Curtin FRC (5333+5663) : Head Mentor
WPILib : Developer

Website | Github
jaci.brunning@gmail.com
Reply With Quote
  #23   Spotlight this post!  
Unread 07-06-2018, 10:01 AM
Foster Foster is offline
Engineering Program Management
VRC #8081 (STEMRobotics)
Team Role: Mentor
 
Join Date: Jul 2007
Rookie Year: 2005
Location: Delaware
Posts: 1,550
Foster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond reputeFoster has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Thanks Jaci for the interesting article, it is an interesting case of how to use special CPU instructions to get things done in a hurry. Lots of CPU have special vector operators.

You said that the A9 NEON only supports floats, does it manage doubles in some kind of emulation package?
__________________
Foster - VEX Delaware - 17 teams in 2016/17 -> 62 teams 2017/18 -- Chief Roboteer STEMRobotics.org
2010 - Mentor of the Year - VEX Clean Sweep World Championship
2006-2017, over a decade of doing VEX, time really flies while having fun
Delmarva Robotics and VEXMen Team Site come see what we can do for you.
Reply With Quote
  #24   Spotlight this post!  
Unread 07-06-2018, 10:20 AM
Jaci's Avatar
Jaci Jaci is offline
http://imjac.in/ta/name
AKA: Jaci R Brunning
FRC #5333 (Can't C#) #5663 (Ground Control) | (OpenRIO, FRC West Aus)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Perth, Western Australia
Posts: 598
Jaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond reputeJaci has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by Foster View Post
Thanks Jaci for the interesting article, it is an interesting case of how to use special CPU instructions to get things done in a hurry. Lots of CPU have special vector operators.

You said that the A9 NEON only supports floats, does it manage doubles in some kind of emulation package?
A9 NEON doesn't support doubles at all, your best bet is to cast to a float, else accept the performance penalty. This document talks more about the SIMD/NEON implementation on Cortex A9 processors (i.e. the roborio arm architecture). Table 2-1 in section 2.4 is of particular note here: http://infocenter.arm.com/help/topic...e_r3p0_trm.pdf

The CPU itself is capable of working with doubles, they just can't be vectorized. This document outlines the FPU's job more, in particular section 1.3 "Writing Optimal FP Code" is pretty relevant to this thread, although it does talk in the low-level assembly sense.
https://static.docs.arm.com/ddi0408/...u_r4p1_trm.pdf
__________________
Jacinta R Brunning

Curtin FRC (5333+5663) : Head Mentor
WPILib : Developer

Website | Github
jaci.brunning@gmail.com
Reply With Quote
  #25   Spotlight this post!  
Unread 07-06-2018, 11:21 AM
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 2,459
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Keep in mind that up into the 70s (I know stone age for anybody in high school now.) real engineering was done on slide rules with a precision of about 3 digits. Calculators referred to a room filled with mostly women doing math by hand. Hidden Figures is a movie largely about this. The star, Katherine Gobble, is an amazing person. Well worth listening to her speak about anything.

A large difference in engineering practice back then is you tended to run a lot fewer what if scenarios and thought a lot more about what you were doing before crunching numbers. I am not wishing for the good old days.
__________________
If you don't know what you should hook up then you should read a data sheet

Last edited by FrankJ : 07-06-2018 at 01:12 PM.
Reply With Quote
  #26   Spotlight this post!  
Unread 07-06-2018, 01:28 PM
brennonbrimhall brennonbrimhall is offline
Lead Mentor
AKA: Brennon Brimhall
FRC #6844 (Provotypes)
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Provo, UT
Posts: 368
brennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond reputebrennonbrimhall has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Before I get into the nitty gritty here, I'd like to invoke these words by Donald Knuth:

Quote:
Originally Posted by Donald Knuth
Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.
FRC is radically different software and programming experience than anything else I've participated in - I'm simply not aware of another organization that has high schoolers design and write production software in six weeks. And let's face it - six weeks is far too generous a figure. Just look at the posts we get on here at the end of week 5 and into week 6 of build seasons.

Quote:
Originally Posted by GeeTwo View Post
We're fundamentally attacking two different problems. I'm optimizing for programming a robot in a very compressed timeframe. I'm optimizing for reprogramming a robot in the pit in between matches. I'm not claiming that I'm trying to optimize my CPU usage.

Quote:
My integer atan2() was for an arduino, not a RIO, and I certainly don't mean to advocate for writing such a routine for the RIO! That said, I can't think of any reason to do significant amounts of double precision arithmetic on board an FRC robot - even (or especially) a 900 robot.
Thanks for this disclaimer. My time with 6844 has reminded me how many people read comments like this on CD but don't necessarily have an understanding of their implicit context.

Quote:
While on the subject, I'd like to call out Java* programmers who create a new object when the proper solution is to modify an existing one. Just because you can do something doesn't mean you should.

* there are probably also some C++ programmers who do this, but I've mostly seen it in Java.
I'm not aware of this being common in C++, but that's strictly a function of the C++ memory model - the programmer is manually managing the memory. In Java, we have the benefit of garbage collection, and here we're left with the choice that Matt touched on. Given two implementations that are both correct and both execute in an acceptable time frame, I will take the one that is easier to read, reason about, and maintain every single time.
__________________
Code and FRC, my personal blog.

Team 20, 2012-2014: 4 blue banners, 5 medals, and 9 team awards.
Missionary, Church of Jesus Christ of Latter-day Saints, 2014-2016: Colorado Denver South Mission.
Brigham Young University, 2016-present: Computer Science.
Team 6844, 2018-present: 2018 Utah RAS, 2018 Newton/Carver RHS.
Reply With Quote
  #27   Spotlight this post!  
Unread 07-06-2018, 03:26 PM
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 2,248
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by brennonbrimhall View Post
I'm not aware of this being common in C++, but that's strictly a function of the C++ memory model - the programmer is manually managing the memory. In Java, we have the benefit of garbage collection, and here we're left with the choice that Matt touched on. Given two implementations that are both correct and both execute in an acceptable time frame, I will take the one that is easier to read, reason about, and maintain every single time.
Reply With Quote
  #28   Spotlight this post!  
Unread 07-06-2018, 03:42 PM
CarlosGJ CarlosGJ is offline
418 alumnus, 696 mentor
AKA: Carlos Gross Jones
FRC #0696 (Circuit Breakers)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: La Canada Flintridge, CA
Posts: 53
CarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to beholdCarlosGJ is a splendid one to behold
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by notmattlythgoe View Post
...
I'll just leave this here: http://tech.jonathangardner.net/wiki/Why_Java_Sucks#GC_Sucks_So_Badly.2C_That_You_Shoul d_Avoid_Using_Memory
Reply With Quote
  #29   Spotlight this post!  
Unread 07-06-2018, 03:59 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Mentor
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 5,713
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Decimal precision in consts and use of double vs float

Quote:
Originally Posted by notmattlythgoe View Post
^^
I always figured using the jdb on the gc would be enlightening, but I didn't realize it would be that easy to understand the output.

Quote:
Originally Posted by gixxy, on slack
I think that last object may have still been in use. lol.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
[Quoting brennonbrimhall]: We design a new robot every year, but we can't forget that we also design a new team every year as folks come and go.

Last edited by GeeTwo : 07-06-2018 at 04:02 PM.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:31 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi