starpu-data-interfaces.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. /* vector interface for contiguous (non-strided) buffers */
  36. typedef struct starpu_vector_interface_s {
  37. uintptr_t ptr;
  38. uint32_t nx;
  39. size_t elemsize;
  40. } starpu_vector_interface_t;
  41. void starpu_register_vector_data(starpu_data_handle *handle, uint32_t home_node,
  42. uintptr_t ptr, uint32_t nx, size_t elemsize);
  43. uint32_t starpu_get_vector_nx(starpu_data_handle handle);
  44. uintptr_t starpu_get_vector_local_ptr(starpu_data_handle handle);
  45. /* CSR interface for sparse matrices (compressed sparse row representation) */
  46. typedef struct starpu_csr_interface_s {
  47. uint32_t nnz; /* number of non-zero entries */
  48. uint32_t nrow; /* number of rows */
  49. uintptr_t nzval; /* non-zero values */
  50. uint32_t *colind; /* position of non-zero entried on the row */
  51. uint32_t *rowptr; /* index (in nzval) of the first entry of the row */
  52. /* k for k-based indexing (0 or 1 usually) */
  53. /* also useful when partitionning the matrix ... */
  54. uint32_t firstentry;
  55. size_t elemsize;
  56. } starpu_csr_interface_t;
  57. void starpu_register_csr_data(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  58. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize);
  59. uint32_t starpu_get_csr_nnz(starpu_data_handle handle);
  60. uint32_t starpu_get_csr_nrow(starpu_data_handle handle);
  61. uint32_t starpu_get_csr_firstentry(starpu_data_handle handle);
  62. uintptr_t starpu_get_csr_local_nzval(starpu_data_handle handle);
  63. uint32_t *starpu_get_csr_local_colind(starpu_data_handle handle);
  64. uint32_t *starpu_get_csr_local_rowptr(starpu_data_handle handle);
  65. /* CSC interface for sparse matrices (compressed sparse column representation) */
  66. typedef struct starpu_csc_interface_s {
  67. int nnz; /* number of non-zero entries */
  68. int nrow; /* number of rows */
  69. float *nzval; /* non-zero values */
  70. int *colind; /* position of non-zero entried on the row */
  71. int *rowptr; /* index (in nzval) of the first entry of the row */
  72. /* k for k-based indexing (0 or 1 usually) */
  73. /* also useful when partitionning the matrix ... */
  74. int firstentry;
  75. } starpu_csc_interface_t;
  76. /* BCSR interface for sparse matrices (blocked compressed sparse row
  77. * representation) */
  78. typedef struct starpu_bcsr_interface_s {
  79. uint32_t nnz; /* number of non-zero BLOCKS */
  80. uint32_t nrow; /* number of rows (in terms of BLOCKS) */
  81. uintptr_t nzval; /* non-zero values */
  82. uint32_t *colind; /* position of non-zero entried on the row */
  83. // uint32_t *rowind; /* position of non-zero entried on the col */
  84. uint32_t *rowptr; /* index (in nzval) of the first entry of the row */
  85. /* k for k-based indexing (0 or 1 usually) */
  86. /* also useful when partitionning the matrix ... */
  87. uint32_t firstentry;
  88. /* size of the blocks */
  89. uint32_t r;
  90. uint32_t c;
  91. size_t elemsize;
  92. } starpu_bcsr_interface_t;
  93. void starpu_register_bcsr_data(starpu_data_handle *handle, uint32_t home_node, uint32_t nnz, uint32_t nrow,
  94. uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, uint32_t r, uint32_t c, size_t elemsize);
  95. uint32_t starpu_get_bcsr_nnz(starpu_data_handle);
  96. uint32_t starpu_get_bcsr_nrow(starpu_data_handle);
  97. uint32_t starpu_get_bcsr_firstentry(starpu_data_handle);
  98. uintptr_t starpu_get_bcsr_local_nzval(starpu_data_handle);
  99. uint32_t *starpu_get_bcsr_local_colind(starpu_data_handle);
  100. uint32_t *starpu_get_bcsr_local_rowptr(starpu_data_handle);
  101. uint32_t starpu_get_bcsr_r(starpu_data_handle);
  102. uint32_t starpu_get_bcsr_c(starpu_data_handle);
  103. typedef union {
  104. starpu_blas_interface_t blas; /* dense BLAS representation */
  105. starpu_vector_interface_t vector; /* continuous vector */
  106. starpu_csr_interface_t csr; /* compressed sparse row */
  107. starpu_csc_interface_t csc; /* compressed sparse column */
  108. starpu_bcsr_interface_t bcsr; /* blocked compressed sparse row */
  109. } starpu_data_interface_t;
  110. #endif // __STARPU_DATA_INTERFACES_H__