forkmode.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013 Centre National de la Recherche Scientifique
  4. * Copyright (C) 2010-2013 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. //! [To be included. You should update doxygen if you see this text.]
  18. void scal_cpu_func(void *buffers[], void *_args)
  19. {
  20. unsigned i;
  21. float *factor = _args;
  22. struct starpu_vector_interface *vector = buffers[0];
  23. unsigned n = STARPU_VECTOR_GET_NX(vector);
  24. float *val = (float *)STARPU_VECTOR_GET_PTR(vector);
  25. #pragma omp parallel for num_threads(starpu_combined_worker_get_size())
  26. for (i = 0; i < n; i++)
  27. val[i] *= *factor;
  28. }
  29. static struct starpu_codelet cl =
  30. {
  31. .modes = { STARPU_RW },
  32. .where = STARPU_CPU,
  33. .type = STARPU_FORKJOIN,
  34. .max_parallelism = INT_MAX,
  35. .cpu_funcs = {scal_cpu_func, NULL},
  36. .cpu_funcs_name = {"scal_cpu_func", NULL},
  37. .nbuffers = 1,
  38. };
  39. //! [To be included. You should update doxygen if you see this text.]