Original Post
I am doing an independent study titled "Parallel Programming on the Cell Processor" and one of the initial programs I have made is a program to approximate pi using the integration of the function 4/(1+x^2) between 0 and 1.
Now with 24 billion boxes between 0 and 1 and their area added together I get 7 decimal places of pi. That is not the problem.
The problem becomes that I have to do 2 billion divides per SPE on a double vector. These divides are terribly slow, I have tried using recipd2(1+x^2) * 4, I have tried just a straight division and it slows the program by 600%+.
Pseudo SPU Code
vec double four(4.0,4.0)
vec double one(1.0,1.0)
vec double result(0,0)
vec double tempResult
for(iterations)
tempResult = spu_mul(x,x)
tempResult = spu_add(one, tempResult)
tempResult = divd2(four, tempResult)
result = spu_add(result, tempResult)
double pi = result[0] + result[1]
DMA command send pi to PPU (which works)
exit
I was wondering if there is a way to get around the divide and are double divisions really that slow on the SPU?
Now with 24 billion boxes between 0 and 1 and their area added together I get 7 decimal places of pi. That is not the problem.
The problem becomes that I have to do 2 billion divides per SPE on a double vector. These divides are terribly slow, I have tried using recipd2(1+x^2) * 4, I have tried just a straight division and it slows the program by 600%+.
Pseudo SPU Code
vec double four(4.0,4.0)
vec double one(1.0,1.0)
vec double result(0,0)
vec double tempResult
for(iterations)
tempResult = spu_mul(x,x)
tempResult = spu_add(one, tempResult)
tempResult = divd2(four, tempResult)
result = spu_add(result, tempResult)
double pi = result[0] + result[1]
DMA command send pi to PPU (which works)
exit
I was wondering if there is a way to get around the divide and are double divisions really that slow on the SPU?