starpu_scheduler.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. #ifndef __STARPU_SCHEDULER_H__
  17. #define __STARPU_SCHEDULER_H__
  18. #include <starpu.h>
  19. #include <starpu_config.h>
  20. #ifdef STARPU_HAVE_HWLOC
  21. #include <hwloc.h>
  22. #endif
  23. struct starpu_task;
  24. struct starpu_machine_topology_s {
  25. unsigned nworkers;
  26. #ifdef STARPU_HAVE_HWLOC
  27. hwloc_topology_t hwtopology;
  28. #else
  29. /* We maintain ABI compatibility with and without hwloc */
  30. void *dummy;
  31. #endif
  32. unsigned nhwcpus;
  33. unsigned nhwcudagpus;
  34. unsigned nhwopenclgpus;
  35. unsigned ncpus;
  36. unsigned ncudagpus;
  37. unsigned nopenclgpus;
  38. unsigned ngordon_spus;
  39. /* Where to bind workers ? */
  40. unsigned workers_bindid[STARPU_NMAXWORKERS];
  41. /* Which GPU(s) do we use for CUDA ? */
  42. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  43. /* Which GPU(s) do we use for OpenCL ? */
  44. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  45. };
  46. struct starpu_sched_policy_s {
  47. /* create all the queues */
  48. void (*init_sched)(struct starpu_machine_topology_s *, struct starpu_sched_policy_s *);
  49. /* cleanup method at termination */
  50. void (*deinit_sched)(struct starpu_machine_topology_s *, struct starpu_sched_policy_s *);
  51. /* some methods to manipulate the previous queue */
  52. int (*push_task)(struct starpu_task *);
  53. int (*push_prio_task)(struct starpu_task *);
  54. struct starpu_task *(*pop_task)(void);
  55. void (*post_exec_hook)(struct starpu_task *);
  56. /* Remove all available tasks from the scheduler (tasks are chained by
  57. * the means of the prev and next fields of the starpu_task
  58. * structure). */
  59. struct starpu_task *(*pop_every_task)(uint32_t where);
  60. /* name of the policy (optionnal) */
  61. const char *policy_name;
  62. /* description of the policy (optionnal) */
  63. const char *policy_description;
  64. };
  65. void starpu_worker_set_sched_condition(int workerid, pthread_cond_t *sched_cond, pthread_mutex_t *sched_mutex);
  66. #endif // __STARPU_SCHEDULER_H__