.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Cyborg Factory > Sandbot
Sandbot A bot for Gunman Chronicles and They Hunger - by tschumann

Reply
 
Thread Tools
using -ffast-math for bot
Old
  (#1)
tschumann
Moderator
 
tschumann's Avatar
 
Status: Offline
Posts: 264
Join Date: Apr 2011
Location: Australia
Default using -ffast-math for bot - 06-03-2022

Has anyone used the -ffast-math gcc compilation flag for a bot? Is it safe? I haven't benchmarked but it does seem a bit iffy to use it.
  
Reply With Quote
Re: using -ffast-math for bot
Old
  (#2)
RoboCop
vBulletin Veteran
 
RoboCop's Avatar
 
Status: Offline
Posts: 210
Join Date: Feb 2013
Location: Dundee, Scotland
Default Re: using -ffast-math for bot - 06-03-2022

Personally...no and also
Code:
-O3
can be risky as well.

Also have you used
Code:
-static-libstdc++
to resolve the CXX ABI issue?





vBulletin Webmaster since 2001
  
Reply With Quote
Re: using -ffast-math for bot
Old
  (#3)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: using -ffast-math for bot - 09-03-2022

The flag fast-math is breaking standard compliance regarding floating point calculations and some other mathematical operations. Basically you should get pretty close results regarding floating point numbers, but they will not be 100% correct. Depending on the code, this might not be a problem.

Other thing which is disabled are traps(unix/linux) and async exceptions(Windows) when you try to do some architecture specific invalid math operation like division by zero. In that case the program will directly crash(you will not be able to trap/catch the signal). So it really depends on your code and use cases.

About -O3. This optimization flag does not break the compliance, on the contrary it will follow it more strictly regarding undefined behavior stuff. I.e. if your code is well written and does not rely on undefined behavior working in "specific" way then you will get a free performance boost. However, in large codebases that do not use linters and high warning levels, this is usually not the case so it may seems like -O3 is breaking your code.
  
Reply With Quote
Re: using -ffast-math for bot
Old
  (#4)
tschumann
Moderator
 
tschumann's Avatar
 
Status: Offline
Posts: 264
Join Date: Apr 2011
Location: Australia
Default Re: using -ffast-math for bot - 11-03-2022

Quote:
Originally Posted by RoboCop View Post
Personally...no and also
Code:
-O3
can be risky as well.

Also have you used
Code:
-static-libstdc++
to resolve the CXX ABI issue?
Hm okay - I haven't tested -O3
And not yet - I was having some trouble with VirtualBox continually corrupting my VM but not I have it sorted so I should reinstall Steam and try it.

Quote:
Originally Posted by The Storm View Post
The flag fast-math is breaking standard compliance regarding floating point calculations and some other mathematical operations. Basically you should get pretty close results regarding floating point numbers, but they will not be 100% correct. Depending on the code, this might not be a problem.

Other thing which is disabled are traps(unix/linux) and async exceptions(Windows) when you try to do some architecture specific invalid math operation like division by zero. In that case the program will directly crash(you will not be able to trap/catch the signal). So it really depends on your code and use cases.

About -O3. This optimization flag does not break the compliance, on the contrary it will follow it more strictly regarding undefined behavior stuff. I.e. if your code is well written and does not rely on undefined behavior working in "specific" way then you will get a free performance boost. However, in large codebases that do not use linters and high warning levels, this is usually not the case so it may seems like -O3 is breaking your code.
Ah I see - it did seem a little risky but I didn't know about the traps/exceptions bit.

Anyway, not that the extra speed is needed but I thought it was worth investigating.
  
Reply With Quote
Re: using -ffast-math for bot
Old
  (#5)
RoboCop
vBulletin Veteran
 
RoboCop's Avatar
 
Status: Offline
Posts: 210
Join Date: Feb 2013
Location: Dundee, Scotland
Default Re: using -ffast-math for bot - 12-03-2022

Also, I've just noticed that some or most of your float variable values don't have "f" suffixed for example:-

https://github.com/tschumann/sandbot...s/bot.cpp#L385

Code:
pBot->f_waypoint_time = 0.0;
Instead of:-

Code:
pBot->f_waypoint_time = 0.0f;
If I'm not mistaken, some IDEs like Visual Studio use those "0.0" values as doubles instead of floats aka "0.0f". I think if you refactor and make sure those float values have those "f" suffixes may improve your float precision codes.





vBulletin Webmaster since 2001
  
Reply With Quote
Re: using -ffast-math for bot
Old
  (#6)
tschumann
Moderator
 
tschumann's Avatar
 
Status: Offline
Posts: 264
Join Date: Apr 2011
Location: Australia
Default Re: using -ffast-math for bot - 19-03-2022

Yeah I think the compiler figures it out - I know I've had to change a few at times to avoid a warning or error but it seems like newer versions of Visual Studio assume it's a double literal by default, even when assigning to a float.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com