shadow.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2009-2010 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. unsigned index = x+z*ldz;
  23. ptr[index+(K-1)*ldy] = ptr[index+(ny-K-1)*ldy];
  24. ptr[index+(ny-K)*ldy] = ptr[index+K*ldy];
  25. }
  26. if (idx == 0)
  27. for (z = i-1 + idz; z < nz-(i-1); z += stepz)
  28. for (y = K + idy; y < ny-K; y += stepy) {
  29. unsigned index = y*ldy+z*ldz;
  30. ptr[(K-1)+index] = ptr[(nx-K-1)+index];
  31. ptr[(nx-K)+index] = ptr[K+index];
  32. }
  33. if (idx == 0 && idy == 0)
  34. for (z = i-1 + idz; z < nz-(i-1); z += stepz) {
  35. unsigned index = z*ldz;
  36. ptr[K-1+(K-1)*ldy+index] = ptr[(nx-K-1)+(ny-K-1)*ldy+index];
  37. ptr[(nx-K)+(K-1)*ldy+index] = ptr[K+(ny-K-1)*ldy+index];
  38. ptr[(K-1)+(ny-K)*ldy+index] = ptr[(nx-K-1)+K*ldy+index];
  39. ptr[(nx-K)+(ny-K)*ldy+index] = ptr[K+K*ldy+index];
  40. }