public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Reducing compilation memory usage
@ 2008-01-17 19:10 Alejandro Pulver
  2008-01-18  6:20 ` John (Eljay) Love-Jensen
  0 siblings, 1 reply; 14+ messages in thread
From: Alejandro Pulver @ 2008-01-17 19:10 UTC (permalink / raw)
  To: gcc-help

[-- 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 --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-01-19  3:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-17 19:10 Reducing compilation memory usage Alejandro Pulver
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

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).