gcc -O3 -maltivec -std=c89 -lpthread -o altivec_smp_bench altivec_smp_bench.c
altivec_smp_bench.c: In function ‘thread_func’:
altivec_smp_bench.c:31:5: error: ‘vector’ undeclared (first use in this function)
31 | vector float va, vb, vc1, vc2, vc3;
| ^~~~~~
altivec_smp_bench.c:31:5: note: each undeclared identifier is reported only once for each function it appears in
altivec_smp_bench.c:31:11: error: expected ‘;’ before ‘float’
31 | vector float va, vb, vc1, vc2, vc3;
| ^~~~~~
| ;
altivec_smp_bench.c:35:13: error: ‘va’ undeclared (first use in this function)
35 | va = vec_ld(0, &arg->a[i]);
| ^~
altivec_smp_bench.c:36:13: error: ‘vb’ undeclared (first use in this function)
36 | vb = vec_ld(0, &arg->b[i]);
| ^~
altivec_smp_bench.c:37:13: error: ‘vc1’ undeclared (first use in this function)
37 | vc1 = vec_add(va, vb);
| ^~~
altivec_smp_bench.c:38:13: error: ‘vc2’ undeclared (first use in this function)
38 | vc2 = vec_mul(vc1, vb);
| ^~~
altivec_smp_bench.c:39:13: error: ‘vc3’ undeclared (first use in this function)
39 | vc3 = vec_sub(vc2, va);
| ^~~
# Linux PPC64 LE / BE, PPC32 BE
gcc -O3 -maltivec -std=c89 -lpthread -o altivec_smp_bench altivec_smp_bench.c
# Mac OS X Tiger/Leopard PPC
gcc -O3 -faltivec -std=c89 -lpthread -o altivec_smp_bench altivec_smp_bench.c
cc -O3 -maltivec -std=c89 -lpthread -o altivec_smp_bench altivec_smp_bench.c
altivec_smp_bench.c: In function ‘main’:
altivec_smp_bench.c:96:14: error: expected ‘;’ at end of input
96 | targs
| ^
| ;
altivec_smp_bench.c:96:9: error: expected declaration or statement at end of input
96 | targs
| ^~~~~
altivec_smp_bench.c:96:9: error: expected declaration or statement at end of input
gcc -O3 -faltivec -std=c89 -lpthread -o altivec_smp_bench altivec_smp_bench.c
In file included from altivec_smp_bench.c:6:
/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include/altivec.h:44:2: warning: #warning Ignoring <altivec.h> because "-faltivec" specified
altivec_smp_bench.c: In function 'thread_func':
altivec_smp_bench.c:40: error: AltiVec argument passed to unprototyped function
altivec_smp_bench.c: In function 'main':
altivec_smp_bench.c:65: error: '_SC_NPROCESSORS_ONLN' undeclared (first use in this function)
altivec_smp_bench.c:65: error: (Each undeclared identifier is reported only once
altivec_smp_bench.c:65: error: for each function it appears in.)
This version seems to work with OS X beating out LinxPPC64LE by quite a bit, about 2.5x.
I'm adding optimized code for VSX for the Power9, sadly VSX does not exist on the G4/G5, but it will give us some idea of how it works with Qemu-system-ppc64 on the pseries with -cpu power9.