idle_policy.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011, 2012 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 "sc_hypervisor_policy.h"
  17. unsigned worker_belong_to_other_sched_ctx(unsigned sched_ctx, int worker)
  18. {
  19. unsigned *sched_ctxs = sc_hypervisor_get_sched_ctxs();
  20. int nsched_ctxs = sc_hypervisor_get_nsched_ctxs();
  21. int i;
  22. for(i = 0; i < nsched_ctxs; i++)
  23. if(sched_ctxs[i] != sched_ctx && starpu_sched_ctx_contains_worker(worker, sched_ctxs[i]))
  24. return 1;
  25. return 0;
  26. }
  27. void idle_handle_idle_cycle(unsigned sched_ctx, int worker)
  28. {
  29. if(sc_hypervisor_criteria_fulfilled(sched_ctx, worker))
  30. {
  31. if(worker_belong_to_other_sched_ctx(sched_ctx, worker))
  32. sc_hypervisor_remove_workers_from_sched_ctx(&worker, 1, sched_ctx, 1);
  33. else
  34. sc_hypervisor_policy_resize_to_unknown_receiver(sched_ctx, 0);
  35. }
  36. }
  37. struct sc_hypervisor_policy idle_policy =
  38. {
  39. .size_ctxs = NULL,
  40. .handle_poped_task = NULL,
  41. .handle_pushed_task = NULL,
  42. .handle_idle_cycle = idle_handle_idle_cycle,
  43. .handle_idle_end = NULL,
  44. .handle_post_exec_hook = NULL,
  45. .handle_submitted_job = NULL,
  46. .end_ctx = NULL,
  47. .init_worker = NULL,
  48. .custom = 0,
  49. .name = "idle"
  50. };