shadow.h 1.7 KB

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