void_interface.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2012-2013 Université de Bordeaux 1
  4. * Copyright (C) 2011, 2012, 2013 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 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 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 struct starpu_data_interface_ops interface_void_ops =
  39. {
  40. .register_data_handle = register_void_handle,
  41. .allocate_data_on_node = allocate_void_buffer_on_node,
  42. .free_data_on_node = free_void_buffer_on_node,
  43. .copy_methods = &void_copy_data_methods_s,
  44. .get_size = void_interface_get_size,
  45. .footprint = footprint_void_interface_crc32,
  46. .compare = void_compare,
  47. .interfaceid = STARPU_VOID_INTERFACE_ID,
  48. .interface_size = 0,
  49. .display = display_void_interface
  50. };
  51. static void register_void_handle(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED,
  52. unsigned home_node STARPU_ATTRIBUTE_UNUSED,
  53. void *data_interface STARPU_ATTRIBUTE_UNUSED)
  54. {
  55. /* Since there is no real data to register, we don't do anything */
  56. }
  57. /* declare a new data with the void interface */
  58. void starpu_void_data_register(starpu_data_handle_t *handleptr)
  59. {
  60. starpu_data_register(handleptr, 0, NULL, &interface_void_ops);
  61. }
  62. static uint32_t footprint_void_interface_crc32(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED)
  63. {
  64. return 0;
  65. }
  66. static int void_compare(void *data_interface_a STARPU_ATTRIBUTE_UNUSED,
  67. void *data_interface_b STARPU_ATTRIBUTE_UNUSED)
  68. {
  69. /* There is no allocation required, and therefore nothing to cache
  70. * anyway. */
  71. return 1;
  72. }
  73. static void display_void_interface(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED, FILE *f)
  74. {
  75. fprintf(f, "void\t");
  76. }
  77. static size_t void_interface_get_size(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED)
  78. {
  79. return 0;
  80. }
  81. /* memory allocation/deallocation primitives for the void interface */
  82. /* returns the size of the allocated area */
  83. static ssize_t allocate_void_buffer_on_node(void *data_interface STARPU_ATTRIBUTE_UNUSED,
  84. unsigned dst_node STARPU_ATTRIBUTE_UNUSED)
  85. {
  86. /* Successfuly allocated 0 bytes */
  87. return 0;
  88. }
  89. static void free_void_buffer_on_node(void *data_interface STARPU_ATTRIBUTE_UNUSED ,
  90. unsigned node STARPU_ATTRIBUTE_UNUSED)
  91. {
  92. /* There is no buffer actually */
  93. }
  94. static int dummy_copy(void *src_interface STARPU_ATTRIBUTE_UNUSED,
  95. unsigned src_node STARPU_ATTRIBUTE_UNUSED,
  96. void *dst_interface STARPU_ATTRIBUTE_UNUSED,
  97. unsigned dst_node STARPU_ATTRIBUTE_UNUSED)
  98. {
  99. return 0;
  100. }