data_request.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 __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 callback_list {
  24. void (*callback_func)(void *);
  25. void *callback_arg;
  26. struct callback_list *next;
  27. };
  28. LIST_TYPE(starpu_data_request,
  29. starpu_spinlock_t lock;
  30. unsigned refcnt;
  31. starpu_data_handle handle;
  32. uint32_t src_node;
  33. uint32_t dst_node;
  34. uint32_t handling_node;
  35. starpu_access_mode mode;
  36. starpu_async_channel async_channel;
  37. unsigned completed;
  38. int retval;
  39. /* in case we have a chain of request (eg. for nvidia multi-GPU) */
  40. struct starpu_data_request_s *next_req[STARPU_MAXNODES];
  41. /* who should perform the next request ? */
  42. unsigned next_req_count;
  43. struct callback_list *callbacks;
  44. unsigned is_a_prefetch_request;
  45. #ifdef STARPU_USE_FXT
  46. unsigned com_id;
  47. #endif
  48. );
  49. /* Everyone that wants to access some piece of data will post a request.
  50. * Not only StarPU internals, but also the application may put such requests */
  51. LIST_TYPE(starpu_data_requester,
  52. /* what kind of access is requested ? */
  53. starpu_access_mode mode;
  54. /* applications may also directly manipulate data */
  55. unsigned is_requested_by_codelet;
  56. /* in case this is a codelet that will do the access */
  57. struct starpu_job_s *j;
  58. unsigned buffer_index;
  59. /* if this is more complicated ... (eg. application request)
  60. * NB: this callback is not called with the lock taken !
  61. */
  62. void (*ready_data_callback)(void *argcb);
  63. void *argcb;
  64. );
  65. void _starpu_init_data_request_lists(void);
  66. void _starpu_deinit_data_request_lists(void);
  67. void _starpu_post_data_request(starpu_data_request_t r, uint32_t handling_node);
  68. void _starpu_handle_node_data_requests(uint32_t src_node, unsigned may_alloc);
  69. void _starpu_handle_pending_node_data_requests(uint32_t src_node);
  70. void _starpu_handle_all_pending_node_data_requests(uint32_t src_node);
  71. int _starpu_check_that_no_data_request_exists(uint32_t node);
  72. starpu_data_request_t _starpu_create_data_request(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, uint32_t handling_node, starpu_access_mode mode, unsigned is_prefetch);
  73. starpu_data_request_t _starpu_search_existing_data_request(starpu_data_handle handle, uint32_t dst_node, starpu_access_mode mode);
  74. int _starpu_wait_data_request_completion(starpu_data_request_t r, unsigned may_alloc);
  75. void _starpu_data_request_append_callback(starpu_data_request_t r,
  76. void (*callback_func)(void *), void *callback_arg);
  77. #endif // __DATA_REQUEST_H__