starpu_data.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013 Université de Bordeaux 1
  4. * Copyright (C) 2010, 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. #ifndef __STARPU_DATA_H__
  18. #define __STARPU_DATA_H__
  19. #include <starpu.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. struct _starpu_data_state;
  25. typedef struct _starpu_data_state* starpu_data_handle_t;
  26. enum starpu_data_access_mode
  27. {
  28. STARPU_NONE=0,
  29. STARPU_R=(1<<0),
  30. STARPU_W=(1<<1),
  31. STARPU_RW=(STARPU_R|STARPU_W),
  32. STARPU_SCRATCH=(1<<2),
  33. STARPU_REDUX=(1<<3),
  34. STARPU_COMMUTE=(1<<4)
  35. /* Note: other STARPU_* values in include/starpu_task_util.h */
  36. };
  37. struct starpu_data_descr
  38. {
  39. starpu_data_handle_t handle;
  40. enum starpu_data_access_mode mode;
  41. };
  42. struct starpu_data_interface_ops;
  43. void starpu_data_unregister(starpu_data_handle_t handle);
  44. void starpu_data_unregister_no_coherency(starpu_data_handle_t handle);
  45. void starpu_data_unregister_submit(starpu_data_handle_t handle);
  46. void starpu_data_invalidate(starpu_data_handle_t handle);
  47. void starpu_data_invalidate_submit(starpu_data_handle_t handle);
  48. void starpu_data_advise_as_important(starpu_data_handle_t handle, unsigned is_important);
  49. int starpu_data_acquire(starpu_data_handle_t handle, enum starpu_data_access_mode mode);
  50. int starpu_data_acquire_on_node(starpu_data_handle_t handle, unsigned node, enum starpu_data_access_mode mode);
  51. int starpu_data_acquire_cb(starpu_data_handle_t handle, enum starpu_data_access_mode mode, void (*callback)(void *), void *arg);
  52. int starpu_data_acquire_on_node_cb(starpu_data_handle_t handle, unsigned node, enum starpu_data_access_mode mode, void (*callback)(void *), void *arg);
  53. #ifdef __GCC__
  54. # define STARPU_DATA_ACQUIRE_CB(handle, mode, code) do \
  55. { \ \
  56. void callback(void *arg) \
  57. { \
  58. code; \
  59. starpu_data_release(handle); \
  60. } \
  61. starpu_data_acquire_cb(handle, mode, callback, NULL); \
  62. } \
  63. while(0)
  64. #endif
  65. void starpu_data_release(starpu_data_handle_t handle);
  66. void starpu_data_release_on_node(starpu_data_handle_t handle, unsigned node);
  67. void starpu_data_display_memory_stats();
  68. /* XXX These macros are provided to avoid breaking old codes. But consider
  69. * these function names as deprecated. */
  70. #define starpu_data_malloc_pinned_if_possible starpu_malloc
  71. #define starpu_data_free_pinned_if_possible starpu_free
  72. int starpu_data_request_allocation(starpu_data_handle_t handle, unsigned node);
  73. int starpu_data_prefetch_on_node(starpu_data_handle_t handle, unsigned node, unsigned async);
  74. enum starpu_node_kind
  75. {
  76. STARPU_UNUSED = 0x00,
  77. STARPU_CPU_RAM = 0x01,
  78. STARPU_CUDA_RAM = 0x02,
  79. STARPU_OPENCL_RAM = 0x03,
  80. STARPU_MIC_RAM = 0x05,
  81. STARPU_SCC_RAM = 0x06,
  82. STARPU_SCC_SHM = 0x07
  83. };
  84. unsigned starpu_worker_get_memory_node(unsigned workerid);
  85. unsigned starpu_memory_nodes_get_count(void);
  86. enum starpu_node_kind starpu_node_get_kind(unsigned node);
  87. void starpu_data_set_wt_mask(starpu_data_handle_t handle, uint32_t wt_mask);
  88. void starpu_data_set_sequential_consistency_flag(starpu_data_handle_t handle, unsigned flag);
  89. unsigned starpu_data_get_sequential_consistency_flag(starpu_data_handle_t handle);
  90. unsigned starpu_data_get_default_sequential_consistency_flag(void);
  91. void starpu_data_set_default_sequential_consistency_flag(unsigned flag);
  92. void starpu_data_query_status(starpu_data_handle_t handle, int memory_node, int *is_allocated, int *is_valid, int *is_requested);
  93. struct starpu_codelet;
  94. void starpu_data_set_reduction_methods(starpu_data_handle_t handle, struct starpu_codelet *redux_cl, struct starpu_codelet *init_cl);
  95. int starpu_data_set_rank(starpu_data_handle_t handle, int rank);
  96. int starpu_data_get_rank(starpu_data_handle_t handle);
  97. int starpu_data_set_tag(starpu_data_handle_t handle, int tag);
  98. int starpu_data_get_tag(starpu_data_handle_t handle);
  99. starpu_data_handle_t starpu_data_get_data_handle_from_tag(int tag);
  100. struct starpu_data_interface_ops* starpu_data_get_interface_ops(starpu_data_handle_t handle);
  101. unsigned starpu_data_test_if_allocated_on_node(starpu_data_handle_t handle, unsigned memory_node);
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif /* __STARPU_DATA_H__ */