|
From: Douglas V. <dou...@dy...> - 2006-03-17 14:37:49
|
> > > Malloc is not the problem. > > Right -- I added another time() and it shows that the malloc calls > do usually add 0 sec and occasionally 1 sec. > > > I wouldn't know enough about the assembled code to know what was going=20 > > on and decipher it. I would have thought though that gcc would create=20 > > similar code. > > I have tried your code and the gcc invocations on Linux with both > 3.3.5 as well as 4.0.2. > > 3.3.5 mostly reflects your results (about 23 sec on my machine). > However the -ffast-math version with 4.0.2 results in about 9 sec > on my machine which is pretty similar to your 8.9 sec using .NET > > I have not bothered to check on the generated assembly however > all but the -ffast-math version requires -lm on Linux which probably > implies there is a subroutine call involved. > Can a subroutine call add that much overhead. Yes I understand that there is some overhead, but certainly it seems to me that the calculation of a trig function is alot more time consuming than such overhead. This example with the trig functions was just a small one I put together so other people could test. If I were to use a Gaussian elimination code to solve a large matrix i would get comparable results that Cases C and D are much slower than any of the others. This would not involve any complex trig function just straight forward adding and multiplaction. I can do this and make all these runs again if I need to to show that its not just associated with the trig function. > Therefor I guess Greg Chicares assumption that the difference in > speed is due to FSIN inline (or something similar) as opposed to > actually calling a subroutine has some probability. > > However according to the gcc docs -ffast-math option impacts > reproduceability of the results on different platforms etc. As I said, I don't know the implications of using -ffast-math and don't necessarly want to use it as "the solution". But still, if you compare Case A1 with Case C1 or D1 there is a large difference in run time. And as just stated above, this slowness is not just associated with trig functions. If i use one that just uses basic it math there is still a large runtime difference. > > Best, > Michael |