void_interface.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2012-2014 Université de Bordeaux 1
  4. * Copyright (C) 2011, 2012, 2013, 2014 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 <starpu_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, void *async_data);
  27. static const struct starpu_data_copy_methods void_copy_data_methods_s =
  28. {
  29. .any_to_any = dummy_copy,
  30. };
  31. static void register_void_handle(starpu_data_handle_t handle, unsigned home_node, void *data_interface);
  32. static starpu_ssize_t allocate_void_buffer_on_node(void *data_interface_, unsigned dst_node);
  33. static void free_void_buffer_on_node(void *data_interface, unsigned node);
  34. static size_t void_interface_get_size(starpu_data_handle_t handle);
  35. static uint32_t footprint_void_interface_crc32(starpu_data_handle_t handle);
  36. static int void_compare(void *data_interface_a, void *data_interface_b);
  37. static void display_void_interface(starpu_data_handle_t handle, FILE *f);
  38. static int pack_void_handle(starpu_data_handle_t handle, unsigned node, void **ptr, ssize_t *count);
  39. static int unpack_void_handle(starpu_data_handle_t handle, unsigned node, void *ptr, size_t count);
  40. static ssize_t describe(void *data_interface, char *buf, size_t size);
  41. struct starpu_data_interface_ops starpu_interface_void_ops =
  42. {
  43. .register_data_handle = register_void_handle,
  44. .allocate_data_on_node = allocate_void_buffer_on_node,
  45. .free_data_on_node = free_void_buffer_on_node,
  46. .copy_methods = &void_copy_data_methods_s,
  47. .get_size = void_interface_get_size,
  48. .footprint = footprint_void_interface_crc32,
  49. .compare = void_compare,
  50. .interfaceid = STARPU_VOID_INTERFACE_ID,
  51. .interface_size = 0,
  52. .display = display_void_interface,
  53. .pack_data = pack_void_handle,
  54. .unpack_data = unpack_void_handle,
  55. .describe = describe
  56. };
  57. static void register_void_handle(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED,
  58. unsigned home_node STARPU_ATTRIBUTE_UNUSED,
  59. void *data_interface STARPU_ATTRIBUTE_UNUSED)
  60. {
  61. /* Since there is no real data to register, we don't do anything */
  62. }
  63. /* declare a new data with the void interface */
  64. void starpu_void_data_register(starpu_data_handle_t *handleptr)
  65. {
  66. starpu_data_register(handleptr, STARPU_MAIN_RAM, NULL, &starpu_interface_void_ops);
  67. }
  68. static uint32_t footprint_void_interface_crc32(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED)
  69. {
  70. return 0;
  71. }
  72. static int void_compare(void *data_interface_a STARPU_ATTRIBUTE_UNUSED,
  73. void *data_interface_b STARPU_ATTRIBUTE_UNUSED)
  74. {
  75. /* There is no allocation required, and therefore nothing to cache
  76. * anyway. */
  77. return 1;
  78. }
  79. static void display_void_interface(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED, FILE *f)
  80. {
  81. fprintf(f, "void\t");
  82. }
  83. static int pack_void_handle(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED,
  84. unsigned node STARPU_ATTRIBUTE_UNUSED,
  85. void **ptr,
  86. ssize_t *count)
  87. {
  88. *count = 0;
  89. *ptr = NULL;
  90. return 0;
  91. }
  92. static int unpack_void_handle(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED,
  93. unsigned node STARPU_ATTRIBUTE_UNUSED,
  94. void *ptr STARPU_ATTRIBUTE_UNUSED,
  95. size_t count STARPU_ATTRIBUTE_UNUSED)
  96. {
  97. return 0;
  98. }
  99. static size_t void_interface_get_size(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED)
  100. {
  101. return 0;
  102. }
  103. /* memory allocation/deallocation primitives for the void interface */
  104. /* returns the size of the allocated area */
  105. static starpu_ssize_t allocate_void_buffer_on_node(void *data_interface STARPU_ATTRIBUTE_UNUSED,
  106. unsigned dst_node STARPU_ATTRIBUTE_UNUSED)
  107. {
  108. /* Successfuly allocated 0 bytes */
  109. return 0;
  110. }
  111. static void free_void_buffer_on_node(void *data_interface STARPU_ATTRIBUTE_UNUSED ,
  112. unsigned node STARPU_ATTRIBUTE_UNUSED)
  113. {
  114. /* There is no buffer actually */
  115. }
  116. static int dummy_copy(void *src_interface STARPU_ATTRIBUTE_UNUSED,
  117. unsigned src_node STARPU_ATTRIBUTE_UNUSED,
  118. void *dst_interface STARPU_ATTRIBUTE_UNUSED,
  119. unsigned dst_node STARPU_ATTRIBUTE_UNUSED,
  120. void *async_data STARPU_ATTRIBUTE_UNUSED)
  121. {
  122. return 0;
  123. }
  124. static ssize_t describe(void *data_interface, char *buf, size_t size)
  125. {
  126. return snprintf(buf, size, "0");
  127. }