<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.1.92">
</HEAD>
<BODY>
Hmm reading code i verified that i can gain a 10% writing:<BR>
<BR>
imd dSquared = sqrt(dx ^^ 2 + dy ^^ 2 + dz ^^ 2);<BR>
imd mag = dt / (dSquared * dSquared^^2);<BR>
<BR>
Around line 115. Give it a try... <BR>
<BR>
Il giorno gio, 24/11/2011 alle 22.37 -0500, bearophile ha scritto:
<BLOCKQUOTE TYPE=CITE>
<PRE>
This is the nbody benchmark of the Shootout site:
<A HREF="http://shootout.alioth.debian.org/u32/performance.php?test=nbody">http://shootout.alioth.debian.org/u32/performance.php?test=nbody</A>
The faster version is a Fortran one, probably thanks to vector operations that allow a better SIMD vectorization.
This is the C++ version:
<A HREF="http://shootout.alioth.debian.org/u32/program.php?test=nbody&lang=gpp&id=1">http://shootout.alioth.debian.org/u32/program.php?test=nbody&lang=gpp&id=1</A>
C++ version compiled with:
g++ -Ofast -fomit-frame-pointer -march=native -mfpmath=sse -msse3 --std=c++0x
An input parameter is n= 3_000_000 (but use a larger number if therun time is too much small, like 10 millions or more).
First D2 version (serial):
<A HREF="http://codepad.org/AdRSm2wP">http://codepad.org/AdRSm2wP</A>
Second D2 version, three times slower thanks to vector ops, more similar to the Fortran version:
<A HREF="http://codepad.org/7O3mz9en">http://codepad.org/7O3mz9en</A>
Is someone willing to take two (or more) timings using LDC 2 compiler (I have LDC1 only, beside DMD)? I'd like to know how much time it takes to run the first D version *compared* to the C++ version :-) If you time the second D2 version too, then it's better.
Bye and thank you,
bearophile
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>