1. How do you ensure that the compiler did not optimize away the assignment to q or the call to sqrt() due to recognition that it has no side-effects (in 80x86 processors, there is a FP sqrt instruction so a serious compiler knows to inline the function call and that it leaves no side effects)? 2. Why not use q += sqrt(i) in the benchmark (solves the above problems without special compiler options or obscure pragmas)?
On Mon, 2005-08-08 at 16:02 +0300, Marc A. Volovic wrote: > Example of an idiotic benchmark: > > int > main() > { > long long i; > double q; > > for (i=0; i<10000000; i++) { > q = sqrt(i); > } > } > > Under gcc 3.3.5 (Debian Sarge) this pile of drek executes in 1.4-1.8 > seconds (depending on -O level). Under icc 9.0 it executes between in > 3.4 seconds for -O0 and -O1, and in 0.015 seconds for -O2. > > And don't tell me this is not a valid benchmark. I know. This is as > artificial as I can get without using a wooden leg. -- One does not make peace with enemies. One makes peace with former enemies. My own blog is at http://www.livejournal.com/users/tddpirate/ My opinions, as expressed in this E-mail message, are mine alone. They do not represent the official policy of any organization with which I may be affiliated in any way. WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]