copy_driver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. STARPU_FETCH = 0, /* A task really needs it now! */
  43. STARPU_TASK_PREFETCH = 1, /* A task will need it soon */
  44. STARPU_PREFETCH = 2, /* It is a good idea to have it asap */
  45. STARPU_IDLEFETCH = 3, /* Get this here when you have time to */
  46. STARPU_NFETCH
  47. };
  48. #ifdef STARPU_USE_MIC
  49. /** MIC needs memory_node to know which MIC is concerned.
  50. * mark is used to wait asynchronous request.
  51. * signal is used to test asynchronous request. */
  52. struct _starpu_mic_async_event
  53. {
  54. unsigned memory_node;
  55. int mark;
  56. uint64_t *signal;
  57. };
  58. #endif
  59. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  60. LIST_TYPE(_starpu_mpi_ms_event_request,
  61. MPI_Request request;
  62. );
  63. struct _starpu_mpi_ms_async_event
  64. {
  65. int is_sender;
  66. struct _starpu_mpi_ms_event_request_list * requests;
  67. };
  68. #endif
  69. LIST_TYPE(_starpu_disk_backend_event,
  70. void *backend_event;
  71. );
  72. struct _starpu_disk_async_event
  73. {
  74. unsigned memory_node;
  75. struct _starpu_disk_backend_event_list * requests;
  76. void * ptr;
  77. unsigned node;
  78. size_t size;
  79. starpu_data_handle_t handle;
  80. };
  81. /** this is a structure that can be queried to see whether an asynchronous
  82. * transfer has terminated or not */
  83. union _starpu_async_channel_event
  84. {
  85. #ifdef STARPU_SIMGRID
  86. struct
  87. {
  88. unsigned finished;
  89. starpu_pthread_queue_t *queue;
  90. };
  91. #endif
  92. #ifdef STARPU_USE_CUDA
  93. cudaEvent_t cuda_event;
  94. #endif
  95. #ifdef STARPU_USE_OPENCL
  96. cl_event opencl_event;
  97. #endif
  98. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  99. struct _starpu_mpi_ms_async_event mpi_ms_event;
  100. #endif
  101. #ifdef STARPU_USE_MIC
  102. struct _starpu_mic_async_event mic_event;
  103. #endif
  104. struct _starpu_disk_async_event disk_event;
  105. };
  106. struct _starpu_async_channel
  107. {
  108. union _starpu_async_channel_event event;
  109. struct _starpu_node_ops *node_ops;
  110. /** Which node to polling when needing ACK msg */
  111. struct _starpu_mp_node *polling_node_sender;
  112. struct _starpu_mp_node *polling_node_receiver;
  113. /** Used to know if the acknowlegdment msg is arrived from sinks */
  114. volatile int starpu_mp_common_finished_sender;
  115. volatile int starpu_mp_common_finished_receiver;
  116. };
  117. void _starpu_wake_all_blocked_workers_on_node(unsigned nodeid);
  118. int _starpu_driver_copy_data_1_to_1(starpu_data_handle_t handle,
  119. struct _starpu_data_replicate *src_replicate,
  120. struct _starpu_data_replicate *dst_replicate,
  121. unsigned donotread,
  122. struct _starpu_data_request *req,
  123. unsigned may_alloc,
  124. enum _starpu_is_prefetch prefetch);
  125. unsigned _starpu_driver_test_request_completion(struct _starpu_async_channel *async_channel);
  126. void _starpu_driver_wait_request_completion(struct _starpu_async_channel *async_channel);
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif // __COPY_DRIVER_H__