digitalmars.D - Re: dmd-x64
- alkor <alkor au.ru> Dec 23 2009
- =?ISO-8859-1?Q?=22J=E9r=F4me_M=2E_Berger=22?= <jeberger free.fr> Dec 23 2009
- alkor <alor au.ru> Dec 23 2009
- Travis Boucher <boucher.travis gmail.com> Dec 23 2009
- alkor <alkor au.ru> Dec 23 2009
- Travis Boucher <boucher.travis gmail.com> Dec 23 2009
maybe, i do something wrong, but for example:
$ cat main.d
int main () {
return 0;
}
$dmd -O -release -ofmain-dmd main.d
$gdc -O3 main.d -o main-gdc
$ ls -l main-dmd main-gdc
-rwxr-xr-x 1 alkor alkor 123439 Dec 23 14:06 main-dmd
-rwxr-xr-x 1 alkor alkor 609363 Dec 23 14:06 main-gdc
why the main-gdc in 5 time more then the main-dmd?
any test shows dmd superiorities over gdc (and gcc)
dmd rules :)
== Repost the article of Travis Boucher (boucher.travis gmail.com)
== Posted at 2009/12/23 04:48 to digitalmars.D
If you can't get gdc to generate optimized code, then you are using it
wrong.
Dec 23 2009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable alkor wrote:maybe, i do something wrong, but for example: =20 $ cat main.d int main () { return 0; } =20 $dmd -O -release -ofmain-dmd main.d $gdc -O3 main.d -o main-gdc $ ls -l main-dmd main-gdc -rwxr-xr-x 1 alkor alkor 123439 Dec 23 14:06 main-dmd -rwxr-xr-x 1 alkor alkor 609363 Dec 23 14:06 main-gdc =20 why the main-gdc in 5 time more then the main-dmd? =20
the gdc command line or use gdmd with the same options as dmd. Moreover, since you are trying to optimize for space rather than=20 performance, you should use -Os (or at least -O2) rather than -O3.any test shows dmd superiorities over gdc (and gcc) dmd rules :) =20
Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Dec 23 2009
oh no - both files aren't stripped
after strip a difference is 2,3 times
$ strip main-gdc main-dmd
$ ls -l main-dmd main-gdc
-rwxr-xr-x 1 alkor alkor 65088 Dec 23 16:44 main-dmd
-rwxr-xr-x 1 alkor alkor 155784 Dec 23 16:44 main-gdc
and main-gdc required libgcc_s.so.1
$ ldd main-gdc
linux-gate.so.1 => (0xffffe000)
libm.so.6 => /lib/libm.so.6 (0xb7ee7000)
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0xb7edc000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7ec4000)
libc.so.6 => /lib/libc.so.6 (0xb7d89000)
/lib/ld-linux.so.2 (0xb7f2d000)
--- the next test - math performance ---
module test.performance;
import std.stdio, std.random;
const int MAX = 10000000;
int main () {
int[] a = new int[MAX];
int[] b = new int[MAX];
double[] c = new double[MAX];
for (auto i=0; i< MAX; i++) {
a[i] = i | 0xa1c0;
b[i] = i | 0xbadbad;
}
for (auto i=0; i< MAX; i++) {
c[i] = (a[i] & 0x10) ? cast(double)a[i] * b[i] * b[i] : cast(double)a[i] *
a[i] * b[i];
}
writefln("init a[9555000] 0x%08X", a[9555000]);
writefln("init b[9555000] 0x%08X", b[9555000]);
writefln("init b[9555000] %f", c[9555000]);
return 0;
}
$ dmd -O -release -oftest-dmd test-performance.d && strip test-dmd
$ time ./test-dmd
init a[9555000] 0x0091EDF8
init b[9555000] 0x00BBDFBD
init b[9555000] 1449827528761239666688.000000
real 0m0.722s
user 0m0.552s
sys 0m0.168s
$ gdc -O3 test-performance.d -o test-gdc && strip test-gdc
$ time ./test-gdc
init a[9555000] 0x0091EDF8
init b[9555000] 0x00BBDFBD
init b[9555000] 1449827528761239666688.000000
real 0m0.786s
user 0m0.628s
sys 0m0.152s
so, dmd's code optimization rules
Walter made nice lang & good compiler - it's true
Jérôme M. Berger Wrote:
alkor wrote:
maybe, i do something wrong, but for example:
$ cat main.d
int main () {
return 0;
}
$dmd -O -release -ofmain-dmd main.d
$gdc -O3 main.d -o main-gdc
$ ls -l main-dmd main-gdc
-rwxr-xr-x 1 alkor alkor 123439 Dec 23 14:06 main-dmd
-rwxr-xr-x 1 alkor alkor 609363 Dec 23 14:06 main-gdc
why the main-gdc in 5 time more then the main-dmd?
the gdc command line or use gdmd with the same options as dmd.
Moreover, since you are trying to optimize for space rather than
performance, you should use -Os (or at least -O2) rather than -O3.
any test shows dmd superiorities over gdc (and gcc)
dmd rules :)
Jerome
--
mailto:jeberger free.fr
http://jeberger.free.fr
Jabber: jeberger jabber.fr
Dec 23 2009
alkor wrote:$ dmd -O -release -oftest-dmd test-performance.d && strip test-dmd $ gdc -O3 test-performance.d -o test-gdc && strip test-gdc so, dmd's code optimization rules Walter made nice lang & good compiler - it's true
Add -frelease to gdc (if you want a fair comparison), and look at the code generated rather then running a micro benchmark on something that takes a fraction of a second to run.
Dec 23 2009
thanks, w -frelease gdc makes a good result - faster then dmd's one & normal size Travis Boucher Wrote:alkor wrote:$ dmd -O -release -oftest-dmd test-performance.d && strip test-dmd $ gdc -O3 test-performance.d -o test-gdc && strip test-gdc so, dmd's code optimization rules Walter made nice lang & good compiler - it's true
Add -frelease to gdc (if you want a fair comparison), and look at the code generated rather then running a micro benchmark on something that takes a fraction of a second to run.
Dec 23 2009
alkor wrote:thanks, w -frelease gdc makes a good result - faster then dmd's one & normal size
Thats because -frelease removes certain array bounds checking code, assertion testing and I think a few other things.
Dec 23 2009








Travis Boucher <boucher.travis gmail.com>