copy_driver.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2012-2015 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2013, 2015 CNRS
  5. * Copyright (C) 2016 INRIA
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __COPY_DRIVER_H__
  19. #define __COPY_DRIVER_H__
  20. #ifdef HAVE_AIO_H
  21. #include <aio.h>
  22. #endif
  23. #include <common/config.h>
  24. #include <common/list.h>
  25. #ifdef STARPU_USE_CUDA
  26. #include <cuda.h>
  27. #include <cuda_runtime.h>
  28. #include <cublas.h>
  29. #endif
  30. #ifdef STARPU_USE_OPENCL
  31. #include <starpu_opencl.h>
  32. #endif
  33. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  34. #include <mpi.h>
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. struct _starpu_data_request;
  41. struct _starpu_data_replicate;
  42. #ifdef STARPU_USE_MIC
  43. /* MIC needs memory_node to know which MIC is concerned.
  44. * mark is used to wait asynchronous request.
  45. * signal is used to test asynchronous request. */
  46. struct _starpu_mic_async_event
  47. {
  48. unsigned memory_node;
  49. int mark;
  50. uint64_t *signal;
  51. };
  52. #endif
  53. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  54. LIST_TYPE(_starpu_mpi_ms_event_request,
  55. MPI_Request request;
  56. );
  57. struct _starpu_mpi_ms_async_event
  58. {
  59. int is_sender;
  60. struct _starpu_mpi_ms_event_request_list * requests;
  61. };
  62. #endif
  63. struct _starpu_disk_async_event
  64. {
  65. unsigned memory_node;
  66. void *backend_event;
  67. };
  68. /* this is a structure that can be queried to see whether an asynchronous
  69. * transfer has terminated or not */
  70. union _starpu_async_channel_event
  71. {
  72. #ifdef STARPU_SIMGRID
  73. struct
  74. {
  75. unsigned finished;
  76. starpu_pthread_mutex_t mutex;
  77. starpu_pthread_cond_t cond;
  78. };
  79. #endif
  80. #ifdef STARPU_USE_CUDA
  81. cudaEvent_t cuda_event;
  82. #endif
  83. #ifdef STARPU_USE_OPENCL
  84. cl_event opencl_event;
  85. #endif
  86. #ifdef STARPU_USE_MPI_MASTER_SLAVE
  87. struct _starpu_mpi_ms_async_event mpi_ms_event;
  88. #endif
  89. #ifdef STARPU_USE_MIC
  90. struct _starpu_mic_async_event mic_event;
  91. #endif
  92. struct _starpu_disk_async_event disk_event;
  93. };
  94. struct _starpu_async_channel
  95. {
  96. union _starpu_async_channel_event event;
  97. enum starpu_node_kind type;
  98. /* Which node to polling when needing ACK msg */
  99. struct _starpu_mp_node *polling_node_sender;
  100. struct _starpu_mp_node *polling_node_receiver;
  101. /* Used to know if the acknowlegdment msg is arrived from sinks */
  102. volatile int starpu_mp_common_finished_sender;
  103. volatile int starpu_mp_common_finished_receiver;
  104. };
  105. void _starpu_wake_all_blocked_workers_on_node(unsigned nodeid);
  106. int _starpu_driver_copy_data_1_to_1(starpu_data_handle_t handle,
  107. struct _starpu_data_replicate *src_replicate,
  108. struct _starpu_data_replicate *dst_replicate,
  109. unsigned donotread,
  110. struct _starpu_data_request *req,
  111. unsigned may_alloc,
  112. unsigned prefetch);
  113. unsigned _starpu_driver_test_request_completion(struct _starpu_async_channel *async_channel);
  114. void _starpu_driver_wait_request_completion(struct _starpu_async_channel *async_channel);
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif // __COPY_DRIVER_H__