how to calculate a parallel product in ispc

54 views Asked by At

the following code does not work because ISPC refuses to compile a function that returns a varying variable from an exported function. Is there any way to do this? Manually in AVX I would calculate products in parallel, then compute the products of all the pieces. The change in the order of the multiplies will change the answer, which perhaps is why ISPC is so nervous about this.

export double prod(uniform double a, uniform double b, uniform int n) {
  uniform double dx = (b-a)/n;

  double prod = 1;
  double x = a;
  for (int i = 0; i < n; i++, x += dx) {
    prod *= x;
  }
  return prod;
}
0

There are 0 answers