copy_driver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2008-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU 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. * StarPU 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 __COPY_DRIVER_H__
  17. #define __COPY_DRIVER_H__
  18. /** @file */
  19. #ifdef HAVE_AIO_H
  20. #include <aio.h>
  21. #endif
  22. #include <common/config.h>
  23. #include <common/list.h>
  24. #ifdef STARPU_USE_CUDA
  25. #include <cuda.h>
  26. #include <cuda_runtime.h>
  27. #endif
  28. #ifdef STARPU_USE_OPENCL
  29. #include <starpu_opencl.h>
  30. #endif
  31. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  32. #include <mpi.h>
  33. #endif
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif
  38. struct _starpu_data_request;
  39. struct _starpu_data_replicate;
  40. enum _starpu_is_prefetch
  41. {
  42. /** A task really needs it now! */
  43. STARPU_FETCH = 0,
  44. /** A task will need it soon */
  45. STARPU_TASK_PREFETCH = 1,
  46. /** It is a good idea to have it asap */
  47. STARPU_PREFETCH = 2,
  48. /** Get this here when you have time to */
  49. STARPU_IDLEFETCH = 3,
  50. STARPU_NFETCH
  51. };
  52. #ifdef STARPU_USE_MIC
  53. /** MIC needs memory_node to know which MIC is concerned.
  54. * mark is used to wait asynchronous request.
  55. * signal is used to test asynchronous request. */
  56. struct _starpu_mic_async_event
  57. {
  58. unsigned memory_node;
  59. int mark;
  60. uint64_t *signal;
  61. };
  62. #endif
  63. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  64. LIST_TYPE(_starpu_mpi_ms_event_request,
  65. MPI_Request request;
  66. );
  67. struct _starpu_mpi_ms_async_event
  68. {
  69. int is_sender;
  70. struct _starpu_mpi_ms_event_request_list * requests;
  71. };
  72. #endif
  73. LIST_TYPE(_starpu_disk_backend_event,
  74. void *backend_event;
  75. );
  76. struct _starpu_disk_async_event
  77. {
  78. unsigned memory_node;
  79. struct _starpu_disk_backend_event_list * requests;
  80. void * ptr;
  81. unsigned node;
  82. size_t size;
  83. starpu_data_handle_t handle;
  84. };
  85. /** this is a structure that can be queried to see whether an asynchronous
  86. * transfer has terminated or not */
  87. union _starpu_async_channel_event
  88. {
  89. #ifdef STARPU_SIMGRID
  90. struct
  91. {
  92. unsigned finished;
  93. starpu_pthread_queue_t *queue;
  94. };
  95. #endif
  96. #ifdef STARPU_USE_CUDA
  97. cudaEvent_t cuda_event;
  98. #endif
  99. #ifdef STARPU_USE_OPENCL
  100. cl_event opencl_event;
  101. #endif
  102. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  103. struct _starpu_mpi_ms_async_event mpi_ms_event;
  104. #endif
  105. #ifdef STARPU_USE_MIC
  106. struct _starpu_mic_async_event mic_event;
  107. #endif
  108. struct _starpu_disk_async_event disk_event;
  109. };
  110. struct _starpu_async_channel
  111. {
  112. union _starpu_async_channel_event event;
  113. struct _starpu_node_ops *node_ops;
  114. /** Which node to polling when needing ACK msg */
  115. struct _starpu_mp_node *polling_node_sender;
  116. struct _starpu_mp_node *polling_node_receiver;
  117. /** Used to know if the acknowlegdment msg is arrived from sinks */
  118. volatile int starpu_mp_common_finished_sender;
  119. volatile int starpu_mp_common_finished_receiver;
  120. };
  121. void _starpu_wake_all_blocked_workers_on_node(unsigned nodeid);
  122. int _starpu_driver_copy_data_1_to_1(starpu_data_handle_t handle,
  123. struct _starpu_data_replicate *src_replicate,
  124. struct _starpu_data_replicate *dst_replicate,
  125. unsigned donotread,
  126. struct _starpu_data_request *req,
  127. unsigned may_alloc,
  128. enum _starpu_is_prefetch prefetch);
  129. unsigned _starpu_driver_test_request_completion(struct _starpu_async_channel *async_channel);
  130. void _starpu_driver_wait_request_completion(struct _starpu_async_channel *async_channel);
  131. #ifdef __cplusplus
  132. }
  133. #endif
  134. #endif // __COPY_DRIVER_H__