From: Alejandro Pulver <alepulver@FreeBSD.org>
To: gcc-help@gcc.gnu.org
Subject: Reducing compilation memory usage
Date: Thu, 17 Jan 2008 19:10:00 -0000 [thread overview]
Message-ID: <20080117001343.6c6b79d7@deimos.mars.bsd> (raw)
[-- Attachment #1: Type: text/plain, Size: 2145 bytes --]
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++ = w->id;
if (--alive_cnt < 2)goto out; w->prev->next = w->next;
w->next->prev = w->prev;
cycles -= cycles / alive_cnt;
}w = w->next;
ip = *w->head;if (++w->head == queue_end)
w->head = 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 187 bytes --]
next reply other threads:[~2008-01-17 2:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-17 19:10 Alejandro Pulver [this message]
2008-01-18 6:20 ` John (Eljay) Love-Jensen
2008-01-18 6:27 ` Alejandro Pulver
2008-01-18 8:22 ` John (Eljay) Love-Jensen
2008-01-18 10:56 ` Alejandro Pulver
2008-01-18 14:12 ` Tony Wetmore
2008-01-18 16:00 ` Alejandro Pulver
2008-01-19 3:49 ` Andrew Haley
2008-01-20 11:44 ` Alejandro Pulver
2008-01-20 13:19 ` Tony Wetmore
2008-01-20 18:35 ` Andrew Haley
2008-01-20 19:08 ` Tom St Denis
2008-01-21 1:25 ` Alejandro Pulver
2008-01-18 14:40 ` John (Eljay) Love-Jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080117001343.6c6b79d7@deimos.mars.bsd \
--to=alepulver@freebsd.org \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).