data_request.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011 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. struct _starpu_spinlock 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. unsigned prefetch;
  41. int retval;
  42. /* The request will not actually be submitted until there remains
  43. * dependencies. */
  44. unsigned ndeps;
  45. /* in case we have a chain of request (eg. for nvidia multi-GPU) */
  46. struct starpu_data_request_s *next_req[STARPU_MAXNODES];
  47. /* who should perform the next request ? */
  48. unsigned next_req_count;
  49. struct callback_list *callbacks;
  50. #ifdef STARPU_USE_FXT
  51. unsigned com_id;
  52. #endif
  53. )
  54. /* Everyone that wants to access some piece of data will post a request.
  55. * Not only StarPU internals, but also the application may put such requests */
  56. LIST_TYPE(starpu_data_requester,
  57. /* what kind of access is requested ? */
  58. starpu_access_mode mode;
  59. /* applications may also directly manipulate data */
  60. unsigned is_requested_by_codelet;
  61. /* in case this is a codelet that will do the access */
  62. struct starpu_job_s *j;
  63. unsigned buffer_index;
  64. /* if this is more complicated ... (eg. application request)
  65. * NB: this callback is not called with the lock taken !
  66. */
  67. void (*ready_data_callback)(void *argcb);
  68. void *argcb;
  69. )
  70. void _starpu_init_data_request_lists(void);
  71. void _starpu_deinit_data_request_lists(void);
  72. void _starpu_post_data_request(starpu_data_request_t r, uint32_t handling_node);
  73. void _starpu_handle_node_data_requests(uint32_t src_node, unsigned may_alloc);
  74. void _starpu_handle_node_prefetch_requests(uint32_t src_node, unsigned may_alloc);
  75. void _starpu_handle_pending_node_data_requests(uint32_t src_node);
  76. void _starpu_handle_all_pending_node_data_requests(uint32_t src_node);
  77. int _starpu_check_that_no_data_request_exists(uint32_t node);
  78. starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle,
  79. struct starpu_data_replicate_s *src_replicate,
  80. struct starpu_data_replicate_s *dst_replicate,
  81. uint32_t handling_node,
  82. starpu_access_mode mode,
  83. unsigned ndeps,
  84. unsigned is_prefetch);
  85. int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_alloc);
  86. void _starpu_data_request_append_callback(starpu_data_request_t r,
  87. void (*callback_func)(void *), void *callback_arg);
  88. void _starpu_update_prefetch_status(starpu_data_request_t r);
  89. #endif // __DATA_REQUEST_H__