shadow.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011,2017 CNRS
  4. * Copyright (C) 2010-2011,2014 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. /* Perform replication of data on X and Y edges, to fold the domain on
  18. itself through mere replication of the source state. */
  19. /* TODO: rather use a dummy for loop, to assign the job to the threads that will work on it? */
  20. if (idy == 0)
  21. for (z = i-1 + idz; z < nz-(i-1); z += stepz)
  22. for (x = K + idx; x < nx-K; x += stepx)
  23. {
  24. unsigned index = x+z*ldz;
  25. ptr[index+(K-1)*ldy] = ptr[index+(ny-K-1)*ldy];
  26. ptr[index+(ny-K)*ldy] = ptr[index+K*ldy];
  27. }
  28. if (idx == 0)
  29. for (z = i-1 + idz; z < nz-(i-1); z += stepz)
  30. for (y = K + idy; y < ny-K; y += stepy)
  31. {
  32. unsigned index = y*ldy+z*ldz;
  33. ptr[(K-1)+index] = ptr[(nx-K-1)+index];
  34. ptr[(nx-K)+index] = ptr[K+index];
  35. }
  36. if (idx == 0 && idy == 0)
  37. for (z = i-1 + idz; z < nz-(i-1); z += stepz)
  38. {
  39. unsigned index = z*ldz;
  40. ptr[K-1+(K-1)*ldy+index] = ptr[(nx-K-1)+(ny-K-1)*ldy+index];
  41. ptr[(nx-K)+(K-1)*ldy+index] = ptr[K+(ny-K-1)*ldy+index];
  42. ptr[(K-1)+(ny-K)*ldy+index] = ptr[(nx-K-1)+K*ldy+index];
  43. ptr[(nx-K)+(ny-K)*ldy+index] = ptr[K+K*ldy+index];
  44. }