starpu-data-interfaces.h 6.1 KB

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