rzm@n289:~/gcc/gcc-4.4-20090227-obj,0> gcc -ftree-parallelize-loops=2 -o test2 test2.c
rzm@n289:~/gcc/gcc-4.4-20090227-obj,0> ./test2
0.655 Gflops (1400000000 ops in 2.14 s), result: 0.000000 600000017.000000
rzm@n289:~/gcc/gcc-4.4-20090227-obj,0> gcc -ftree-parallelize-loops=16 -o test2 test2.c
rzm@n289:~/gcc/gcc-4.4-20090227-obj,0> ./test2
0.651 Gflops (1400000000 ops in 2.15 s), result: 0.000000 600000017.000000
I'd love to see any example showing that this option really works.
My test program:
#include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
#define MEGA 1000000UL
#define GIGA 1000000000UL
#define N (100*MEGA)
double a[N], b[N], c[N];
int main() {
long int i, ops;
double s = 0, dt;
struct timeval tv0, tv1;
for (i=0; i < N; i++) {
a[i] = 5;
}
for (i=0; i < N; i++) {
b[i] = N - 6;
}
gettimeofday(&tv0, NULL);
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] + a[i] + b[i] + a[i]/(1+b[i]);
}
gettimeofday(&tv1, NULL);
dt = tv1.tv_sec - tv0.tv_sec + (tv1.tv_usec - tv0.tv_usec)/1000000.0;
ops = 14*N;
printf("%.3lf Gflops (%ld ops in %.2lf s), result: %lf %lf\n", ops/dt/GIGA, ops, dt, s, c[N-1]);
exit(0);
}
The compilers checked:
rzm@n289:~/gcc/gcc-4.4-20090227-obj,0> gcc -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.2/work/gcc-4.3.2/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.3.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-cld --disable-libgcj --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.2 p1.0'
Thread model: posix
gcc version 4.3.2 (Gentoo 4.3.2 p1.0)
rzm@n289:~/gcc/gcc-4.4-20090227-obj,0> gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.4-20090227/configure --prefix=/opt/gcc-4.4 --with-mpfr=/opt/mpfr-2.4.1 --with-ppl=/opt/ppl-0.10 --with-cloog=/opt/cloog-ppl-0.15
Thread model: posix
gcc version 4.4.0 20090227 (experimental) (GCC)
R.
--
Jeżeli upadnie cywilizacja zachodnia, to będzie szansa na odbudowę cywilizacji
chrześcijańskiej. (dr Stanisław Krajski, Radio Maryja, 10 X 2001)