component_eager_calibration.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013 Inria
  4. * Copyright (C) 2014,2017 CNRS
  5. * Copyright (C) 2014-2015,2017-2018 Université de Bordeaux
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <starpu_sched_component.h>
  19. #include <starpu_scheduler.h>
  20. static int eager_calibration_push_task(struct starpu_sched_component * component, struct starpu_task * task)
  21. {
  22. STARPU_ASSERT(component && task && starpu_sched_component_is_eager_calibration(component));
  23. STARPU_ASSERT(starpu_sched_component_can_execute_task(component,task));
  24. starpu_task_bundle_t bundle = task->bundle;
  25. int workerid;
  26. for(workerid = starpu_bitmap_first(component->workers_in_ctx);
  27. workerid != -1;
  28. workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
  29. {
  30. struct starpu_perfmodel_arch* archtype = starpu_worker_get_perf_archtype(workerid, component->tree->sched_ctx_id);
  31. int nimpl;
  32. for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
  33. {
  34. if(starpu_worker_can_execute_task(workerid,task,nimpl)
  35. || starpu_combined_worker_can_execute_task(workerid, task, nimpl))
  36. {
  37. double d;
  38. if(bundle)
  39. d = starpu_task_bundle_expected_length(bundle, archtype, nimpl);
  40. else
  41. d = starpu_task_expected_length(task, archtype, nimpl);
  42. if(isnan(d))
  43. {
  44. unsigned i;
  45. for (i = 0; i < component->nchildren; i++)
  46. {
  47. int idworker;
  48. for(idworker = starpu_bitmap_first(component->children[i]->workers);
  49. idworker != -1;
  50. idworker = starpu_bitmap_next(component->children[i]->workers, idworker))
  51. {
  52. if (idworker == workerid)
  53. {
  54. return starpu_sched_component_push_task(component,component->children[i],task);
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. return 1;
  63. }
  64. int starpu_sched_component_is_eager_calibration(struct starpu_sched_component * component)
  65. {
  66. return component->push_task == eager_calibration_push_task;
  67. }
  68. struct starpu_sched_component * starpu_sched_component_eager_calibration_create(struct starpu_sched_tree *tree, void *arg)
  69. {
  70. (void)arg;
  71. struct starpu_sched_component * component = starpu_sched_component_create(tree, "eager_calibration");
  72. component->push_task = eager_calibration_push_task;
  73. return component;
  74. }