data_request.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #ifndef __DATA_REQUEST_H__
  18. #define __DATA_REQUEST_H__
  19. #include <semaphore.h>
  20. #include <datawizard/coherency.h>
  21. #include <datawizard/copy_driver.h>
  22. #include <common/list.h>
  23. #include <common/starpu_spinlock.h>
  24. struct starpu_data_replicate_s;
  25. struct callback_list {
  26. void (*callback_func)(void *);
  27. void *callback_arg;
  28. struct callback_list *next;
  29. };
  30. LIST_TYPE(starpu_data_request,
  31. starpu_spinlock_t lock;
  32. unsigned refcnt;
  33. starpu_data_handle handle;
  34. struct starpu_data_replicate_s *src_replicate;
  35. struct starpu_data_replicate_s *dst_replicate;
  36. uint32_t handling_node;
  37. starpu_access_mode mode;
  38. struct starpu_async_channel async_channel;
  39. unsigned completed;
  40. int retval;
  41. /* The request will not actually be submitted until there remains
  42. * dependencies. */
  43. unsigned ndeps;
  44. /* in case we have a chain of request (eg. for nvidia multi-GPU) */
  45. struct starpu_data_request_s *next_req[STARPU_MAXNODES];
  46. /* who should perform the next request ? */
  47. unsigned next_req_count;
  48. struct callback_list *callbacks;
  49. #ifdef STARPU_USE_FXT
  50. unsigned com_id;
  51. #endif
  52. );
  53. /* Everyone that wants to access some piece of data will post a request.
  54. * Not only StarPU internals, but also the application may put such requests */
  55. LIST_TYPE(starpu_data_requester,
  56. /* what kind of access is requested ? */
  57. starpu_access_mode mode;
  58. /* applications may also directly manipulate data */
  59. unsigned is_requested_by_codelet;
  60. /* in case this is a codelet that will do the access */
  61. struct starpu_job_s *j;
  62. unsigned buffer_index;
  63. /* if this is more complicated ... (eg. application request)
  64. * NB: this callback is not called with the lock taken !
  65. */
  66. void (*ready_data_callback)(void *argcb);
  67. void *argcb;
  68. );
  69. void _starpu_init_data_request_lists(void);
  70. void _starpu_deinit_data_request_lists(void);
  71. void _starpu_post_data_request(starpu_data_request_t r, uint32_t handling_node);
  72. void _starpu_handle_node_data_requests(uint32_t src_node, unsigned may_alloc);
  73. void _starpu_handle_pending_node_data_requests(uint32_t src_node);
  74. void _starpu_handle_all_pending_node_data_requests(uint32_t src_node);
  75. int _starpu_check_that_no_data_request_exists(uint32_t node);
  76. starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle,
  77. struct starpu_data_replicate_s *src_replicate,
  78. struct starpu_data_replicate_s *dst_replicate,
  79. uint32_t handling_node,
  80. starpu_access_mode mode,
  81. unsigned ndeps);
  82. int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_alloc);
  83. void _starpu_data_request_append_callback(starpu_data_request_t r,
  84. void (*callback_func)(void *), void *callback_arg);
  85. #endif // __DATA_REQUEST_H__