147d993e7Ssuyashtn /* Portions of this code are under: 247d993e7Ssuyashtn Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 347d993e7Ssuyashtn */ 4*59194e33SJacob Faibussowitsch #ifndef __MPIHIPSPARSEMATIMPL 547d993e7Ssuyashtn #define __MPIHIPSPARSEMATIMPL 647d993e7Ssuyashtn 747d993e7Ssuyashtn #if PETSC_PKG_HIP_VERSION_GE(5, 2, 0) 847d993e7Ssuyashtn #include <hipsparse/hipsparse.h> 947d993e7Ssuyashtn #else 1047d993e7Ssuyashtn #include <hipsparse.h> 1147d993e7Ssuyashtn #endif 1247d993e7Ssuyashtn #include <petsc/private/hipvecimpl.h> 1347d993e7Ssuyashtn 1447d993e7Ssuyashtn struct Mat_MPIAIJHIPSPARSE { 1547d993e7Ssuyashtn /* The following are used by GPU capabilities to store matrix storage formats on the device */ 1647d993e7Ssuyashtn MatHIPSPARSEStorageFormat diagGPUMatFormat; 1747d993e7Ssuyashtn MatHIPSPARSEStorageFormat offdiagGPUMatFormat; 1847d993e7Ssuyashtn PetscSplitCSRDataStructure deviceMat; 1947d993e7Ssuyashtn PetscInt coo_nd, coo_no; /* number of nonzero entries in coo for the diag/offdiag part */ 2047d993e7Ssuyashtn THRUSTINTARRAY *coo_p; /* the permutation array that partitions the coo array into diag/offdiag parts */ 2147d993e7Ssuyashtn THRUSTARRAY *coo_pw; /* the work array that stores the partitioned coo scalar values */ 2247d993e7Ssuyashtn 2347d993e7Ssuyashtn /* Extended COO stuff */ 2447d993e7Ssuyashtn PetscCount *Ajmap1_d, *Aperm1_d; /* Local entries to diag */ 2547d993e7Ssuyashtn PetscCount *Bjmap1_d, *Bperm1_d; /* Local entries to offdiag */ 2647d993e7Ssuyashtn PetscCount *Aimap2_d, *Ajmap2_d, *Aperm2_d; /* Remote entries to diag */ 2747d993e7Ssuyashtn PetscCount *Bimap2_d, *Bjmap2_d, *Bperm2_d; /* Remote entries to offdiag */ 2847d993e7Ssuyashtn PetscCount *Cperm1_d; /* Permutation to fill send buffer. 'C' for communication */ 2947d993e7Ssuyashtn PetscScalar *sendbuf_d, *recvbuf_d; /* Buffers for remote values in MatSetValuesCOO() */ 3047d993e7Ssuyashtn PetscBool use_extended_coo; 3147d993e7Ssuyashtn 3247d993e7Ssuyashtn Mat_MPIAIJHIPSPARSE() 3347d993e7Ssuyashtn { 3447d993e7Ssuyashtn diagGPUMatFormat = MAT_HIPSPARSE_CSR; 3547d993e7Ssuyashtn offdiagGPUMatFormat = MAT_HIPSPARSE_CSR; 3647d993e7Ssuyashtn coo_p = NULL; 3747d993e7Ssuyashtn coo_pw = NULL; 3847d993e7Ssuyashtn deviceMat = NULL; 3947d993e7Ssuyashtn use_extended_coo = PETSC_FALSE; 4047d993e7Ssuyashtn } 4147d993e7Ssuyashtn }; 4247d993e7Ssuyashtn 4347d993e7Ssuyashtn #endif 44