data_request.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 __DATA_REQUEST_H__
  17. #define __DATA_REQUEST_H__
  18. #include <semaphore.h>
  19. #include <datawizard/coherency.h>
  20. #include <datawizard/copy_driver.h>
  21. #include <common/list.h>
  22. #include <common/starpu_spinlock.h>
  23. struct starpu_data_replicate_s;
  24. struct callback_list {
  25. void (*callback_func)(void *);
  26. void *callback_arg;
  27. struct callback_list *next;
  28. };
  29. LIST_TYPE(starpu_data_request,
  30. starpu_spinlock_t lock;
  31. unsigned refcnt;
  32. starpu_data_handle handle;
  33. struct starpu_data_replicate_s *src_replicate;
  34. struct starpu_data_replicate_s *dst_replicate;
  35. uint32_t handling_node;
  36. starpu_access_mode mode;
  37. starpu_async_channel async_channel;
  38. unsigned completed;
  39. int retval;
  40. /* The request will not actually be submitted until there remains
  41. * dependencies. */
  42. unsigned ndeps;
  43. /* in case we have a chain of request (eg. for nvidia multi-GPU) */
  44. struct starpu_data_request_s *next_req[STARPU_MAXNODES];
  45. /* who should perform the next request ? */
  46. unsigned next_req_count;
  47. struct callback_list *callbacks;
  48. unsigned is_a_prefetch_request;
  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. unsigned is_prefetch);
  83. starpu_data_request_t _starpu_search_existing_data_request(struct starpu_data_replicate_s *replicate, starpu_access_mode mode);
  84. int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_alloc);
  85. void _starpu_data_request_append_callback(starpu_data_request_t r,
  86. void (*callback_func)(void *), void *callback_arg);
  87. #endif // __DATA_REQUEST_H__