Noob questions about PPU SIMD setup

Investigation into how Linux on the PS3 might lead to homebrew development.

Moderators: cheriff, emoon

Post Reply
ffelagund
Posts: 14
Joined: Thu Mar 16, 2006 9:44 pm
Contact:

Noob questions about PPU SIMD setup

Post by ffelagund »

Hello,

I'm following IBM documents for Cell programming. Now I'm trying to compile some SIMD examples, but I'm totally lost for the next reasons:
My most inmediate problem: according with IBM docs, I have to use 'vector' type, and this type is totally unknown by the compiler. Also, I dont know what is the header file needed for the SIMD intrinsics (like vec_perm, vec_sums, etc)
The IBM document called: "Programming tutorial" from the Cell SDK 3.0 says the next: "You do not need to setup, to enter in a special mode, or to include a special header file".
Its obvious that this is not true, so, what should I do in order to use that types and intrinsics?

I'm running Yellow Dog 6 with the SDK 3.0, and this is exactly the code I'm trying to run:

Code: Select all

union SumArray
{
	int i[4];
	vector signed int v;
};

int vect_sum( unsigned char bytes[] )
{
	SumArray sum;
	vector unsigned char vbytes;
	vector unsigned int zero =(unsigned int){0};
	vbytes = vec_perm( vec_ld(0, bytes), vector_ld( 16, bytes), vector_lvsl(0, bytes) );
	sum.v = vec_sums( (vector signed int) vec4_sum4s( vbytes,zero), (vector signed int) zero);
	return sum.i[3];
}


int main()
{
	unsigned char bytes[16];
	for&#40;int i=0; i < 16; ++i &#41;
		bytes&#91;i&#93; = 2;

	int sum = vect_sum&#40; bytes &#41;;
	printf&#40; "\nLa suma es&#58; %d\n", sum &#41;;
       return 0;
&#125;
And this is the compile command:
ppu-g++ -c main.cpp -o main.o -fno-inline-functions -fmessage-length=0 -Wall -I./include -m64 -G0 -D_DEBUG -DPLATFORM_PS3 -g

With all this, I got errors like:
main.cpp|21|error: ISO C++ forbids declaration of 'vector' with no type|
main.cpp|29|error: 'vec_ld' was not declared in this scope|
main.cpp|29|error: 'vec_perm' was not declared in this scope|
etc.


Any clue will be appreciated :)
Regards,
Jacobo.
I dont know... flight casual!
IronPeter
Posts: 207
Joined: Mon Aug 06, 2007 12:46 am
Contact:

Post by IronPeter »

try <altivec.h> include.
ffelagund
Posts: 14
Joined: Thu Mar 16, 2006 9:44 pm
Contact:

Post by ffelagund »

Thanks,

That solved all my problems :) I think that IBM docs assume some knowledge about ppc programming and they ommited that requirements.

Also, it would help much in my development having a good reference for intrinsics (Cell docs from IBM dont talk too much about PPU VMX) Fo you know a good one site? (I found several on google, but I'd prefer one that talks specifically about Cell, not generic PPC)

Thanks :)
Jacobo.
I dont know... flight casual!
Post Reply