public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Toon Moene <toon@moene.org>
To: Sebastian Pop <sebpop@gmail.com>
Cc: gcc mailing list <gcc@gcc.gnu.org>
Subject: Graphite: Collapsing of loop nests ?
Date: Fri, 04 Dec 2009 15:41:00 -0000	[thread overview]
Message-ID: <4B192DA0.1080006@moene.org> (raw)

I wonder if Graphite can do this one (or is planned to be able to):

Another loop optimization that suggests itself
is the following, trying to eliminate unnecessary
loop constructs:
\begin{verbatim}
       SUBROUTINE SUB(A, B, C, N, M)
       REAL A(N, M), B(N, M), C(N, M)
       DO J = 1, M
          DO I = 1, N
             C(I, J) = A(I, J) + B(I, J)
          ENDDO
       ENDDO
       END
\end{verbatim}
If we could generate code that looks like what is
written below, we would have nothing but
{\em one} loop.
\begin{verbatim}
       DO K = 1, M*N
          C(K, 1) = A(K, 1) + B(K, 1)
       ENDDO
\end{verbatim}
In this case, this transformation can be done
because the tuple $(i,j)$ forms an induction
variable $i+n*(j-1)$ in its own right
(replaced by $k$ in the {\em collapsed} loop).

This is the latex from a set of slides I used in my LinuxExpo '99 talk 
(22nd of May 1999).

These loop nests result quite naturally from whole array expressions in 
Fortran.

Cheers,

-- 
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/
Progress of GNU Fortran: http://gcc.gnu.org/gcc-4.5/changes.html

             reply	other threads:[~2009-12-04 15:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-04 15:41 Toon Moene [this message]
2009-12-04 16:30 ` Sebastian Pop
2009-12-04 16:40   ` Tobias Grosser
2009-12-04 16:51     ` Sebastian Pop
2009-12-04 17:09       ` Cédric Bastoul
2009-12-04 18:20         ` Sebastian Pop
2009-12-04 18:55           ` Cédric Bastoul
     [not found]           ` <32759_1259952898_4B195B02_32759_483_1_470fef730912041054p34714c0dr7d9ff346ade8ac80@mail.gmail.com>
2009-12-14 15:14             ` Armin Größlinger
     [not found]     ` <25849_1259945451_4B193DEB_25849_852_1_cb9d34b20912040850u3da6ac10re723d862196516d1@mail.gmail.com>
2009-12-04 17:24       ` Tobias Grosser
2009-12-04 16:44   ` Cédric Bastoul
2009-12-04 16:55     ` Sebastian Pop

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=4B192DA0.1080006@moene.org \
    --to=toon@moene.org \
    --cc=gcc@gcc.gnu.org \
    --cc=sebpop@gmail.com \
    /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).