starpu_data.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011 Université de Bordeaux 1
  4. * Copyright (C) 2010, 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. #ifndef __STARPU_DATA_H__
  18. #define __STARPU_DATA_H__
  19. #include <starpu.h>
  20. #include <starpu_config.h>
  21. struct starpu_data_state_t;
  22. typedef struct starpu_data_state_t * starpu_data_handle;
  23. #include <starpu_data_interfaces.h>
  24. #include <starpu_data_filters.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #define STARPU_R (1<<0)
  29. #define STARPU_W (1<<1)
  30. #define STARPU_RW (STARPU_R|STARPU_W)
  31. #define STARPU_SCRATCH (1<<2)
  32. #define STARPU_REDUX (1<<3)
  33. typedef uint32_t starpu_access_mode;
  34. typedef struct starpu_buffer_descr_t {
  35. starpu_data_handle handle;
  36. starpu_access_mode mode;
  37. } starpu_buffer_descr;
  38. struct starpu_data_interface_ops_t;
  39. /* Destroy the data handle, in case we don't need to update the value of the
  40. * data in the home node, we can use starpu_data_unregister_no_coherency
  41. * instead. */
  42. void starpu_data_unregister(starpu_data_handle handle);
  43. void starpu_data_unregister_no_coherency(starpu_data_handle handle);
  44. /* Destroy all data replicates. After data invalidation, the first access to
  45. * the handle must be performed in write-only mode. */
  46. void starpu_data_invalidate(starpu_data_handle);
  47. void starpu_data_advise_as_important(starpu_data_handle handle, unsigned is_important);
  48. int starpu_data_acquire(starpu_data_handle handle, starpu_access_mode mode);
  49. int starpu_data_acquire_cb(starpu_data_handle handle,
  50. starpu_access_mode mode, void (*callback)(void *), void *arg);
  51. #ifdef __GCC__
  52. # define STARPU_DATA_ACQUIRE_CB(handle, mode, code) do { \
  53. void callback(void *arg) { \
  54. code; \
  55. starpu_data_release(handle); \
  56. } \
  57. starpu_data_acquire_cb(handle, mode, callback, NULL); \
  58. } while(0)
  59. #endif
  60. void starpu_data_release(starpu_data_handle handle);
  61. int starpu_malloc(void **A, size_t dim);
  62. int starpu_free(void *A);
  63. /* XXX These macros are provided to avoid breaking old codes. But consider
  64. * these function names as deprecated. */
  65. #define starpu_data_malloc_pinned_if_possible starpu_malloc
  66. #define starpu_data_free_pinned_if_possible starpu_free
  67. int starpu_data_request_allocation(starpu_data_handle handle, uint32_t node);
  68. int starpu_data_prefetch_on_node(starpu_data_handle handle, unsigned node, unsigned async);
  69. unsigned starpu_worker_get_memory_node(unsigned workerid);
  70. /* It is possible to associate a mask to a piece of data (and its children) so
  71. * that when it is modified, it is automatically transfered into those memory
  72. * node. For instance a (1<<0) write-through mask means that the CUDA workers will
  73. * commit their changes in main memory (node 0). */
  74. void starpu_data_set_wt_mask(starpu_data_handle handle, uint32_t wt_mask);
  75. void starpu_data_set_sequential_consistency_flag(starpu_data_handle handle, unsigned flag);
  76. unsigned starpu_data_get_default_sequential_consistency_flag(void);
  77. void starpu_data_set_default_sequential_consistency_flag(unsigned flag);
  78. /* Query the status of the handle on the specified memory node. */
  79. void starpu_data_query_status(starpu_data_handle handle, int memory_node, int *is_allocated, int *is_valid, int *is_requested);
  80. struct starpu_codelet_t;
  81. void starpu_data_set_reduction_methods(starpu_data_handle handle,
  82. struct starpu_codelet_t *redux_cl,
  83. struct starpu_codelet_t *init_cl);
  84. int starpu_data_set_rank(starpu_data_handle handle, int rank);
  85. int starpu_data_get_rank(starpu_data_handle handle);
  86. int starpu_data_set_tag(starpu_data_handle handle, int tag);
  87. int starpu_data_get_tag(starpu_data_handle handle);
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif /* __STARPU_DATA_H__ */