void_interface.c 5.0 KB

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