tensor_opencl_kernel.cl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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. __kernel void tensor_opencl(__global int *tensor,
  17. int nx, int ny, int nz, int nt,
  18. int ldy, int ldz, int ldt,
  19. int factor, __global int *err)
  20. {
  21. const int id = get_global_id(0);
  22. if (id > 0)
  23. return;
  24. unsigned int i, j, k, l;
  25. int val = 0;
  26. for (l = 0; l < nt; l++)
  27. {
  28. for (k = 0; k < nz; k++)
  29. {
  30. for (j = 0; j < ny; j++)
  31. {
  32. for (i = 0; i < nx; i++)
  33. {
  34. if (tensor[(l*ldt)+(k*ldz)+(j*ldy)+i] != factor * val)
  35. {
  36. *err = 1;
  37. return;
  38. }
  39. else
  40. {
  41. tensor[(l*ldt)+(k*ldz)+(j*ldy)+i] *= -1;
  42. val++;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }