From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25880 invoked by alias); 17 Jan 2008 02:14:36 -0000 Received: (qmail 25768 invoked by uid 22791); 17 Jan 2008 02:14:35 -0000 X-Spam-Check-By: sourceware.org Received: from relay00.pair.com (HELO relay00.pair.com) (209.68.5.9) by sourceware.org (qpsmtpd/0.31) with SMTP; Thu, 17 Jan 2008 02:14:10 +0000 Received: (qmail 72907 invoked by uid 0); 17 Jan 2008 02:14:08 -0000 Received: from unknown (HELO deimos.mars.bsd) (unknown) by unknown with SMTP; 17 Jan 2008 02:14:08 -0000 X-pair-Authenticated: 200.127.63.61 Date: Thu, 17 Jan 2008 19:10:00 -0000 From: Alejandro Pulver To: gcc-help@gcc.gnu.org Subject: Reducing compilation memory usage Message-ID: <20080117001343.6c6b79d7@deimos.mars.bsd> X-Mailer: Claws Mail 3.0.2 (GTK+ 2.12.3; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/346xOi5xk=W1M_SbQKpm92z"; protocol="application/pgp-signature"; micalg=PGP-SHA1 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg00155.txt.bz2 --Sig_/346xOi5xk=W1M_SbQKpm92z Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-length: 2110 Hello. There is a Core War simulator (an interpreter for a minimalistic machine, called MARS, with a language named redcode) called fmars (http://www.v-lo.krakow.pl/~michal/fmars.html), which uses computed gotos to achieve very good performance. The original version only uses a subset of the available redcode instructions (~250), instead of the full set (~8000). The author told me GCC dumped core if trying to use all of them (I don't remember if he was referring to 2.95 or 3.3). I decided to try with GCC 4 (4.2.3 20071219 prerelease and 4.3.0 20080111 experimental), and it builds (both) without optimizations (-O0), but runs twice as slower than the reduced fmars built with -O2. Version 3.4.6 (20060305) runs out of memory (with and without optimizations), as 4.x does even with -O1. I have 2GB of RAM (and allowed processes to use it). The strange thing is that when looking at options enabled at different -O levels (trying to remove the ones that were using more memory), ended up with a GCC 4.2.3 command-line that specified exactly all the options enabled by -O2 (as listed in the manpage), and built. But ran at the same speed as without them. The source file is a function with the ~250/~8000 cases like this one (they are generated by an intermediate program): dat_f_immediate_direct: {if (!--w->nprocs) { *death_tab++ =3D w->id; if (--alive_cnt < 2)goto out; w->prev->next =3D w->next; w->next->prev =3D w->prev; cycles -=3D cycles / alive_cnt; }w =3D w->next; ip =3D *w->head;if (++w->head =3D=3D queue_end) w->head =3D queue_start;if (!--cycles) goto out; goto *ip->i;} So my question is, what optimizations options can I use in this file without using too much memory (I've read the docs and tried with various ones, but was annoyed about the fact that using equivalent -f* options worked without effect but -O/-O2 didn't)? If more information is needed, please ask. Also please CC me as I'm not subscribed. I'm using FreeBSD 6.2 (with mentioned GCC 3.4.6 as base compiler). Thanks and Best Regards, Ale --Sig_/346xOi5xk=W1M_SbQKpm92z Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc Content-length: 187 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHjsfniV05EpRcP2ERArtMAKCtp3UN/Z0Vsg/iQaA2GrVTrwPl3QCfXJhy 6kmd/lwBBvNac6sZHnMBuAI= =b2HQ -----END PGP SIGNATURE----- --Sig_/346xOi5xk=W1M_SbQKpm92z--