forkmode.c 1.4 KB

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