hotspotKernel.cl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. __kernel void hotspotOpt1(__global float *p, __global float* tIn, __global float *tOut, float sdc,
  2. int nx, int ny, int nz,
  3. float ce, float cw,
  4. float cn, float cs,
  5. float ct, float cb,
  6. float cc)
  7. {
  8. float amb_temp = 80.0;
  9. int i = get_global_id(0);
  10. int j = get_global_id(1);
  11. int c = i + j * nx;
  12. int xy = nx * ny;
  13. int W = (i == 0) ? c : c - 1;
  14. int E = (i == nx-1) ? c : c + 1;
  15. int N = (j == 0) ? c : c - nx;
  16. int S = (j == ny-1) ? c : c + nx;
  17. float temp1, temp2, temp3;
  18. temp1 = temp2 = tIn[c];
  19. temp3 = tIn[c+xy];
  20. tOut[c] = cc * temp2 + cw * tIn[W] + ce * tIn[E] + cs * tIn[S]
  21. + cn * tIn[N] + cb * temp1 + ct * temp3 + sdc * p[c] + ct * amb_temp;
  22. c += xy;
  23. W += xy;
  24. E += xy;
  25. N += xy;
  26. S += xy;
  27. for (int k = 1; k < nz-1; ++k) {
  28. temp1 = temp2;
  29. temp2 = temp3;
  30. temp3 = tIn[c+xy];
  31. tOut[c] = cc * temp2 + cw * tIn[W] + ce * tIn[E] + cs * tIn[S]
  32. + cn * tIn[N] + cb * temp1 + ct * temp3 + sdc * p[c] + ct * amb_temp;
  33. c += xy;
  34. W += xy;
  35. E += xy;
  36. N += xy;
  37. S += xy;
  38. }
  39. temp1 = temp2;
  40. temp2 = temp3;
  41. tOut[c] = cc * temp2 + cw * tIn[W] + ce * tIn[E] + cs * tIn[S]
  42. + cn * tIn[N] + cb * temp1 + ct * temp3 + sdc * p[c] + ct * amb_temp;
  43. return;
  44. }