parallel_task.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include <starpu.h>
  17. #include <common/config.h>
  18. #include <core/jobs.h>
  19. #include <core/task.h>
  20. #include <common/utils.h>
  21. #include <core/workers.h>
  22. #include <common/barrier.h>
  23. struct starpu_task *starpu_task_dup(struct starpu_task *task)
  24. {
  25. struct starpu_task *task_dup = (struct starpu_task *) malloc(sizeof(struct starpu_task));
  26. STARPU_ASSERT(task_dup);
  27. /* TODO perhaps this is a bit too much overhead and we should only copy
  28. * part of the structure ? */
  29. memcpy(task_dup, task, sizeof(struct starpu_task));
  30. return task_dup;
  31. }
  32. void starpu_parallel_task_barrier_init(struct starpu_task* task, int workerid)
  33. {
  34. /* The master needs to dispatch the task between the
  35. * different combined workers */
  36. struct _starpu_combined_worker *combined_worker = _starpu_get_combined_worker_struct(workerid);
  37. int worker_size = combined_worker->worker_size;
  38. struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
  39. j->task_size = worker_size;
  40. j->combined_workerid = workerid;
  41. j->active_task_alias_count = 0;
  42. //fprintf(stderr, "POP -> size %d best_size %d\n", worker_size, best_size);
  43. STARPU_PTHREAD_BARRIER_INIT(&j->before_work_barrier, NULL, worker_size);
  44. STARPU_PTHREAD_BARRIER_INIT(&j->after_work_barrier, NULL, worker_size);
  45. return;
  46. }