What is wrong with gcc 4.4.1

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

What is wrong with gcc 4.4.1

Postby Julio Jerez » Tue Mar 02, 2010 11:17 am

Last time I build the engine in Linux I believe is was with GCC 4.3.x

and I used the options #CPU_FLAGS = -fPIC -O2

after many trying I found that it generate the faster code,
However I run Sinaptic update in Ubuntu and it installed CCG 4.4.1

and now the 64 bit bill have lot of float math problems, after reveral hours of debugging I found no error, and after trying the code in debug mode I realized
this this was compiler code generation bug, so I tried option CPU_FLAGS = -fPIC -O2 -ffloat-store and the code run correctly again

As I remember last time I used those option the code was about half the speed of the code without float-store.
what the hell is going on with the GCC people that they make such huge changes from one version to the next.
has any one seen these huge difference from one GCC version to the next?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby Julio Jerez » Tue Mar 02, 2010 11:38 am

I also noticed that after all these years the GCC people realized that the stack must be aligned in function calls
from the new feature list I read this,
IA-32/x86-64
...
...
* Automatically align the stack for local variables with alignment requirement.


what is funny is the about 5 year ago, I reported this and in certain graphic and physics forums I was treated like a moron that did not know what I was doing.
you could no do any SSE code using local on variables that did no have explicit alignment which was a big problem for mutilator code.
I have to turn SSE off for a long time because of that, until I wrote in a way the is independent of compiler alignment.

I may seem like a not brainier but is more tedious than you may think, you end up doin aligmen of data structures and create variable like this *.

Code: Select all
struct MtData

   //put all you local data here
}

function foo ()
{
   char pool[sizeof(MtData) + 32];
   // make sure the local array is aligned to 16 bytes
   MTData* cont ptr =   (MTData*) (((long) pool) + 15) & -16;
    ...
    ...
}

Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby martinsm » Tue Mar 02, 2010 1:10 pm

Afaik -ffloat-store generates slower floating point code, because it always store intermediate result into variables instead of keeping them in floating point registers. In result you get a lot of memory operations.
Using this option vs not using can give completely different results in calculations. For example:
Code: Select all
float a = ...;
float b = ...;
float c = a + b;
double d = c*2;

With -ffloat-store a+b result will be stored in local stack (variable c), and in d=c*2 it will be reloaded from memory. Without it - variable c will be optimized away, and c*2 will be calculated from floating point register. Meaning - increased precision (because floating point registers have 80-bit precision), but lower speed.

Better try -ffast-math option that generates faster floating point code.

What exactly error messages you were getting?

I don't think that something is wrong with gcc 4.4.1. It's just default optimizations settings change from time to time. It's nothing unusual. If you don't want this behavior - stick to one version, don't upgrade so often. This is true even for Newton library. If I'm using 1.53, and I don't want more work and changing code, I won't upgrade to 2.x. Same thing applies between versions in 2.x beta releases.
martinsm
 
Posts: 86
Joined: Mon Dec 19, 2005 3:15 pm
Location: Latvia

Re: What is wrong with gcc 4.4.1

Postby Julio Jerez » Tue Mar 02, 2010 3:03 pm

I am not getting any error, I am just getting collision mal funtions.
Exploiion, bad contacts etc.

I us etio get thoe error with GCC 3.3 and lowe version, then wne 4.x.x came out I was able to build onle with option O2,
but with teh lates GCC4.4.x thos math erro came back.
it is not error it is bug in GCC code generation that do not happens with VS or Intel compiler or GCC xcode in the MAC.
option -float-store seems to fix it, I am hope it is not at the expence of cutting half the porformance.
about the option, thinking to one version may be costly, because you state with old versions.
any way the problems are gone, now.

BTW Martinsm a user from China is using Newton with multiple worlds in Linux, and he found a bug when using Hieghtfild collision.
I was cause becaus eI have a stack global variable the was charea by multi colllsion shapesn but was no considering mutpl world instanance.
I fix it by moving variable instance to the world object, and this is why I was making a new Linux Build.

I run Ubuntu update and that how I got this compiler problems, but to is fine now.
later I will see if I can isolate the problem, and maybe I can go back to not using -ffloat-store
I do not really liek using that option, but for now it will do.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby Julio Jerez » Thu Mar 04, 2010 3:11 am

The Problem is that each time you launch Unbutu it always comes up with the Update pop up.
when I Boot on linux after my last section, it came up with New Ubuntu Version 9.10 and I clicked yes.
the version of the G++ compiler is GCC 4.4.3 which generates bugus binaries.

but when I opened the laptop, it still has Ubuntu 9.02 and there latest GCC is still 4.3.3 which generate the correct binary.
I am guessing the GCC folk went crazy trying to be too aggresive with optimization for this GCC, but they F*%k up the defualt code generation for floats intensive libraries,
maybe someone else complain about this and they fix it for GCC 4.5.0
as it stand now I do not see how to revertt back from a higher version to a lower, so I guess, my 64 bit linux I will have to leave like that until the next version of Ubuntu or GCC is out.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby JernejL » Thu Mar 04, 2010 4:43 am

You could try to make a small example and submit a bug report to GCC, compiler developers usually take such bugs very seriously, so there's a very good chance that they will fix it if you can prove them that the bug exists.

Still, 4.3.3 can probably cross-compile 64 bit binaries for linux?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: What is wrong with gcc 4.4.1

Postby Julio Jerez » Thu Mar 04, 2010 11:21 am

Now I finish building the engine in 32 bit, and something is very very wrong, the engine is slow, and exploding all over the place.

I had not changes to the engine from 2.17, the only changes is adding collada, and WxWidget.
I believ that some how WxWidge does not play nice with OpenGL and other libraries,

teh Gl_Camvas is flikering all over the place.
I do not know what to do, and do not really want to start looking for another GUI.

The thing is that even the 2.17 does not work in Linux now, I do not know what is going on.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby Stucuk » Thu Mar 04, 2010 11:35 am

Does disabling WxWidge make it faster?
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: What is wrong with gcc 4.4.1

Postby Julio Jerez » Thu Mar 04, 2010 11:51 am

It is not that eassy now, since I wold have to come up with a new front end to present the graphics.

The other thing is that I was wondering how the hell I got GCC 4.4.1 in my system when I do not remember ever doing that.
so I Update again to Ubuntu to 9.10 in my 32 bit system, I guess that if you update from 9.03 to 9.10, it silently replace GCC 4.3 with GCC 4.4.1
It tell you that Many Libraries are not longer supported and one of them is GCC 4.3.x, so is either you stay with the older version of ubuntu or you get all the changes that comes with it.

These are the * you get with the Open Source Community of Self appointed Experts, Every Idia that comes from where the sun do not shine goes.
Now I have more that 2 dozen libraries added to the projects, and after two month I have zero progress. It is all compile and searching the next Open source decencies.

It is so ridiculuos that some moron at the Collada group decided that it was a good idea to add 65 Megabytes of source code to a project that is already more than 100 Megabytes, just to include a smart pointer.

I find that I am spending more than 99% of my time trying to figure out what some self appointed Open Source expert did just to get the * to compile.
All I have is a 8 megbyte executable that does not really works.

Just one compiled Utility Library is more than 50 megabytes while the completed Newton engine is only 670 kBytes.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby Stucuk » Thu Mar 04, 2010 6:52 pm

Can't you just download the older version from the internet and install it?
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: What is wrong with gcc 4.4.1

Postby Julio Jerez » Tue Mar 09, 2010 12:08 pm

Aparently the wiereness in Linux was beacause of two things,
in the gl render canvas I was using this method to do realt time update

Code: Select all
void RenderCanvas::OnIdle(wxIdleEvent &event)
{
   // this method is recommended by the WxWidegt doc, but it is very buggy and it appears to mess with the timer.
   // send a paint update for viewing the next frame
   wxPaintEvent paintEvent;
   GetEventHandler()->ProcessEvent(paintEvent);

   / make sure we send a request for the next update
   event.RequestMore ();
}


it work fine in windows but in Linux it appears to send event messages before the last update finish, I do not know why but it was wierd.
I changed to this

Code: Select all
void RenderCanvas::OnIdle(wxIdleEvent &event)
{
   // this is much elegant and it works on all platform
   Refresh(false);
}


and now is fine.
the secund problem was the it appears that OGL initilization in windowes set double buffer by deffault, but i Linux it does not, so I have to add this to the creation code

Code: Select all
// Note: In Linux the default gl_canvas window does not uses GL_DOUBLEBUFFER,
   // this results int a terrible flicker when rendering in real time
   // the solution is to explicitly force DL_DOUBLEBUFFER on all platform
   int attributes [] = {WX_GL_DOUBLEBUFFER, WX_GL_RGBA,  0};
   // add the render window   
   m_canvas = new RenderCanvas(this, wxID_ANY, wxDefaultPosition, wxSize(300, 300), wxSUNKEN_BORDER, attributes);
}


now the flicker is gone.
Now I am moving to the Mac to try to bring every thing to the same level, but I am seen big problem already,
it looks like COLLADA xcode project does not build for MAC OS 10.4.

so I will try later 10.5 only and if some one want to make the 10.4 they are free to do it,
but keeping backward compatibility is taking too much of my time in stuff that I simple hate to do.
so I will only use xcode 3.0 and forget abput xcode 2.5 because Collada and wxwidget projects are simple to big to recreate.

in addition there are like another half a dozen dependencies libraries I have not even tried to build yet.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What is wrong with gcc 4.4.1

Postby Carli » Sun May 16, 2010 3:26 pm

Julio Jerez wrote:but keeping backward compatibility is taking too much of my time in stuff that I simple hate to do.


So why do you do all the work alone?
You could give the code to some trustworthy person who cares about portin Newton to all platforms, the users need and who keeps the backwards compatibility to each visual studio version ;)
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: What is wrong with gcc 4.4.1

Postby Carli » Sun May 16, 2010 3:27 pm

[Edit: and Linux and MAC of course .]
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: What is wrong with gcc 4.4.1

Postby JernejL » Sun May 16, 2010 4:05 pm

Bumping 2 month old topic to discuss this?
viewtopic.php?f=9&t=5840

Please don't do that..
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: What is wrong with gcc 4.4.1

Postby Stucuk » Sun May 16, 2010 4:37 pm

Its unlikely you would find someone who is dedicated. If you look at all the wrappers for Newton, there are alot that were never updated for 2.0 . That tells you alot, the wrappers were open source and when the main guy looses interest it never gets updated again.

P.S The reason Julio is giving up Backwards compatibility in what you quoted was because of External Libraries not Newton, so the Newton Source code isn't required. He also wasn't talking about Visual Studio but XCode. Btw, hes also on about the demo/samples rather than Newton its self(Newton doesn't use wxwidget for example in its self as wxwidget is a User Interface). So your quote is completely unrelated to what your talking about.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron