void_interface.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux 1
  4. * Copyright (C) 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. #include <starpu.h>
  18. #include <common/config.h>
  19. #include <datawizard/coherency.h>
  20. #include <datawizard/copy_driver.h>
  21. #include <datawizard/filters.h>
  22. #include <common/hash.h>
  23. #include <starpu_cuda.h>
  24. #include <starpu_opencl.h>
  25. #include <drivers/opencl/driver_opencl.h>
  26. static int dummy_copy(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node);
  27. #ifdef STARPU_USE_CUDA
  28. static int dummy_cuda_copy_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, cudaStream_t stream);
  29. #endif
  30. #ifdef STARPU_USE_OPENCL
  31. static int dummy_opencl_copy_async(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *_event);
  32. #endif
  33. static const struct starpu_data_copy_methods void_copy_data_methods_s = {
  34. .ram_to_ram = dummy_copy,
  35. .ram_to_spu = dummy_copy,
  36. #ifdef STARPU_USE_CUDA
  37. .ram_to_cuda = dummy_copy,
  38. .cuda_to_ram = dummy_copy,
  39. .cuda_to_cuda = dummy_copy,
  40. .ram_to_cuda_async = dummy_cuda_copy_async,
  41. .cuda_to_ram_async = dummy_cuda_copy_async,
  42. .cuda_to_cuda_async = dummy_cuda_copy_async,
  43. #endif
  44. #ifdef STARPU_USE_OPENCL
  45. .ram_to_opencl = dummy_copy,
  46. .opencl_to_ram = dummy_copy,
  47. .ram_to_opencl_async = dummy_opencl_copy_async,
  48. .opencl_to_ram_async = dummy_opencl_copy_async,
  49. #endif
  50. .cuda_to_cuda = dummy_copy,
  51. .cuda_to_spu = dummy_copy,
  52. .spu_to_ram = dummy_copy,
  53. .spu_to_cuda = dummy_copy,
  54. .spu_to_spu = dummy_copy
  55. };
  56. static void register_void_handle(starpu_data_handle handle, uint32_t home_node, void *data_interface);
  57. static ssize_t allocate_void_buffer_on_node(void *data_interface_, uint32_t dst_node);
  58. static void free_void_buffer_on_node(void *data_interface, uint32_t node);
  59. static size_t void_interface_get_size(starpu_data_handle handle);
  60. static uint32_t footprint_void_interface_crc32(starpu_data_handle handle);
  61. static int void_compare(void *data_interface_a, void *data_interface_b);
  62. static void display_void_interface(starpu_data_handle handle, FILE *f);
  63. static struct starpu_data_interface_ops_t interface_void_ops = {
  64. .register_data_handle = register_void_handle,
  65. .allocate_data_on_node = allocate_void_buffer_on_node,
  66. .free_data_on_node = free_void_buffer_on_node,
  67. .copy_methods = &void_copy_data_methods_s,
  68. .get_size = void_interface_get_size,
  69. .footprint = footprint_void_interface_crc32,
  70. .compare = void_compare,
  71. .interfaceid = STARPU_VOID_INTERFACE_ID,
  72. .interface_size = 0,
  73. .display = display_void_interface
  74. };
  75. static void register_void_handle(starpu_data_handle handle __attribute__((unused)),
  76. uint32_t home_node __attribute__((unused)),
  77. void *data_interface __attribute__((unused)))
  78. {
  79. /* Since there is no real data to register, we don't do anything */
  80. }
  81. /* declare a new data with the void interface */
  82. void starpu_void_data_register(starpu_data_handle *handleptr)
  83. {
  84. starpu_data_register(handleptr, 0, NULL, &interface_void_ops);
  85. }
  86. static uint32_t footprint_void_interface_crc32(starpu_data_handle handle __attribute__((unused)))
  87. {
  88. return 0;
  89. }
  90. static int void_compare(void *data_interface_a __attribute__((unused)),
  91. void *data_interface_b __attribute__((unused)))
  92. {
  93. /* There is no allocation required, and therefore nothing to cache
  94. * anyway. */
  95. return 1;
  96. }
  97. static void display_void_interface(starpu_data_handle handle __attribute__((unused)), FILE *f)
  98. {
  99. fprintf(f, "void\t");
  100. }
  101. static size_t void_interface_get_size(starpu_data_handle handle __attribute__((unused)))
  102. {
  103. return 0;
  104. }
  105. /* memory allocation/deallocation primitives for the void interface */
  106. /* returns the size of the allocated area */
  107. static ssize_t allocate_void_buffer_on_node(void *data_interface __attribute__((unused)),
  108. uint32_t dst_node __attribute__((unused)))
  109. {
  110. /* Successfuly allocated 0 bytes */
  111. return 0;
  112. }
  113. static void free_void_buffer_on_node(void *data_interface __attribute__((unused)) ,
  114. uint32_t node __attribute__((unused)))
  115. {
  116. /* There is no buffer actually */
  117. }
  118. static int dummy_copy(void *src_interface __attribute__((unused)),
  119. unsigned src_node __attribute__((unused)),
  120. void *dst_interface __attribute__((unused)),
  121. unsigned dst_node __attribute__((unused)))
  122. {
  123. return 0;
  124. }
  125. #ifdef STARPU_USE_CUDA
  126. static int dummy_cuda_copy_async(void *src_interface __attribute__((unused)),
  127. unsigned src_node __attribute__((unused)),
  128. void *dst_interface __attribute__((unused)),
  129. unsigned dst_node __attribute__((unused)),
  130. cudaStream_t stream __attribute__ ((unused)))
  131. {
  132. return 0;
  133. }
  134. #endif // STARPU_USE_CUDA
  135. #ifdef STARPU_USE_OPENCL
  136. static int dummy_opencl_copy_async(void *src_interface __attribute__((unused)),
  137. unsigned src_node __attribute__((unused)),
  138. void *dst_interface __attribute__((unused)),
  139. unsigned dst_node __attribute__((unused)),
  140. void *_event __attribute__((unused)))
  141. {
  142. return 0;
  143. }
  144. #endif // STARPU_USE_OPENCL