starpu-data-interfaces.h 6.8 KB

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