data_request.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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;
  25. struct _starpu_callback_list
  26. {
  27. void (*callback_func)(void *);
  28. void *callback_arg;
  29. struct _starpu_callback_list *next;
  30. };
  31. LIST_TYPE(_starpu_data_request,
  32. struct _starpu_spinlock lock;
  33. unsigned refcnt;
  34. starpu_data_handle_t handle;
  35. struct _starpu_data_replicate *src_replicate;
  36. struct _starpu_data_replicate *dst_replicate;
  37. uint32_t handling_node;
  38. enum starpu_access_mode mode;
  39. struct _starpu_async_channel async_channel;
  40. unsigned completed;
  41. unsigned prefetch;
  42. int retval;
  43. /* The request will not actually be submitted until there remains
  44. * dependencies. */
  45. unsigned ndeps;
  46. /* in case we have a chain of request (eg. for nvidia multi-GPU) */
  47. struct _starpu_data_request *next_req[STARPU_MAXNODES];
  48. /* who should perform the next request ? */
  49. unsigned next_req_count;
  50. struct _starpu_callback_list *callbacks;
  51. #ifdef STARPU_USE_FXT
  52. unsigned com_id;
  53. #endif
  54. )
  55. /* Everyone that wants to access some piece of data will post a request.
  56. * Not only StarPU internals, but also the application may put such requests */
  57. LIST_TYPE(_starpu_data_requester,
  58. /* what kind of access is requested ? */
  59. enum starpu_access_mode mode;
  60. /* applications may also directly manipulate data */
  61. unsigned is_requested_by_codelet;
  62. /* in case this is a codelet that will do the access */
  63. struct _starpu_job *j;
  64. unsigned buffer_index;
  65. /* if this is more complicated ... (eg. application request)
  66. * NB: this callback is not called with the lock taken !
  67. */
  68. void (*ready_data_callback)(void *argcb);
  69. void *argcb;
  70. )
  71. void _starpu_init_data_request_lists(void);
  72. void _starpu_deinit_data_request_lists(void);
  73. void _starpu_post_data_request(struct _starpu_data_request *r, uint32_t handling_node);
  74. void _starpu_handle_node_data_requests(uint32_t src_node, unsigned may_alloc);
  75. void _starpu_handle_node_prefetch_requests(uint32_t src_node, unsigned may_alloc);
  76. void _starpu_handle_pending_node_data_requests(uint32_t src_node);
  77. void _starpu_handle_all_pending_node_data_requests(uint32_t src_node);
  78. int _starpu_check_that_no_data_request_exists(uint32_t node);
  79. struct _starpu_data_request *_starpu_create_data_request(starpu_data_handle_t handle,
  80. struct _starpu_data_replicate *src_replicate,
  81. struct _starpu_data_replicate *dst_replicate,
  82. uint32_t handling_node,
  83. enum starpu_access_mode mode,
  84. unsigned ndeps,
  85. unsigned is_prefetch);
  86. int _starpu_wait_data_request_completion(struct _starpu_data_request *r, unsigned may_alloc);
  87. void _starpu_data_request_append_callback(struct _starpu_data_request *r,
  88. void (*callback_func)(void *),
  89. void *callback_arg);
  90. void _starpu_update_prefetch_status(struct _starpu_data_request *r);
  91. #endif // __DATA_REQUEST_H__