Does GCC Graphite framework work?

1,148 views
Skip to first unread message

salvatore...@gmail.com

unread,
Feb 4, 2012, 4:41:44 AM2/4/12
to GCC GRAPHITE, tob...@grosser.es
Hi,

I'm trying to use -ftree-parallelize-loops=n option of GCC. I also
read the wiki http://gcc.gnu.org/wiki/AutoparRelated and the related
report Autopar's Performance. The report shows that the results are
promising if compared to openMP. So GCC can autoparallelize loops (at
least the simple cases shown in the wiki): it should divide loops into
chunks and execute them on different Cores/CPUs. The problem is that I
don't see any difference though. I'm using a simple example similar to
one provided by this discussion
http://groups.google.com/group/gnu.gcc.help/browse_thread/thread/4f582e60af3ecfbd?pli=1.

I'm under Ubuntu 11.10 64 bit and I used both gcc 4.6.1 installed from
repository and gcc 4.6.2 installed from source code with the Graphite
framework enabled.

gcc 4.6.1
[CODE]
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/
README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/
usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --
with-system-zlib --libexecdir=/usr/lib --without-included-gettext --
enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --
libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --
enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --
enable-objc-gc --disable-werror --with-arch-32=i686 --with-
tune=generic --enable-checking=release --build=x86_64-linux-gnu --
host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
[/CODE]

gcc 4.6.2 with ppl and cloog explicitly enabled
[CODE]
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc-4.6.2-optimized/libexec/gcc/x86_64-
unknown-linux-gnu/4.6.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /gcc-4.6.2/configure -v --enable-languages=c,c+
+,fortran --prefix=/opt/gcc-4.6.2-optimized --enable-shared --enable-
linker-build-id --enable-threads=posix --disable-werror --with-
arch=native --with-cpu=native --with-tune=native --enable-nls --
without-included-gettext --with-system-zlib --with-fpmath=avx --with-
ppl --with-cloog
Thread model: posix
gcc version 4.6.2 (GCC)
[/CODE]
I have tried with these compilation options:
gcc test-autoparallel.c -o test-autoparallel
gcc -ftree-parallelize-loops=2 test-autoparallel.c -o test-
autoparallel
gcc -ftree-parallelize-loops=2 -floop-parallelize-all test-
autoparallel.c -o test-autoparallel
but there are no differencies.

The source code is this:
[CODE]
#include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>

#define KILO 1000UL
#define MEGA 1000000UL
#define GIGA 1000000000UL
#define N 10*MEGA

double a[N], b[N], c[N];

void Initialize(double* a, double* b, double* c)
{
long int i, j;
// initialize the vector
for (i = 0; i < N; ++i)
{
a[i] = 1;
b[i] = N - 2;
c[i] = 0;
}
return;
}


// compute the dot product

void DotProduct(double* a, double* b, double* result, long int*
operations)
{
long int i;
double partial_result = 0;
for (i = 0; i < N; ++i)
{
partial_result += a[i] * b[i];
}
// number of operations 1 product 1 sum
*operations = 2 * N;
*result = partial_result;

return;
}

// simple operations
void Compute(double* a, double* b, double* c, long int* operations)
{
long int i;
for (i = 0; i < N; ++i)
{
c[i] = ((a[i] + b[i]) * (a[i] - b[i])) / (a[i] * a[i] + b[i] *
b[i] + a[i] * b[i]);
}
// number of operations 3 product 3 sum 1 difference 1 division
*operations = 8 * N;

return;
}

int main()
{
long int operations = 0;
double result = 0, dt = 0;

// time struct with two member second and microseconds
struct timeval tv0, tv1;

Initialize(a, b, c);

// take the current time
if (gettimeofday(&tv0, NULL) != 0)
printf("WARNING, get the time \n");

// do operation
//DotProduct(a, b, &result, &operations);
Compute(a, b, c, &operations);

// take the current time
if (gettimeofday(&tv1, NULL) != 0)
printf("WARNING, get the time \n");

// compute the time for the operation
dt = tv1.tv_sec - tv0.tv_sec + (double) (tv1.tv_usec -
tv0.tv_usec) / MEGA;

// print result
printf("%.3lf Gflops (%ld M operations in time %.3lf s), result:
%lf \n", (operations / dt) / GIGA, operations / MEGA, dt, result);

return 0;
}

[/CODE]

If I'm not wrong, the GCC can parallelize the function Compute while
the DotProduct cannot be parallelized a due to the shared variable
among the threads. Is it correct?

Thank you in advance

Best Regards

Salvatore

ismail akturk

unread,
Feb 5, 2012, 4:26:07 AM2/5/12
to gcc-gr...@googlegroups.com
Hi Salvatore,

Do you use -ftree-parallelize-loops flag along with -02 flag? If you
also want to enable cloog optimizations in Graphite, you can use the
following options:

gcc -O2 -fgraphite-cloog-opts -ftree-parallelize-loops=2
-floop-parallelize-all test-autoparallel.c

Ismail

Message has been deleted

Razya Ladelsky

unread,
Feb 6, 2012, 4:41:51 AM2/6/12
to salvatore...@gmail.com, GCC GRAPHITE, tob...@grosser.es
gcc-gr...@googlegroups.com wrote on 04/02/2012 11:41:44 AM:

Hi Salvatore,

I haven't tried parallelizing using graphite lately so I'm not sure
what shape the framework is at.
However, parallelizing without graphite should work just fine.

You should add -O2 or -O3 to the command line,

Try:
gcc -ftree-parallelize-loops=2 -O2 test-autoparallel.c -o
test-autoparallel

DotProduct is a reduction patten, and such pattern are supported by the
auto-parallelizer,
so basically DotProduct is parallelizable :)


Please let me know if you have more questions,
Thanks,
Razya

Razya Ladelsky

unread,
Feb 6, 2012, 4:44:00 AM2/6/12
to Anthony Falzone, gcc-gr...@googlegroups.com
gcc-gr...@googlegroups.com wrote on 05/02/2012 07:40:02 PM:

> From: Anthony Falzone <prop_...@live.com>
> To: gcc-gr...@googlegroups.com
> Date: 05/02/2012 07:40 PM
> Subject: Re: Does GCC Graphite framework work?
> Sent by: gcc-gr...@googlegroups.com
>

> I posted previously that Graphite does not seem to work and no one
> has been able to get it to work as of yet. I am using Windows
> however. Also, the -fgraphite-cloog-opts doesn't seem to work with
Cygwin.

Hey Anthony,
I haven't used graphite lately, so I'm not sure what shape the framework
is at.
If you need to auto parallelize, though,remember that you can also do it
without
using graphite.
Thanks,
Razya

Tobias Grosser

unread,
Feb 6, 2012, 4:56:21 AM2/6/12
to gcc-gr...@googlegroups.com, prop_...@live.com
On 02/05/2012 06:40 PM, Anthony Falzone wrote:
> I posted previously that Graphite does not seem to work and no one has
> been able to get it to work as of yet. I am using Windows however. Also,
> the -fgraphite-cloog-opts doesn't seem to work with Cygwin.

Hi Anthony,

to which post are you referring exactly? What does not work for you in
graphite? To my knowledge Sebastian put a lot of afford into graphite,
before he changed jobs. So the quality of the code is actually pretty good.

Cheers
Tobi

Message has been deleted

Tobias Grosser

unread,
Feb 6, 2012, 12:25:14 PM2/6/12
to gcc-gr...@googlegroups.com, Anthony Falzone, nemok...@gmail.com
On 02/06/2012 04:49 PM, Anthony Falzone wrote:
> Hi Tobias and Razya,
>
> I posted on the forum awhile back and both of you replied. It was in
> regards to my code called PROP_DESIGN. Razya helped me debug it some and
> basically GCC was saying all my loops were outer loops or something. I
> was hoping someone could use my code to debug GCC and see why it would
> not auto-parallelize the code. Absoft and Intel Fortran compilers can.
> You can see the Polyhedron Fortran benchmark results for MP_PROP_DESIGN.
>
> MP_PROP_DESIGN has since been renamed to PROP_DESIGN_MAPS. Also, I made
> several benchmarking versions of PROP_DESIGN. I have tried everything I
> can and as far as I can tell auto-parallelization in GCC does not work
> on Windows. Perhaps for certain codes, but definitely not for mine.

I would phrase this as 'auto-parallelization for your code on windows
does not work'. This is sad, but is not equivalent to GRAPHITE does not
work at all. Still it shows that the GRAPHITE autopar part can be
improved and for this, your code is a valuable test case. Especially, as
the intel compiler shows larger speedups. To auto parallelize with gcc I
would first try the classical autoparallelizer maintained by Razya.
Graphite also provides auto parallelization, but it is less tested. It
was developed as a proof of concept by Li Feng, a Google Summer of code
student, but misses the robustness needed for production environments.

To make it production quality your program is a good start, but an in
depth analysis is required to understand exactly what needs to be
improved here. Analyzing an entire program is a large task and even
though I would love to see it done, I have unfortunately not the time to
do this. In case you are interested I will be glad to guide you through
this.

In respect of Sebastian: He was full time employed to work on GCC and
now switched jobs. I am still maintaining graphite, but as I do it in my
spare time aside of my PhD, I have a lot less time. This means I need to
focus. I am currently focusing on blocking infrastructure issues like
moving graphite to an actual integer set library and
the introduction of a polyhedral optimizer based on the Pluto algorithm.
This will not make all your code run faster overnight, but provides a
powerful infrastructure that can help with this. If you want to step
inhere, you are more than welcome.

Cheers
Tobi

Message has been deleted

Tobias Grosser

unread,
Feb 8, 2012, 5:28:56 AM2/8/12
to Razya Ladelsky, salvatore...@gmail.com, GCC GRAPHITE

Hi,

I just tried this with a recent gcc 4.7 and it seems not to work for me.
Salvatore, did this work for you?

I think we should first try the normal autopar until we jump into
graphite land.

Tobi


razya ladelsky

unread,
Feb 8, 2012, 9:07:03 AM2/8/12
to gcc-gr...@googlegroups.com
Hi Anthony,
I remember that we got a little lost back then.
Let's start fresh:
Have you tried using autopar w/o graphite?
That is add -O2 -ftree-parallelize-loops=4 to the compilation command line.
Thanks,
Razya


On Mon, Feb 6, 2012 at 5:49 PM, Anthony Falzone <prop_...@live.com> wrote:
Hi Tobias and Razya,

I posted on the forum awhile back and both of you replied.  It was in regards to my code called PROP_DESIGN.  Razya helped me debug it some and basically GCC was saying all my loops were outer loops or something.  I was hoping someone could use my code to debug GCC and see why it would not auto-parallelize the code.  Absoft and Intel Fortran compilers can.  You can see the Polyhedron Fortran benchmark results for MP_PROP_DESIGN.

MP_PROP_DESIGN has since been renamed to PROP_DESIGN_MAPS.  Also, I made several benchmarking versions of PROP_DESIGN.  I have tried everything I can and as far as I can tell auto-parallelization in GCC does not work on Windows.  Perhaps for certain codes, but definitely not for mine.

The old post topics are:

Re: question about graphite auto-parallelization

and

MinGW, MinGW-w64, Cygwin Support

I posted on SourceForge originally as well.  PROP_DESIGN can be downloaded at http://propdesign.weebly.com/.

Tobias, I'm I to understand that Sebastian Pop developed Graphite and now no one is developing it?  If so, that could explain a lot.

Message has been deleted

salvatore...@gmail.com

unread,
Feb 8, 2012, 5:33:48 PM2/8/12
to GCC GRAPHITE
Hi Ismail,

no unfortunately it doesn't work for me.

Thank you

Best Regards

Salvatore

On Feb 5, 10:26 am, ismail akturk <ismailakt...@gmail.com> wrote:
> Hi Salvatore,
>
> Do you use -ftree-parallelize-loops flag along with -02 flag? If you
> also want to enable cloog optimizations in Graphite, you can use the
> following options:
>
> gcc -O2 -fgraphite-cloog-opts -ftree-parallelize-loops=2
> -floop-parallelize-all test-autoparallel.c
>
> Ismail
>
> On 02/04/2012 11:41 AM, salvatore.frand...@gmail.com wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm trying to use -ftree-parallelize-loops=n option of GCC. I also
> > read the wikihttp://gcc.gnu.org/wiki/AutoparRelatedand the related
> > report Autopar's Performance. The report shows that the results are
> > promising if compared to openMP. So GCC can autoparallelize loops (at
> > least the simple cases shown in the wiki): it should divide loops into
> > chunks and execute them on different Cores/CPUs. The problem is that I
> > don't see any difference though. I'm using a simple example similar to
> > one provided by this discussion
> >http://groups.google.com/group/gnu.gcc.help/browse_thread/thread/4f58....

salvatore...@gmail.com

unread,
Feb 8, 2012, 5:34:33 PM2/8/12
to GCC GRAPHITE
Hi Anthony,

yes I agree with you.

Best Regards

Salvatore

salvatore...@gmail.com

unread,
Feb 8, 2012, 5:36:46 PM2/8/12
to GCC GRAPHITE
Hi Razya,

the graphite framework does not work with the current (4.6.1) version
of GCC.
Ok you are right, the dot product can be auto-parallelized.

Thank you

Best Regards

Salvatore Frandina

On Feb 6, 10:41 am, Razya Ladelsky <RA...@il.ibm.com> wrote:
> gcc-gr...@googlegroups.comwrote on 04/02/2012 11:41:44 AM:
>
>
>
>
>
>
>
>
>
> > From: "salvatore.frand...@gmail.com" <salvatore.frand...@gmail.com>> To: GCC GRAPHITE <gcc-gr...@googlegroups.com>
> > Cc: tob...@grosser.es
> > Date: 04/02/2012 11:41 AM
> > Subject: Does GCC Graphite framework work?> Sent by:gcc-gr...@googlegroups.com
>
> > Hi,
>
> > I'm trying to use -ftree-parallelize-loops=n option of GCC. I also
> > read the wikihttp://gcc.gnu.org/wiki/AutoparRelatedand the related
Message has been deleted

Razya Ladelsky

unread,
Feb 9, 2012, 4:52:42 AM2/9/12
to Anthony Falzone, gcc-gr...@googlegroups.com
Hi Anthony,
There are testcases for autopar and graphite in the testsuite directory.
gcc/testsuite/gcc.dg/autopar/ - there are C testcases (autopar testcases)
gcc/testsuite/gcc.dg/graphite/ C testcases for graphite
gcc/testsuite/gfortran.dg/graphite/ - fortran testcases for graphite
gcc/libgomp/testsuite/libgomp.graphite/ - C cases (graphite+autopar
testcases)


gcc-gr...@googlegroups.com wrote on 09/02/2012 04:58:04 AM:

> From: Anthony Falzone <prop_...@live.com>
> To: gcc-gr...@googlegroups.com

> Date: 09/02/2012 04:58 AM
> Subject: Re: Does GCC Graphite framework work?
> Sent by: gcc-gr...@googlegroups.com
>

> Something that could help everyone a lot is a code that is known to
> work with autopar and one that is known to work with graphite. That
> way we can all rule out something has not been installed or
> configured properly. I personally need some Fortran codes for this.
> However, others may like C codes. I would think that there must be
> some test codes that people use when developing these tools.

Razya Ladelsky

unread,
Feb 9, 2012, 4:54:11 AM2/9/12
to Anthony Falzone, gcc-gr...@googlegroups.com
gcc-gr...@googlegroups.com wrote on 08/02/2012 07:41:55 PM:

> From: Anthony Falzone <prop_...@live.com>
> To: gcc-gr...@googlegroups.com
> Date: 08/02/2012 07:42 PM
> Subject: Re: Does GCC Graphite framework work?
> Sent by: gcc-gr...@googlegroups.com
>

> Hi Razya,
>
> Yes I have tried both ways and neither seems to work with PROP_DESIGN.


hi Anthony,
What exactly do you mean by 'does not work'?
What is your indication? did you check the dump files?

Thanks,
razya

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages