CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   assembly coding for CFD (

Andrei Chernousov November 2, 2000 03:33

assembly coding for CFD
Can anybody tell is it worth to convert even the most time critical portion(s) of CFD code written in C to achieve a substantial speedup?

Thanks in advance,


John C. Chien November 2, 2000 17:23

Re: assembly coding for CFD
(1). Based on the theory of Garbage-in-grabage-out, the speed up is going to produce the garbage at a faster rate. This is especially true in CFD. (2). If you are doing computer games, then, you will have not choice but to find ways to speed up the code. (3). In CFD, if you are doing 3-D, it is usually very slow, or very very solw. The convergence and accuracy of the solution usually is more important (or much more important) than the speed of the code. (4). A very fast code also is very difficult to read. Well, the choice is yours. It is not easy to speed up a code, because modern compiler optimization is very effective.

Brian Gribben November 3, 2000 12:49

Re: assembly coding for CFD
I've seen some very impressive speed-ups when certain heavily-used routines are written in assembler. A disadvantage is that your code then becomes less portable and legible. And of course your compiler may be cleverer than you think and your effort may be wasted.

Whether it's "worth" the effort is of course very subjective, depending on your own skill set and what you consider important for your code. My overall feeling though is that it won't be worth the effort, spend your precious time doing something else!

Bob Anderson November 4, 2000 17:08

Re: assembly coding for CFD
In general, I don't think assembly (assembler is not a language, but the tool that converts assembly to machine language, i.e., an assembly "compiler") is worth it with the optimizing compilers available today. However, C does not optimize particularly well for some numerical applications. I've seen a typical speed-up of a factor of 2 or 3 when translating an explicit CFD C code into an equivalent fortran 77 code, and vice-versa.

What might be worth a shot is converting your most expensive inner loops to f77 (dissipation and viscous terms tend to be the culprits), and then using a quality optimizing compiler on them.

Even if speedup was possible using assembler, the maintenance and portability hits would, in most cases, far outweight the potential speedup gains.

Kenji Takeda November 9, 2000 10:33

Re: assembly coding for CFD
When in doubt, let somebody else do it for you ;-)

Intel has assembly coded BLAS 1,2 & 3, LAPACK and FFT routines for slotting into your own (CFD!) code. They are available for free download under the guise of the 'Intel Math kernel Library' from...

They are also available for Linux (a by-product of the ASCI Red project), but I can't remember the URL.

In general, you should use BLAS routines where possible, as other vendors typically supply (assembly) optimised versions with their systems as part of their 'fast' maths libraries.

My colleague here reports 2-3 times speedup on a spectral element CFD code using the Intel libraries under Windows NT!!!

Not sure if AMD have a similar set of libraries, but I do know that Digital Visual FORTRAN version 6.5, just out, contains Athlon optimisations.

Hope this is of use :) Dr Kenji Takeda ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ School of Engineering Sciences (Aeronautics and Astronautics) University of Southampton, UK ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All times are GMT -4. The time now is 15:46.