Browse thread
[Benchmark] NBody
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Ken Rose <kenrose@t...> |
| Subject: | Re: [Caml-list] NBody (one more question) |
Christophe TROESTLER wrote: > When I compile the C code with -O0 (with gcc -o nbody.gcc -Wall > --fast-math nbody.c -lm), I get a time of 1.513s which is comparable > to OCaml (1.607s). But as soon as I turn on -O options (as with gcc > -o nbody.gcc -Wall -O1 --fast-math nbody.c -lm), the running time > drops down to 0.871s (0.58%). Can somebody tell me what is the > optimization that has such an effect and whether it could be applied > to OCaml ? (I am not saying or asking it to be done -- it is not up > to me to decide -- I just want to understand -- and I am not versed > enough in assembly to do it myself unfortunately :( ). I'm not familiar with the OCaml code generator, but gcc without optimization produces very naive code. Each source statement is translated separately, and all variable values are read from & written back to memory. (Only changed values are written, obviously) It doesn't do any instruction scheduling beyond what the processor may require for correctness. It really doesn't do anything more sophisticated than suppressing moves that have the same register as source & destination. So it might be just about anything, from using registers to some common-subexpression elimination to a number of others. - ken