starpu-data-interfaces.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. #ifndef __STARPU_DATA_INTERFACES_H__
  17. #define __STARPU_DATA_INTERFACES_H__
  18. #include <starpu.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. struct starpu_data_state_t;
  23. typedef struct starpu_data_state_t * starpu_data_handle;
  24. /* BLAS interface for dense matrices */
  25. typedef struct starpu_blas_interface_s {
  26. uintptr_t ptr;
  27. uint32_t nx;
  28. uint32_t ny;
  29. uint32_t ld;
  30. size_t elemsize;
  31. } starpu_blas_interface_t;
  32. void starpu_register_blas_data(starpu_data_handle *handle, uint32_t home_node,
  33. uintptr_t ptr, uint32_t ld, uint32_t nx,
  34. uint32_t ny, size_t elemsize);
  35. uint32_t starpu_get_blas_nx(starpu_data_handle handle);
  36. uint32_t starpu_get_blas_ny(starpu_data_handle handle);
  37. uint32_t starpu_get_blas_local_ld(starpu_data_handle handle);
  38. uintptr_t starpu_get_blas_local_ptr(starpu_data_handle handle);
  39. /* BLOCK interface for 3D dense blocks */
  40. typedef struct starpu_block_interface_s {
  41. uintptr_t ptr;
  42. uint32_t nx;
  43. uint32_t ny;
  44. uint32_t nz;
  45. uint32_t ldy; /* number of elements between two lines */
  46. uint32_t ldz; /* number of elements between two planes */
  47. size_t elemsize;
  48. } starpu_block_interface_t;
  49. void starpu_register_block_data(starpu_data_handle *handle, uint32_t home_node,
  50. uintptr_t ptr, uint32_t ldy, uint32_t ldz, uint32_t nx,
  51. uint32_t ny, uint32_t nz, size_t elemsize);
  52. uint32_t starpu_get_block_nx(starpu_data_handle handle);
  53. uint32_t starpu_get_block_ny(starpu_data_handle handle);
  54. uint32_t starpu_get_block_nz(starpu_data_handle handle);
  55. uint32_t starpu_get_block_local_ldy(starpu_data_handle handle);
  56. uint32_t starpu_get_block_local_ldz(starpu_data_handle handle);
  57. uintptr_t starpu_get_block_local_ptr(starpu_data_handle handle);
  58. /* vector interface for contiguous (non-strided) buffers */
  59. typedef struct starpu_vector_interface_s {
  60. uintptr_t ptr;
  61. uint32_t nx;
  62. size_t elemsize;
  63. } starpu_vector_interface_t;
  64. void starpu_register_vector_data(starpu_data_handle *handle, uint32_t home_node,
  65. uintptr_t ptr, uint32_t nx, size_t elemsize);
  66. uint32_t starpu_get_vector_nx(starpu_data_handle handle);
  67. size_t starpu_get_vector_elemsize(starpu_data_handle handle);
  68. uintptr_t starpu_get_vector_local_ptr(starpu_data_handle handle);
  69. /* CSR interface for sparse matrices (compressed sparse row representation) */
  70. typedef struct starpu_csr_interface_s {
  71. uint32_t nnz; /* number of non-zero entries */
  72. uint32_t nrow; /* number of rows */
  73. uintptr_t nzval; /* non-zero values */
  74. uint32_t *colind; /* position of non-zero entried on the row */
  75. uint32_t *rowptr; /* index (in nzval) of the first entry of the row */
  76. /* k for k-based indexing (0 or 1 usually) */
  77. /* also useful when partitionning the matrix ... */
  78. uint32_t firstentry;
  79. size_t elemsize;
  80. } starpu_csr_interface_t;
  81. void starpu_register_csr_data(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  82. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize);
  83. uint32_t starpu_get_csr_nnz(starpu_data_handle handle);
  84. uint32_t starpu_get_csr_nrow(starpu_data_handle handle);
  85. uint32_t starpu_get_csr_firstentry(starpu_data_handle handle);
  86. uintptr_t starpu_get_csr_local_nzval(starpu_data_handle handle);
  87. uint32_t *starpu_get_csr_local_colind(starpu_data_handle handle);
  88. uint32_t *starpu_get_csr_local_rowptr(starpu_data_handle handle);
  89. size_t starpu_get_csr_elemsize(struct starpu_data_state_t *state);
  90. /* CSC interface for sparse matrices (compressed sparse column representation) */
  91. typedef struct starpu_csc_interface_s {
  92. int nnz; /* number of non-zero entries */
  93. int nrow; /* number of rows */
  94. float *nzval; /* non-zero values */
  95. int *colind; /* position of non-zero entried on the row */
  96. int *rowptr; /* index (in nzval) of the first entry of the row */
  97. /* k for k-based indexing (0 or 1 usually) */
  98. /* also useful when partitionning the matrix ... */
  99. int firstentry;
  100. } starpu_csc_interface_t;
  101. /* BCSR interface for sparse matrices (blocked compressed sparse row
  102. * representation) */
  103. typedef struct starpu_bcsr_interface_s {
  104. uint32_t nnz; /* number of non-zero BLOCKS */
  105. uint32_t nrow; /* number of rows (in terms of BLOCKS) */
  106. uintptr_t nzval; /* non-zero values */
  107. uint32_t *colind; /* position of non-zero entried on the row */
  108. // uint32_t *rowind; /* position of non-zero entried on the col */
  109. uint32_t *rowptr; /* index (in nzval) of the first entry of the row */
  110. /* k for k-based indexing (0 or 1 usually) */
  111. /* also useful when partitionning the matrix ... */
  112. uint32_t firstentry;
  113. /* size of the blocks */
  114. uint32_t r;
  115. uint32_t c;
  116. size_t elemsize;
  117. } starpu_bcsr_interface_t;
  118. void starpu_register_bcsr_data(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  119. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, uint32_t r, uint32_t c, size_t elemsize);
  120. uint32_t starpu_get_bcsr_nnz(starpu_data_handle);
  121. uint32_t starpu_get_bcsr_nrow(starpu_data_handle);
  122. uint32_t starpu_get_bcsr_firstentry(starpu_data_handle);
  123. uintptr_t starpu_get_bcsr_local_nzval(starpu_data_handle);
  124. uint32_t *starpu_get_bcsr_local_colind(starpu_data_handle);
  125. uint32_t *starpu_get_bcsr_local_rowptr(starpu_data_handle);
  126. uint32_t starpu_get_bcsr_r(starpu_data_handle);
  127. uint32_t starpu_get_bcsr_c(starpu_data_handle);
  128. size_t starpu_get_bcsr_elemsize(starpu_data_handle);
  129. #define STARPU_BLAS_INTERFACE_ID 0
  130. #define STARPU_BLOCK_INTERFACE_ID 1
  131. #define STARPU_VECTOR_INTERFACE_ID 2
  132. #define STARPU_CSR_INTERFACE_ID 3
  133. #define STARPU_CSC_INTERFACE_ID 4
  134. #define STARPU_BCSCR_INTERFACE_ID 5
  135. #define STARPU_NINTERFACES_ID 6 /* number of data interfaces */
  136. unsigned starpu_get_handle_interface_id(starpu_data_handle);
  137. typedef union {
  138. starpu_blas_interface_t blas; /* dense BLAS representation */
  139. starpu_block_interface_t block; /* BLOCK interface for 3D dense blocks */
  140. starpu_vector_interface_t vector; /* continuous vector */
  141. starpu_csr_interface_t csr; /* compressed sparse row */
  142. starpu_csc_interface_t csc; /* compressed sparse column */
  143. starpu_bcsr_interface_t bcsr; /* blocked compressed sparse row */
  144. uint8_t pad[64];
  145. } starpu_data_interface_t;
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif // __STARPU_DATA_INTERFACES_H__