queues.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (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 __QUEUES_H__
  17. #define __QUEUES_H__
  18. #include <pthread.h>
  19. #include <core/jobs.h>
  20. #include <core/policies/sched_policy.h>
  21. enum starpu_perf_archtype;
  22. struct jobq_s {
  23. /* a pointer to some queue structure */
  24. void *queue;
  25. /* some methods to manipulate the previous queue */
  26. int (*push_task)(struct jobq_s *, job_t);
  27. int (*push_prio_task)(struct jobq_s *, job_t);
  28. struct job_s* (*pop_task)(struct jobq_s *);
  29. /* returns the number of tasks that were retrieved
  30. * the function is reponsible for allocating the output but the driver
  31. * has to free it
  32. *
  33. * NB : this function is non blocking
  34. * */
  35. struct job_list_s *(*pop_every_task)(struct jobq_s *, uint32_t);
  36. /* what are the driver that may pop job from that queue ? */
  37. uint32_t who;
  38. /* this is only relevant if there is a single worker per queue */
  39. uint32_t memory_node;
  40. enum starpu_perf_archtype arch;
  41. float alpha;
  42. /* for performance analysis purpose */
  43. double total_computation_time;
  44. double total_communication_time;
  45. double total_computation_time_error;
  46. /* in case workers are blocked on the queue, signaling on that
  47. condition must unblock them, even if there is no available task */
  48. pthread_cond_t activity_cond;
  49. pthread_mutex_t activity_mutex;
  50. };
  51. struct machine_config_s;
  52. void setup_queues(void (*init_queue_design)(void),
  53. struct jobq_s *(*func_init_queue)(void),
  54. struct machine_config_s *config);
  55. struct jobq_s *get_local_queue(void);
  56. void set_local_queue(struct jobq_s *jobq);
  57. #endif // __QUEUES_H__