Hi Chris, Virtually all applications I’ve seen that are “slow” are slow not because of CPU time, but because of other operations (such as disk and network accesses) that are orders of magnitude more expensive. Or because they needlessly do operations many times where once would do. Certainly you know more about the specifics of your application and its larger objectives than a compiler can know. And therefore you CAN write code that is faster in the individual case than a compiler. That is quite true. But I have said this before, in 25+ years in the software business I’ve seen precisely one case where someone made huge performance gains in an application by hand-coding or tricking the compiler, and that was almost 20 years ago when the person wrote code that just fit in the 80286 pre-fetch cache. In every other case, the return on time investment for this kind of stuff is tiny (or negative) and serves merely to amuse the inner-geek in the coder and not the larger case of making the application faster. </soapbox> :)
I do think you make a valid point. It is *also*, however, one of my pert peeves when people make the kind of general statement you did. But also I agree just as annoying when people scream.. Hoo Rah! Hand coding rules!!
I have no doubt you know your stuff. None whatsoever.
RIght now the project I am on is actually GPU bound (so you are right there). But that is simply because the GPU is working very hard. And rightly so IMO!
I pay just as much attention to that as I do to the CPU end, because also from experience complacency is a killer, and as the project develops I know we are going to run out of CPU horsepower for AI, and maths.
I have actually found by in-lining and aggressively optimizing vector maths in asm I really can gain 50 - 200% increases in maths libraries, both my own, and those which I rely on from other APIs and have now re-written. I have found that gcc (whilst a great tool) is lagging behind on vectorization, or simply too head strong to listen to my tips / requirements.
That's not to say I haven't got bitten and had to find out the hard way why on one day a maths function that seemed to be on steroids with a recompile started acting like a geriatric!!
For straight C I would rarely if ever consider trying to hand code. But for a bunch of FFTs, Floors, Cubics and other vector arithmetic I just don't think compilers are quite up to speed yet.
Heh. I'll get off my soapbox now! :)
Cheers, Stephen.
|