Peterp

Java Code to GPU

Discussion created by Peterp on Mar 30, 2009

Hi,

i want to convert the following code to Brook+, is it possible?

 

 

 

 



 

 

for (int k = 0; k < MAX; k++)

{

for (int j = 0; j < MAX-1; j++)

{

Direction d0 = data

[k] [j];

Direction d1 = data

[k] [j+1];

double fr = speed * (d1.r - d0.r);

d0.Fr += fr;

d1.Fr -= fr;

}

}

 

I'm just reading the ATI Streaming Guide but i'm note sure about how to index the stream correct:

 

 

kernel void speed(int width, float a[], out float c[])

{

int index = instance().x;

float p1 = a[index];

float p2 = a[index+1];

float diff = 2.0f * (p2-p1);

c[index] = p1+diff;

c[index+1] = p2-diff;

}



 







Outcomes