xref: /petsc/src/mat/impls/aij/mpi/mpihipsparse/mpihipsparsematimpl.h (revision 8ba4effdc256b99103d44af35f27014676a8e511)
1 /* Portions of this code are under:
2    Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
3 */
4 #ifndef __MPIHIPSPARSEMATIMPL
5 #define __MPIHIPSPARSEMATIMPL
6 
7 #include <petscpkg_version.h>
8 #if PETSC_PKG_HIP_VERSION_GE(5, 2, 0)
9   #include <hipsparse/hipsparse.h>
10 #else
11   #include <hipsparse.h>
12 #endif
13 #include <petsc/private/veccupmimpl.h>
14 
15 struct Mat_MPIAIJHIPSPARSE {
16   /* The following are used by GPU capabilities to store matrix storage formats on the device */
17   MatHIPSPARSEStorageFormat diagGPUMatFormat;
18   MatHIPSPARSEStorageFormat offdiagGPUMatFormat;
19   PetscInt                  coo_nd, coo_no; /* number of nonzero entries in coo for the diag/offdiag part */
20   THRUSTINTARRAY           *coo_p;          /* the permutation array that partitions the coo array into diag/offdiag parts */
21   THRUSTARRAY              *coo_pw;         /* the work array that stores the partitioned coo scalar values */
22 
23   /* Extended COO stuff */
24   PetscCount  *Ajmap1_d, *Aperm1_d;            /* Local entries to diag */
25   PetscCount  *Bjmap1_d, *Bperm1_d;            /* Local entries to offdiag */
26   PetscCount  *Aimap2_d, *Ajmap2_d, *Aperm2_d; /* Remote entries to diag */
27   PetscCount  *Bimap2_d, *Bjmap2_d, *Bperm2_d; /* Remote entries to offdiag */
28   PetscCount  *Cperm1_d;                       /* Permutation to fill send buffer. 'C' for communication */
29   PetscScalar *sendbuf_d, *recvbuf_d;          /* Buffers for remote values in MatSetValuesCOO() */
30   PetscBool    use_extended_coo;
31 
32   Mat_MPIAIJHIPSPARSE()
33   {
34     diagGPUMatFormat    = MAT_HIPSPARSE_CSR;
35     offdiagGPUMatFormat = MAT_HIPSPARSE_CSR;
36     coo_p               = NULL;
37     coo_pw              = NULL;
38     use_extended_coo    = PETSC_FALSE;
39   }
40 };
41 
42 #endif
43