component_eager_calibration.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-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. #include <starpu_sched_component.h>
  17. #include <starpu_scheduler.h>
  18. static int eager_calibration_push_task(struct starpu_sched_component * component, struct starpu_task * task)
  19. {
  20. STARPU_ASSERT(component && task && starpu_sched_component_is_eager_calibration(component));
  21. STARPU_ASSERT(starpu_sched_component_can_execute_task(component,task));
  22. starpu_task_bundle_t bundle = task->bundle;
  23. int workerid;
  24. for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
  25. workerid != -1;
  26. workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
  27. {
  28. struct starpu_perfmodel_arch* archtype = starpu_worker_get_perf_archtype(workerid, component->tree->sched_ctx_id);
  29. int nimpl;
  30. for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
  31. {
  32. if(starpu_worker_can_execute_task(workerid,task,nimpl)
  33. || starpu_combined_worker_can_execute_task(workerid, task, nimpl))
  34. {
  35. double d;
  36. if(bundle)
  37. d = starpu_task_bundle_expected_length(bundle, archtype, nimpl);
  38. else
  39. d = starpu_task_expected_length(task, archtype, nimpl);
  40. if(isnan(d))
  41. {
  42. unsigned i;
  43. for (i = 0; i < component->nchildren; i++)
  44. {
  45. int idworker;
  46. for(idworker = starpu_bitmap_first(&component->children[i]->workers);
  47. idworker != -1;
  48. idworker = starpu_bitmap_next(&component->children[i]->workers, idworker))
  49. {
  50. if (idworker == workerid)
  51. {
  52. return starpu_sched_component_push_task(component,component->children[i],task);
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. return 1;
  61. }
  62. int starpu_sched_component_is_eager_calibration(struct starpu_sched_component * component)
  63. {
  64. return component->push_task == eager_calibration_push_task;
  65. }
  66. struct starpu_sched_component * starpu_sched_component_eager_calibration_create(struct starpu_sched_tree *tree, void *arg)
  67. {
  68. (void)arg;
  69. struct starpu_sched_component * component = starpu_sched_component_create(tree, "eager_calibration");
  70. component->push_task = eager_calibration_push_task;
  71. return component;
  72. }