starpu_scheduler.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #endif
  29. unsigned nhwcpus;
  30. unsigned nhwcudagpus;
  31. unsigned nhwopenclgpus;
  32. unsigned ncpus;
  33. unsigned ncudagpus;
  34. unsigned nopenclgpus;
  35. unsigned ngordon_spus;
  36. /* Where to bind workers ? */
  37. unsigned workers_bindid[STARPU_NMAXWORKERS];
  38. /* Which GPU(s) do we use for CUDA ? */
  39. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  40. /* Which GPU(s) do we use for OpenCL ? */
  41. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  42. };
  43. struct starpu_sched_policy_s {
  44. /* create all the queues */
  45. void (*init_sched)(struct starpu_machine_topology_s *, struct starpu_sched_policy_s *);
  46. /* cleanup method at termination */
  47. void (*deinit_sched)(struct starpu_machine_topology_s *, struct starpu_sched_policy_s *);
  48. /* some methods to manipulate the previous queue */
  49. int (*push_task)(struct starpu_task *);
  50. int (*push_prio_task)(struct starpu_task *);
  51. struct starpu_task *(*pop_task)(void);
  52. /* returns the number of tasks that were retrieved
  53. * the function is reponsible for allocating the output but the driver
  54. * has to free it
  55. *
  56. * NB : this function is non blocking
  57. * */
  58. struct starpu_task_list *(*pop_every_task)(uint32_t where);
  59. /* name of the policy (optionnal) */
  60. const char *policy_name;
  61. /* description of the policy (optionnal) */
  62. const char *policy_description;
  63. };
  64. void starpu_worker_set_sched_condition(int workerid, pthread_cond_t *sched_cond, pthread_mutex_t *sched_mutex);
  65. #endif // __STARPU_SCHEDULER_H__