File: | mat/impls/aij/mpi/mpiptap.c |
Warning: | line 1085, column 5 Access to field 'i' results in a dereference of a null pointer (loaded from variable 'p_oth') |
[?] Use j/k keys for keyboard navigation
1 | ||||||||||
2 | /* | |||||||||
3 | Defines projective product routines where A is a MPIAIJ matrix | |||||||||
4 | C = P^T * A * P | |||||||||
5 | */ | |||||||||
6 | ||||||||||
7 | #include <../src/mat/impls/aij/seq/aij.h> /*I "petscmat.h" I*/ | |||||||||
8 | #include <../src/mat/utils/freespace.h> | |||||||||
9 | #include <../src/mat/impls/aij/mpi/mpiaij.h> | |||||||||
10 | #include <petscbt.h> | |||||||||
11 | #include <petsctime.h> | |||||||||
12 | ||||||||||
13 | /* #define PTAP_PROFILE */ | |||||||||
14 | ||||||||||
15 | PetscErrorCode MatView_MPIAIJ_PtAP(Mat A,PetscViewer viewer) | |||||||||
16 | { | |||||||||
17 | PetscErrorCode ierr; | |||||||||
18 | Mat_MPIAIJ *a=(Mat_MPIAIJ*)A->data; | |||||||||
19 | Mat_APMPI *ptap=a->ap; | |||||||||
20 | PetscBool iascii; | |||||||||
21 | PetscViewerFormat format; | |||||||||
22 | ||||||||||
23 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 23; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
24 | if (!ptap) { | |||||||||
25 | /* hack: MatDuplicate() sets oldmat->ops->view to newmat which is a base mat class with null ptpa! */ | |||||||||
26 | A->ops->view = MatView_MPIAIJ; | |||||||||
27 | ierr = (A->ops->view)(A,viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),27,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
28 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
29 | } | |||||||||
30 | ||||||||||
31 | ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII"ascii",&iascii);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),31,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
32 | if (iascii) { | |||||||||
33 | ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),33,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
34 | if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) { | |||||||||
35 | if (ptap->algType == 0) { | |||||||||
36 | ierr = PetscViewerASCIIPrintf(viewer,"using scalable MatPtAP() implementation\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),36,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
37 | } else if (ptap->algType == 1) { | |||||||||
38 | ierr = PetscViewerASCIIPrintf(viewer,"using nonscalable MatPtAP() implementation\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),38,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
39 | } | |||||||||
40 | } | |||||||||
41 | } | |||||||||
42 | ierr = (ptap->view)(A,viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),42,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
43 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
44 | } | |||||||||
45 | ||||||||||
46 | PetscErrorCode MatFreeIntermediateDataStructures_MPIAIJ_AP(Mat A) | |||||||||
47 | { | |||||||||
48 | PetscErrorCode ierr; | |||||||||
49 | Mat_MPIAIJ *a=(Mat_MPIAIJ*)A->data; | |||||||||
50 | Mat_APMPI *ptap=a->ap; | |||||||||
51 | Mat_Merge_SeqsToMPI *merge; | |||||||||
52 | ||||||||||
53 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 53; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
54 | if (!ptap) PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
55 | ||||||||||
56 | ierr = PetscFree2(ptap->startsj_s,ptap->startsj_r)PetscFreeA(2,56,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(ptap->startsj_s),&(ptap->startsj_r));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),56,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
57 | ierr = PetscFree(ptap->bufa)((*PetscTrFree)((void*)(ptap->bufa),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((ptap->bufa) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),57,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
58 | ierr = MatDestroy(&ptap->P_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),58,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
59 | ierr = MatDestroy(&ptap->P_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),59,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
60 | ierr = MatDestroy(&ptap->A_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),60,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* used by MatTransposeMatMult() */ | |||||||||
61 | ierr = MatDestroy(&ptap->Rd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),61,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
62 | ierr = MatDestroy(&ptap->Ro);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),62,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
63 | if (ptap->AP_loc) { /* used by alg_rap */ | |||||||||
64 | Mat_SeqAIJ *ap = (Mat_SeqAIJ*)(ptap->AP_loc)->data; | |||||||||
65 | ierr = PetscFree(ap->i)((*PetscTrFree)((void*)(ap->i),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((ap->i) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
66 | ierr = PetscFree2(ap->j,ap->a)PetscFreeA(2,66,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(ap->j),&(ap->a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
67 | ierr = MatDestroy(&ptap->AP_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),67,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
68 | } else { /* used by alg_ptap */ | |||||||||
69 | ierr = PetscFree(ptap->api)((*PetscTrFree)((void*)(ptap->api),69,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((ptap->api) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),69,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
70 | ierr = PetscFree(ptap->apj)((*PetscTrFree)((void*)(ptap->apj),70,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((ptap->apj) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),70,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
71 | } | |||||||||
72 | ierr = MatDestroy(&ptap->C_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),72,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
73 | ierr = MatDestroy(&ptap->C_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),73,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
74 | if (ptap->apa) {ierr = PetscFree(ptap->apa)((*PetscTrFree)((void*)(ptap->apa),74,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((ptap->apa) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),74,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||||||||
75 | ||||||||||
76 | ierr = MatDestroy(&ptap->Pt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),76,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
77 | ||||||||||
78 | merge=ptap->merge; | |||||||||
79 | if (merge) { /* used by alg_ptap */ | |||||||||
80 | ierr = PetscFree(merge->id_r)((*PetscTrFree)((void*)(merge->id_r),80,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->id_r) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),80,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
81 | ierr = PetscFree(merge->len_s)((*PetscTrFree)((void*)(merge->len_s),81,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->len_s) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),81,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
82 | ierr = PetscFree(merge->len_r)((*PetscTrFree)((void*)(merge->len_r),82,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->len_r) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),82,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
83 | ierr = PetscFree(merge->bi)((*PetscTrFree)((void*)(merge->bi),83,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->bi) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),83,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
84 | ierr = PetscFree(merge->bj)((*PetscTrFree)((void*)(merge->bj),84,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->bj) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),84,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
85 | ierr = PetscFree(merge->buf_ri[0])((*PetscTrFree)((void*)(merge->buf_ri[0]),85,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->buf_ri[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),85,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
86 | ierr = PetscFree(merge->buf_ri)((*PetscTrFree)((void*)(merge->buf_ri),86,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->buf_ri) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),86,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
87 | ierr = PetscFree(merge->buf_rj[0])((*PetscTrFree)((void*)(merge->buf_rj[0]),87,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->buf_rj[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),87,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
88 | ierr = PetscFree(merge->buf_rj)((*PetscTrFree)((void*)(merge->buf_rj),88,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->buf_rj) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),88,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
89 | ierr = PetscFree(merge->coi)((*PetscTrFree)((void*)(merge->coi),89,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->coi) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),89,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
90 | ierr = PetscFree(merge->coj)((*PetscTrFree)((void*)(merge->coj),90,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->coj) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),90,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
91 | ierr = PetscFree(merge->owners_co)((*PetscTrFree)((void*)(merge->owners_co),91,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((merge->owners_co) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),91,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
92 | ierr = PetscLayoutDestroy(&merge->rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),92,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
93 | ierr = PetscFree(ptap->merge)((*PetscTrFree)((void*)(ptap->merge),93,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((ptap->merge) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),93,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
94 | } | |||||||||
95 | ierr = ISLocalToGlobalMappingDestroy(&ptap->ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),95,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
96 | ||||||||||
97 | A->ops->destroy = ptap->destroy; | |||||||||
98 | ierr = PetscFree(a->ap)((*PetscTrFree)((void*)(a->ap),98,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((a->ap) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),98,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
99 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
100 | } | |||||||||
101 | ||||||||||
102 | PetscErrorCode MatDestroy_MPIAIJ_PtAP(Mat A) | |||||||||
103 | { | |||||||||
104 | PetscErrorCode ierr; | |||||||||
105 | ||||||||||
106 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 106; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
107 | ierr = (*A->ops->freeintermediatedatastructures)(A);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),107,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
108 | ierr = (*A->ops->destroy)(A);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),108,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
109 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
110 | } | |||||||||
111 | ||||||||||
112 | PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode MatPtAP_MPIAIJ_MPIAIJ(Mat A,Mat P,MatReuse scall,PetscReal fill,Mat *C) | |||||||||
113 | { | |||||||||
114 | PetscErrorCode ierr; | |||||||||
115 | PetscBool flg; | |||||||||
116 | MPI_Comm comm; | |||||||||
117 | #if !defined(PETSC_HAVE_HYPRE) | |||||||||
118 | const char *algTypes[2] = {"scalable","nonscalable"}; | |||||||||
119 | PetscInt nalg=2; | |||||||||
120 | #else | |||||||||
121 | const char *algTypes[3] = {"scalable","nonscalable","hypre"}; | |||||||||
122 | PetscInt nalg=3; | |||||||||
123 | #endif | |||||||||
124 | PetscInt pN=P->cmap->N,alg=1; /* set default algorithm */ | |||||||||
125 | ||||||||||
126 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 126; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
127 | /* check if matrix local sizes are compatible */ | |||||||||
128 | ierr = PetscObjectGetComm((PetscObject)A,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),128,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
129 | if (A->rmap->rstart != P->rmap->rstart || A->rmap->rend != P->rmap->rend) SETERRQ4(comm,PETSC_ERR_ARG_SIZ,"Matrix local dimensions are incompatible, Arow (%D, %D) != Prow (%D,%D)",A->rmap->rstart,A->rmap->rend,P->rmap->rstart,P->rmap->rend)return PetscError(comm,129,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,60,PETSC_ERROR_INITIAL,"Matrix local dimensions are incompatible, Arow (%D, %D) != Prow (%D,%D)" ,A->rmap->rstart,A->rmap->rend,P->rmap->rstart ,P->rmap->rend); | |||||||||
130 | if (A->cmap->rstart != P->rmap->rstart || A->cmap->rend != P->rmap->rend) SETERRQ4(comm,PETSC_ERR_ARG_SIZ,"Matrix local dimensions are incompatible, Acol (%D, %D) != Prow (%D,%D)",A->cmap->rstart,A->cmap->rend,P->rmap->rstart,P->rmap->rend)return PetscError(comm,130,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,60,PETSC_ERROR_INITIAL,"Matrix local dimensions are incompatible, Acol (%D, %D) != Prow (%D,%D)" ,A->cmap->rstart,A->cmap->rend,P->rmap->rstart ,P->rmap->rend); | |||||||||
131 | ||||||||||
132 | if (scall == MAT_INITIAL_MATRIX) { | |||||||||
133 | /* pick an algorithm */ | |||||||||
134 | ierr = PetscOptionsBegin(PetscObjectComm((PetscObject)A),((PetscObject)A)->prefix,"MatPtAP","Mat")0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; PetscMemzero (PetscOptionsObject,sizeof(PetscOptionItems)); for (PetscOptionsObject ->count=(PetscOptionsPublish?-1:1); PetscOptionsObject-> count<2; PetscOptionsObject->count++) { PetscErrorCode _5_ierr = PetscOptionsBegin_Private(PetscOptionsObject,PetscObjectComm ((PetscObject)A),((PetscObject)A)->prefix,"MatPtAP","Mat") ;do {if (__builtin_expect(!!(_5_ierr),0)) return PetscError(( (MPI_Comm)0x44000001),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
135 | ierr = PetscOptionsEList("-matptap_via","Algorithmic approach","MatPtAP",algTypes,nalg,algTypes[alg],&alg,&flg)PetscOptionsEList_Private(PetscOptionsObject,"-matptap_via","Algorithmic approach" ,"MatPtAP",algTypes,nalg,algTypes[alg],&alg,&flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),135,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
136 | ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if ( __builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm )0x44000001),136,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),136,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
137 | ||||||||||
138 | if (!flg && pN > 100000) { /* may switch to scalable algorithm as default */ | |||||||||
139 | MatInfo Ainfo,Pinfo; | |||||||||
140 | PetscInt nz_local; | |||||||||
141 | PetscBool alg_scalable_loc=PETSC_FALSE,alg_scalable; | |||||||||
142 | ||||||||||
143 | ierr = MatGetInfo(A,MAT_LOCAL,&Ainfo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),143,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
144 | ierr = MatGetInfo(P,MAT_LOCAL,&Pinfo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),144,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
145 | nz_local = (PetscInt)(Ainfo.nz_allocated + Pinfo.nz_allocated); | |||||||||
146 | ||||||||||
147 | if (pN > fill*nz_local) alg_scalable_loc = PETSC_TRUE; | |||||||||
148 | ierr = MPIU_Allreduce(&alg_scalable_loc,&alg_scalable,1,MPIU_BOOL,MPI_LOR,comm)(PetscAllreduceBarrierCheck(comm,1,148,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((&alg_scalable_loc),(&alg_scalable),(1 ),(MPIU_BOOL),((MPI_Op)(0x58000007)),(comm))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
149 | ||||||||||
150 | if (alg_scalable) { | |||||||||
151 | alg = 0; /* scalable algorithm would 50% slower than nonscalable algorithm */ | |||||||||
152 | } | |||||||||
153 | } | |||||||||
154 | ||||||||||
155 | switch (alg) { | |||||||||
156 | case 1: | |||||||||
157 | /* do R=P^T locally, then C=R*A*P -- nonscalable */ | |||||||||
158 | ierr = PetscLogEventBegin(MAT_PtAPSymbolic,A,P,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPSymbolic].active) ? (*PetscLogPLB)((MAT_PtAPSymbolic ),0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),158,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
159 | ierr = MatPtAPSymbolic_MPIAIJ_MPIAIJ(A,P,fill,C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
160 | ierr = PetscLogEventEnd(MAT_PtAPSymbolic,A,P,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPSymbolic].active) ? (*PetscLogPLE)((MAT_PtAPSymbolic ),0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),160,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
161 | break; | |||||||||
162 | #if defined(PETSC_HAVE_HYPRE) | |||||||||
163 | case 2: | |||||||||
164 | /* Use boomerAMGBuildCoarseOperator */ | |||||||||
165 | ierr = PetscLogEventBegin(MAT_PtAPSymbolic,A,P,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPSymbolic].active) ? (*PetscLogPLB)((MAT_PtAPSymbolic ),0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),165,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
166 | ierr = MatPtAPSymbolic_AIJ_AIJ_wHYPRE(A,P,fill,C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),166,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
167 | ierr = PetscLogEventEnd(MAT_PtAPSymbolic,A,P,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPSymbolic].active) ? (*PetscLogPLE)((MAT_PtAPSymbolic ),0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),167,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
168 | break; | |||||||||
169 | #endif | |||||||||
170 | default: | |||||||||
171 | /* do R=P^T locally, then C=R*A*P */ | |||||||||
172 | ierr = PetscLogEventBegin(MAT_PtAPSymbolic,A,P,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPSymbolic].active) ? (*PetscLogPLB)((MAT_PtAPSymbolic ),0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),172,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
173 | ierr = MatPtAPSymbolic_MPIAIJ_MPIAIJ_scalable(A,P,fill,C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),173,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
174 | ierr = PetscLogEventEnd(MAT_PtAPSymbolic,A,P,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPSymbolic].active) ? (*PetscLogPLE)((MAT_PtAPSymbolic ),0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),174,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
175 | break; | |||||||||
176 | } | |||||||||
177 | ||||||||||
178 | if (alg == 0 || alg == 1) { | |||||||||
179 | Mat_MPIAIJ *c = (Mat_MPIAIJ*)(*C)->data; | |||||||||
180 | Mat_APMPI *ap = c->ap; | |||||||||
181 | ierr = PetscOptionsBegin(PetscObjectComm((PetscObject)(*C)),((PetscObject)(*C))->prefix,"MatFreeIntermediateDataStructures","Mat")0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; PetscMemzero (PetscOptionsObject,sizeof(PetscOptionItems)); for (PetscOptionsObject ->count=(PetscOptionsPublish?-1:1); PetscOptionsObject-> count<2; PetscOptionsObject->count++) { PetscErrorCode _5_ierr = PetscOptionsBegin_Private(PetscOptionsObject,PetscObjectComm ((PetscObject)(*C)),((PetscObject)(*C))->prefix,"MatFreeIntermediateDataStructures" ,"Mat");do {if (__builtin_expect(!!(_5_ierr),0)) return PetscError (((MPI_Comm)0x44000001),181,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),181,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
182 | ap->freestruct = PETSC_FALSE; | |||||||||
183 | ierr = PetscOptionsBool("-mat_freeintermediatedatastructures","Free intermediate data structures", "MatFreeIntermediateDataStructures",ap->freestruct,&ap->freestruct, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-mat_freeintermediatedatastructures" ,"Free intermediate data structures","MatFreeIntermediateDataStructures" ,ap->freestruct,&ap->freestruct,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),183,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
184 | ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if ( __builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm )0x44000001),184,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),184,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
185 | } | |||||||||
186 | } | |||||||||
187 | ||||||||||
188 | ierr = PetscLogEventBegin(MAT_PtAPNumeric,A,P,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPNumeric].active) ? (*PetscLogPLB)((MAT_PtAPNumeric), 0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),188,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
189 | ierr = (*(*C)->ops->ptapnumeric)(A,P,*C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
190 | ierr = PetscLogEventEnd(MAT_PtAPNumeric,A,P,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [MAT_PtAPNumeric].active) ? (*PetscLogPLE)((MAT_PtAPNumeric), 0,(PetscObject)(A),(PetscObject)(P),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),190,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
191 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
192 | } | |||||||||
193 | ||||||||||
194 | PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ_scalable(Mat A,Mat P,Mat C) | |||||||||
195 | { | |||||||||
196 | PetscErrorCode ierr; | |||||||||
197 | Mat_MPIAIJ *a=(Mat_MPIAIJ*)A->data,*p=(Mat_MPIAIJ*)P->data,*c=(Mat_MPIAIJ*)C->data; | |||||||||
198 | Mat_SeqAIJ *ad=(Mat_SeqAIJ*)(a->A)->data,*ao=(Mat_SeqAIJ*)(a->B)->data; | |||||||||
199 | Mat_SeqAIJ *ap,*p_loc,*p_oth,*c_seq; | |||||||||
200 | Mat_APMPI *ptap = c->ap; | |||||||||
201 | Mat AP_loc,C_loc,C_oth; | |||||||||
202 | PetscInt i,rstart,rend,cm,ncols,row,*api,*apj,am = A->rmap->n,apnz,nout; | |||||||||
203 | PetscScalar *apa; | |||||||||
204 | const PetscInt *cols; | |||||||||
205 | const PetscScalar *vals; | |||||||||
206 | ||||||||||
207 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 207; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
208 | if (!ptap) { | |||||||||
209 | MPI_Comm comm; | |||||||||
210 | ierr = PetscObjectGetComm((PetscObject)C,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),210,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
211 | SETERRQ(comm,PETSC_ERR_ARG_WRONGSTATE,"PtAP cannot be reused. Do not call MatFreeIntermediateDataStructures() or use '-mat_freeintermediatedatastructures'")return PetscError(comm,211,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,73,PETSC_ERROR_INITIAL,"PtAP cannot be reused. Do not call MatFreeIntermediateDataStructures() or use '-mat_freeintermediatedatastructures'" ); | |||||||||
212 | } | |||||||||
213 | ||||||||||
214 | ierr = MatZeroEntries(C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),214,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
215 | ||||||||||
216 | /* 1) get R = Pd^T,Ro = Po^T */ | |||||||||
217 | if (ptap->reuse == MAT_REUSE_MATRIX) { | |||||||||
218 | ierr = MatTranspose(p->A,MAT_REUSE_MATRIX,&ptap->Rd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),218,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
219 | ierr = MatTranspose(p->B,MAT_REUSE_MATRIX,&ptap->Ro);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),219,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
220 | } | |||||||||
221 | ||||||||||
222 | /* 2) get AP_loc */ | |||||||||
223 | AP_loc = ptap->AP_loc; | |||||||||
224 | ap = (Mat_SeqAIJ*)AP_loc->data; | |||||||||
225 | ||||||||||
226 | /* 2-1) get P_oth = ptap->P_oth and P_loc = ptap->P_loc */ | |||||||||
227 | /*-----------------------------------------------------*/ | |||||||||
228 | if (ptap->reuse == MAT_REUSE_MATRIX) { | |||||||||
229 | /* P_oth and P_loc are obtained in MatPtASymbolic() when reuse == MAT_INITIAL_MATRIX */ | |||||||||
230 | ierr = MatGetBrowsOfAoCols_MPIAIJ(A,P,MAT_REUSE_MATRIX,&ptap->startsj_s,&ptap->startsj_r,&ptap->bufa,&ptap->P_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),230,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
231 | ierr = MatMPIAIJGetLocalMat(P,MAT_REUSE_MATRIX,&ptap->P_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),231,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
232 | } | |||||||||
233 | ||||||||||
234 | /* 2-2) compute numeric A_loc*P - dominating part */ | |||||||||
235 | /* ---------------------------------------------- */ | |||||||||
236 | /* get data from symbolic products */ | |||||||||
237 | p_loc = (Mat_SeqAIJ*)(ptap->P_loc)->data; | |||||||||
238 | if (ptap->P_oth) p_oth = (Mat_SeqAIJ*)(ptap->P_oth)->data; | |||||||||
239 | else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"ptap->P_oth is NULL. Cannot proceed!")return PetscError(((MPI_Comm)0x44000001),239,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,73,PETSC_ERROR_INITIAL,"ptap->P_oth is NULL. Cannot proceed!" ); | |||||||||
240 | ||||||||||
241 | api = ap->i; | |||||||||
242 | apj = ap->j; | |||||||||
243 | ierr = ISLocalToGlobalMappingApply(ptap->ltog,api[AP_loc->rmap->n],apj,apj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),243,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
244 | for (i=0; i<am; i++) { | |||||||||
245 | /* AP[i,:] = A[i,:]*P = Ad*P_loc Ao*P_oth */ | |||||||||
246 | apnz = api[i+1] - api[i]; | |||||||||
247 | apa = ap->a + api[i]; | |||||||||
248 | ierr = PetscMemzero(apa,sizeof(PetscScalar)*apnz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),248,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
249 | AProw_scalable(i,ad,ao,p_loc,p_oth,api,apj,apa){ PetscInt _anz,_pnz,_j,_k,*_ai,*_aj,_row,*_pi,*_pj,_nextp,*_apJ ; PetscScalar *_aa,_valtmp,*_pa; _apJ = apj + api[i]; _ai = ad ->i; _anz = _ai[i+1] - _ai[i]; _aj = ad->j + _ai[i]; _aa = ad->a + _ai[i]; for (_j=0; _j<_anz; _j++) { _row = _aj [_j]; _pi = p_loc->i; _pnz = _pi[_row+1] - _pi[_row]; _pj = p_loc->j + _pi[_row]; _pa = p_loc->a + _pi[_row]; _valtmp = _aa[_j]; _nextp = 0; for (_k=0; _nextp<_pnz; _k++) { if (_apJ[_k] == _pj[_nextp]) { apa[_k] += _valtmp*_pa[_nextp++] ; } } (void)PetscLogFlops(2.0*_pnz); } _ai = ao->i; _anz = _ai[i+1] - _ai[i]; _aj = ao->j + _ai[i]; _aa = ao->a + _ai[i]; for (_j=0; _j<_anz; _j++) { _row = _aj[_j]; _pi = p_oth->i; _pnz = _pi[_row+1] - _pi[_row]; _pj = p_oth-> j + _pi[_row]; _pa = p_oth->a + _pi[_row]; _valtmp = _aa[_j ]; _nextp = 0; for (_k=0; _nextp<_pnz; _k++) { if (_apJ[_k ] == _pj[_nextp]) { apa[_k] += _valtmp*_pa[_nextp++]; } } (void )PetscLogFlops(2.0*_pnz); } }; | |||||||||
250 | ierr = PetscLogFlops(2.0*apnz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),250,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
251 | } | |||||||||
252 | ierr = ISGlobalToLocalMappingApply(ptap->ltog,IS_GTOLM_DROP,api[AP_loc->rmap->n],apj,&nout,apj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),252,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
253 | if (api[AP_loc->rmap->n] != nout) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incorrect mapping %D != %D\n",api[AP_loc->rmap->n],nout)return PetscError(((MPI_Comm)0x44000001),253,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,75,PETSC_ERROR_INITIAL,"Incorrect mapping %D != %D\n",api[AP_loc ->rmap->n],nout); | |||||||||
254 | ||||||||||
255 | /* 3) C_loc = Rd*AP_loc, C_oth = Ro*AP_loc */ | |||||||||
256 | /* Always use scalable version since we are in the MPI scalable version */ | |||||||||
257 | ierr = MatMatMultNumeric_SeqAIJ_SeqAIJ_Scalable(ptap->Rd,AP_loc,ptap->C_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),257,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
258 | ierr = MatMatMultNumeric_SeqAIJ_SeqAIJ_Scalable(ptap->Ro,AP_loc,ptap->C_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),258,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
259 | ||||||||||
260 | C_loc = ptap->C_loc; | |||||||||
261 | C_oth = ptap->C_oth; | |||||||||
262 | ||||||||||
263 | /* add C_loc and Co to to C */ | |||||||||
264 | ierr = MatGetOwnershipRange(C,&rstart,&rend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),264,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
265 | ||||||||||
266 | /* C_loc -> C */ | |||||||||
267 | cm = C_loc->rmap->N; | |||||||||
268 | c_seq = (Mat_SeqAIJ*)C_loc->data; | |||||||||
269 | cols = c_seq->j; | |||||||||
270 | vals = c_seq->a; | |||||||||
271 | ierr = ISLocalToGlobalMappingApply(ptap->ltog,c_seq->i[C_loc->rmap->n],c_seq->j,c_seq->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),271,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
272 | ||||||||||
273 | /* The (fast) MatSetValues_MPIAIJ_CopyFromCSRFormat function can only be used when C->was_assembled is PETSC_FALSE and */ | |||||||||
274 | /* when there are no off-processor parts. */ | |||||||||
275 | /* If was_assembled is true, then the statement aj[rowstart_diag+dnz_row] = mat_j[col] - cstart; in MatSetValues_MPIAIJ_CopyFromCSRFormat */ | |||||||||
276 | /* is no longer true. Then the more complex function MatSetValues_MPIAIJ() has to be used, where the column index is looked up from */ | |||||||||
277 | /* a table, and other, more complex stuff has to be done. */ | |||||||||
278 | if (C->assembled) { | |||||||||
279 | C->was_assembled = PETSC_TRUE; | |||||||||
280 | C->assembled = PETSC_FALSE; | |||||||||
281 | } | |||||||||
282 | if (C->was_assembled) { | |||||||||
283 | for (i=0; i<cm; i++) { | |||||||||
284 | ncols = c_seq->i[i+1] - c_seq->i[i]; | |||||||||
285 | row = rstart + i; | |||||||||
286 | ierr = MatSetValues_MPIAIJ(C,1,&row,ncols,cols,vals,ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
287 | cols += ncols; vals += ncols; | |||||||||
288 | } | |||||||||
289 | } else { | |||||||||
290 | ierr = MatSetValues_MPIAIJ_CopyFromCSRFormat(C,c_seq->j,c_seq->i,c_seq->a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),290,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
291 | } | |||||||||
292 | ierr = ISGlobalToLocalMappingApply(ptap->ltog,IS_GTOLM_DROP,c_seq->i[C_loc->rmap->n],c_seq->j,&nout,c_seq->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),292,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
293 | if (c_seq->i[C_loc->rmap->n] != nout) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incorrect mapping %D != %D\n",c_seq->i[C_loc->rmap->n],nout)return PetscError(((MPI_Comm)0x44000001),293,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,75,PETSC_ERROR_INITIAL,"Incorrect mapping %D != %D\n",c_seq-> i[C_loc->rmap->n],nout); | |||||||||
294 | ||||||||||
295 | /* Co -> C, off-processor part */ | |||||||||
296 | cm = C_oth->rmap->N; | |||||||||
297 | c_seq = (Mat_SeqAIJ*)C_oth->data; | |||||||||
298 | cols = c_seq->j; | |||||||||
299 | vals = c_seq->a; | |||||||||
300 | ierr = ISLocalToGlobalMappingApply(ptap->ltog,c_seq->i[C_oth->rmap->n],c_seq->j,c_seq->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
301 | for (i=0; i<cm; i++) { | |||||||||
302 | ncols = c_seq->i[i+1] - c_seq->i[i]; | |||||||||
303 | row = p->garray[i]; | |||||||||
304 | ierr = MatSetValues(C,1,&row,ncols,cols,vals,ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),304,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
305 | cols += ncols; vals += ncols; | |||||||||
306 | } | |||||||||
307 | ierr = MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),307,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
308 | ierr = MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),308,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
309 | ||||||||||
310 | ptap->reuse = MAT_REUSE_MATRIX; | |||||||||
311 | ||||||||||
312 | ierr = ISGlobalToLocalMappingApply(ptap->ltog,IS_GTOLM_DROP,c_seq->i[C_oth->rmap->n],c_seq->j,&nout,c_seq->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),312,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
313 | if (c_seq->i[C_oth->rmap->n] != nout) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incorrect mapping %D != %D\n",c_seq->i[C_loc->rmap->n],nout)return PetscError(((MPI_Comm)0x44000001),313,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,75,PETSC_ERROR_INITIAL,"Incorrect mapping %D != %D\n",c_seq-> i[C_loc->rmap->n],nout); | |||||||||
314 | ||||||||||
315 | /* supporting struct ptap consumes almost same amount of memory as C=PtAP, release it if C will not be updated by A and P */ | |||||||||
316 | if (ptap->freestruct) { | |||||||||
317 | ierr = MatFreeIntermediateDataStructures(C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),317,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
318 | } | |||||||||
319 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
320 | } | |||||||||
321 | ||||||||||
322 | PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ_scalable(Mat A,Mat P,PetscReal fill,Mat *C) | |||||||||
323 | { | |||||||||
324 | PetscErrorCode ierr; | |||||||||
325 | Mat_APMPI *ptap; | |||||||||
326 | Mat_MPIAIJ *a=(Mat_MPIAIJ*)A->data,*p=(Mat_MPIAIJ*)P->data,*c; | |||||||||
327 | MPI_Comm comm; | |||||||||
328 | PetscMPIInt size,rank; | |||||||||
329 | Mat Cmpi,P_loc,P_oth; | |||||||||
330 | PetscFreeSpaceList free_space=NULL((void*)0),current_space=NULL((void*)0); | |||||||||
331 | PetscInt am=A->rmap->n,pm=P->rmap->n,pN=P->cmap->N,pn=P->cmap->n; | |||||||||
332 | PetscInt *lnk,i,k,pnz,row,nsend; | |||||||||
333 | PetscMPIInt tagi,tagj,*len_si,*len_s,*len_ri,icompleted=0,nrecv; | |||||||||
334 | PetscInt **buf_rj,**buf_ri,**buf_ri_k; | |||||||||
335 | PetscInt len,proc,*dnz,*onz,*owners,nzi,nspacedouble; | |||||||||
336 | PetscInt nrows,*buf_s,*buf_si,*buf_si_i,**nextrow,**nextci; | |||||||||
337 | MPI_Request *swaits,*rwaits; | |||||||||
338 | MPI_Status *sstatus,rstatus; | |||||||||
339 | PetscLayout rowmap; | |||||||||
340 | PetscInt *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */ | |||||||||
341 | PetscMPIInt *len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */ | |||||||||
342 | PetscInt *api,*apj,*Jptr,apnz,*prmap=p->garray,con,j,Crmax,*aj,*ai,*pi,nout; | |||||||||
343 | Mat_SeqAIJ *p_loc,*p_oth=NULL((void*)0),*ad=(Mat_SeqAIJ*)(a->A)->data,*ao=NULL((void*)0),*c_loc,*c_oth; | |||||||||
344 | PetscScalar *apv; | |||||||||
345 | PetscTable ta; | |||||||||
346 | MatType mtype; | |||||||||
347 | const char *prefix; | |||||||||
348 | #if defined(PETSC_USE_INFO1) | |||||||||
349 | PetscReal apfill; | |||||||||
350 | #endif | |||||||||
351 | ||||||||||
352 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 352; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
353 | ierr = PetscObjectGetComm((PetscObject)A,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),353,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
354 | ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),354,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
355 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),355,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
356 | ||||||||||
357 | if (size > 1) ao = (Mat_SeqAIJ*)(a->B)->data; | |||||||||
358 | ||||||||||
359 | /* create symbolic parallel matrix Cmpi */ | |||||||||
360 | ierr = MatCreate(comm,&Cmpi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),360,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
361 | ierr = MatGetType(A,&mtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),361,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
362 | ierr = MatSetType(Cmpi,mtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),362,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
363 | ||||||||||
364 | /* create struct Mat_APMPI and attached it to C later */ | |||||||||
365 | ierr = PetscNew(&ptap)PetscMallocA(1,PETSC_TRUE,365,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(1)*sizeof(**((&ptap))),((&ptap)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),365,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
366 | ptap->reuse = MAT_INITIAL_MATRIX; | |||||||||
367 | ptap->algType = 0; | |||||||||
368 | ||||||||||
369 | /* get P_oth by taking rows of P (= non-zero cols of local A) from other processors */ | |||||||||
370 | ierr = MatGetBrowsOfAoCols_MPIAIJ(A,P,MAT_INITIAL_MATRIX,&ptap->startsj_s,&ptap->startsj_r,&ptap->bufa,&P_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),370,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
371 | /* get P_loc by taking all local rows of P */ | |||||||||
372 | ierr = MatMPIAIJGetLocalMat(P,MAT_INITIAL_MATRIX,&P_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),372,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
373 | ||||||||||
374 | ptap->P_loc = P_loc; | |||||||||
375 | ptap->P_oth = P_oth; | |||||||||
376 | ||||||||||
377 | /* (0) compute Rd = Pd^T, Ro = Po^T */ | |||||||||
378 | /* --------------------------------- */ | |||||||||
379 | ierr = MatTranspose(p->A,MAT_INITIAL_MATRIX,&ptap->Rd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),379,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
380 | ierr = MatTranspose(p->B,MAT_INITIAL_MATRIX,&ptap->Ro);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),380,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
381 | ||||||||||
382 | /* (1) compute symbolic AP = A_loc*P = Ad*P_loc + Ao*P_oth (api,apj) */ | |||||||||
383 | /* ----------------------------------------------------------------- */ | |||||||||
384 | p_loc = (Mat_SeqAIJ*)P_loc->data; | |||||||||
385 | if (P_oth) p_oth = (Mat_SeqAIJ*)P_oth->data; | |||||||||
386 | ||||||||||
387 | /* create and initialize a linked list */ | |||||||||
388 | ierr = PetscTableCreate(pn,pN,&ta);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),388,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* for compute AP_loc and Cmpi */ | |||||||||
389 | MatRowMergeMax_SeqAIJ(p_loc,P_loc->rmap->N,ta){ PetscInt _j,_row,_nz,*_col; if (p_loc) { for (_row=0; _row< P_loc->rmap->N; _row++) { _nz = p_loc->i[_row+1] - p_loc ->i[_row]; for (_j=0; _j<_nz; _j++) { _col = _j + p_loc ->j + p_loc->i[_row]; PetscTableAdd(ta,*_col+1,1,INSERT_VALUES ); } } } }; | |||||||||
390 | MatRowMergeMax_SeqAIJ(p_oth,P_oth->rmap->N,ta){ PetscInt _j,_row,_nz,*_col; if (p_oth) { for (_row=0; _row< P_oth->rmap->N; _row++) { _nz = p_oth->i[_row+1] - p_oth ->i[_row]; for (_j=0; _j<_nz; _j++) { _col = _j + p_oth ->j + p_oth->i[_row]; PetscTableAdd(ta,*_col+1,1,INSERT_VALUES ); } } } }; | |||||||||
391 | ierr = PetscTableGetCount(ta,&Crmax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),391,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* Crmax = nnz(sum of Prows) */ | |||||||||
392 | ||||||||||
393 | ierr = PetscLLCondensedCreate_Scalable(Crmax,&lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),393,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
394 | ||||||||||
395 | /* Initial FreeSpace size is fill*(nnz(A) + nnz(P)) */ | |||||||||
396 | if (ao) { | |||||||||
397 | ierr = PetscFreeSpaceGet(PetscRealIntMultTruncate(fill,PetscIntSumTruncate(ad->i[am],PetscIntSumTruncate(ao->i[am],p_loc->i[pm]))),&free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),397,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
398 | } else { | |||||||||
399 | ierr = PetscFreeSpaceGet(PetscRealIntMultTruncate(fill,PetscIntSumTruncate(ad->i[am],p_loc->i[pm])),&free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),399,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
400 | } | |||||||||
401 | current_space = free_space; | |||||||||
402 | nspacedouble = 0; | |||||||||
403 | ||||||||||
404 | ierr = PetscMalloc1(am+1,&api)PetscMallocA(1,PETSC_FALSE,404,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(am+1)*sizeof(**(&api)),(&api));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),404,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
405 | api[0] = 0; | |||||||||
406 | for (i=0; i<am; i++) { | |||||||||
407 | /* diagonal portion: Ad[i,:]*P */ | |||||||||
408 | ai = ad->i; pi = p_loc->i; | |||||||||
409 | nzi = ai[i+1] - ai[i]; | |||||||||
410 | aj = ad->j + ai[i]; | |||||||||
411 | for (j=0; j<nzi; j++) { | |||||||||
412 | row = aj[j]; | |||||||||
413 | pnz = pi[row+1] - pi[row]; | |||||||||
414 | Jptr = p_loc->j + pi[row]; | |||||||||
415 | /* add non-zero cols of P into the sorted linked list lnk */ | |||||||||
416 | ierr = PetscLLCondensedAddSorted_Scalable(pnz,Jptr,lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),416,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
417 | } | |||||||||
418 | /* off-diagonal portion: Ao[i,:]*P */ | |||||||||
419 | if (ao) { | |||||||||
420 | ai = ao->i; pi = p_oth->i; | |||||||||
421 | nzi = ai[i+1] - ai[i]; | |||||||||
422 | aj = ao->j + ai[i]; | |||||||||
423 | for (j=0; j<nzi; j++) { | |||||||||
424 | row = aj[j]; | |||||||||
425 | pnz = pi[row+1] - pi[row]; | |||||||||
426 | Jptr = p_oth->j + pi[row]; | |||||||||
427 | ierr = PetscLLCondensedAddSorted_Scalable(pnz,Jptr,lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),427,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
428 | } | |||||||||
429 | } | |||||||||
430 | apnz = lnk[0]; | |||||||||
431 | api[i+1] = api[i] + apnz; | |||||||||
432 | ||||||||||
433 | /* if free space is not available, double the total space in the list */ | |||||||||
434 | if (current_space->local_remaining<apnz) { | |||||||||
435 | ierr = PetscFreeSpaceGet(PetscIntSumTruncate(apnz,current_space->total_array_size),¤t_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),435,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
436 | nspacedouble++; | |||||||||
437 | } | |||||||||
438 | ||||||||||
439 | /* Copy data into free space, then initialize lnk */ | |||||||||
440 | ierr = PetscLLCondensedClean_Scalable(apnz,current_space->array,lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),440,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
441 | ||||||||||
442 | current_space->array += apnz; | |||||||||
443 | current_space->local_used += apnz; | |||||||||
444 | current_space->local_remaining -= apnz; | |||||||||
445 | } | |||||||||
446 | /* Allocate space for apj and apv, initialize apj, and */ | |||||||||
447 | /* destroy list of free space and other temporary array(s) */ | |||||||||
448 | ierr = PetscCalloc2(api[am],&apj,api[am],&apv)PetscMallocA(2,PETSC_TRUE,448,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(api[am])*sizeof(**(&apj)),(&apj),(size_t)(api [am])*sizeof(**(&apv)),(&apv));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),448,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
449 | ierr = PetscFreeSpaceContiguous(&free_space,apj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
450 | ierr = PetscLLCondensedDestroy_Scalable(lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),450,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
451 | ||||||||||
452 | /* Create AP_loc for reuse */ | |||||||||
453 | ierr = MatCreateSeqAIJWithArrays(PETSC_COMM_SELF((MPI_Comm)0x44000001),am,pN,api,apj,apv,&ptap->AP_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),453,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
454 | ierr = MatSeqAIJCompactOutExtraColumns_SeqAIJ(ptap->AP_loc, &ptap->ltog);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),454,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
455 | ||||||||||
456 | #if defined(PETSC_USE_INFO1) | |||||||||
457 | if (ao) { | |||||||||
458 | apfill = (PetscReal)api[am]/(ad->i[am]+ao->i[am]+p_loc->i[pm]+1); | |||||||||
459 | } else { | |||||||||
460 | apfill = (PetscReal)api[am]/(ad->i[am]+p_loc->i[pm]+1); | |||||||||
461 | } | |||||||||
462 | ptap->AP_loc->info.mallocs = nspacedouble; | |||||||||
463 | ptap->AP_loc->info.fill_ratio_given = fill; | |||||||||
464 | ptap->AP_loc->info.fill_ratio_needed = apfill; | |||||||||
465 | ||||||||||
466 | if (api[am]) { | |||||||||
467 | ierr = PetscInfo3(ptap->AP_loc,"Scalable algorithm, AP_loc reallocs %D; Fill ratio: given %g needed %g.\n",nspacedouble,(double)fill,(double)apfill)PetscInfo_Private(__func__,ptap->AP_loc,"Scalable algorithm, AP_loc reallocs %D; Fill ratio: given %g needed %g.\n" ,nspacedouble,(double)fill,(double)apfill);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),467,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
468 | ierr = PetscInfo1(ptap->AP_loc,"Use MatPtAP(A,B,MatReuse,%g,&C) for best AP_loc performance.;\n",(double)apfill)PetscInfo_Private(__func__,ptap->AP_loc,"Use MatPtAP(A,B,MatReuse,%g,&C) for best AP_loc performance.;\n" ,(double)apfill);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),468,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
469 | } else { | |||||||||
470 | ierr = PetscInfo(ptap->AP_loc,"Scalable algorithm, AP_loc is empty \n")PetscInfo_Private(__func__,ptap->AP_loc,"Scalable algorithm, AP_loc is empty \n" );CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),470,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
471 | } | |||||||||
472 | #endif | |||||||||
473 | ||||||||||
474 | /* (2-1) compute symbolic Co = Ro*AP_loc */ | |||||||||
475 | /* ------------------------------------ */ | |||||||||
476 | ierr = MatGetOptionsPrefix(A,&prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),476,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
477 | ierr = MatSetOptionsPrefix(ptap->Ro,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),477,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
478 | ierr = MatAppendOptionsPrefix(ptap->Ro,"inner_offdiag_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),478,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
479 | ierr = MatMatMultSymbolic_SeqAIJ_SeqAIJ(ptap->Ro,ptap->AP_loc,fill,&ptap->C_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),479,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
480 | ||||||||||
481 | /* (3) send coj of C_oth to other processors */ | |||||||||
482 | /* ------------------------------------------ */ | |||||||||
483 | /* determine row ownership */ | |||||||||
484 | ierr = PetscLayoutCreate(comm,&rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),484,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
485 | rowmap->n = pn; | |||||||||
486 | rowmap->bs = 1; | |||||||||
487 | ierr = PetscLayoutSetUp(rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),487,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
488 | owners = rowmap->range; | |||||||||
489 | ||||||||||
490 | /* determine the number of messages to send, their lengths */ | |||||||||
491 | ierr = PetscMalloc4(size,&len_s,size,&len_si,size,&sstatus,size+2,&owners_co)PetscMallocA(4,PETSC_FALSE,491,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(size)*sizeof(**(&len_s)),(&len_s),(size_t)( size)*sizeof(**(&len_si)),(&len_si),(size_t)(size)*sizeof (**(&sstatus)),(&sstatus),(size_t)(size+2)*sizeof(**( &owners_co)),(&owners_co));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),491,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
492 | ierr = PetscMemzero(len_s,size*sizeof(PetscMPIInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),492,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
493 | ierr = PetscMemzero(len_si,size*sizeof(PetscMPIInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),493,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
494 | ||||||||||
495 | c_oth = (Mat_SeqAIJ*)ptap->C_oth->data; | |||||||||
496 | coi = c_oth->i; coj = c_oth->j; | |||||||||
497 | con = ptap->C_oth->rmap->n; | |||||||||
498 | proc = 0; | |||||||||
499 | ierr = ISLocalToGlobalMappingApply(ptap->ltog,coi[con],coj,coj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),499,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
500 | for (i=0; i<con; i++) { | |||||||||
501 | while (prmap[i] >= owners[proc+1]) proc++; | |||||||||
502 | len_si[proc]++; /* num of rows in Co(=Pt*AP) to be sent to [proc] */ | |||||||||
503 | len_s[proc] += coi[i+1] - coi[i]; /* num of nonzeros in Co to be sent to [proc] */ | |||||||||
504 | } | |||||||||
505 | ||||||||||
506 | len = 0; /* max length of buf_si[], see (4) */ | |||||||||
507 | owners_co[0] = 0; | |||||||||
508 | nsend = 0; | |||||||||
509 | for (proc=0; proc<size; proc++) { | |||||||||
510 | owners_co[proc+1] = owners_co[proc] + len_si[proc]; | |||||||||
511 | if (len_s[proc]) { | |||||||||
512 | nsend++; | |||||||||
513 | len_si[proc] = 2*(len_si[proc] + 1); /* length of buf_si to be sent to [proc] */ | |||||||||
514 | len += len_si[proc]; | |||||||||
515 | } | |||||||||
516 | } | |||||||||
517 | ||||||||||
518 | /* determine the number and length of messages to receive for coi and coj */ | |||||||||
519 | ierr = PetscGatherNumberOfMessages(comm,NULL((void*)0),len_s,&nrecv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),519,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
520 | ierr = PetscGatherMessageLengths2(comm,nsend,nrecv,len_s,len_si,&id_r,&len_r,&len_ri);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),520,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
521 | ||||||||||
522 | /* post the Irecv and Isend of coj */ | |||||||||
523 | ierr = PetscCommGetNewTag(comm,&tagj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),523,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
524 | ierr = PetscPostIrecvInt(comm,tagj,nrecv,id_r,len_r,&buf_rj,&rwaits);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),524,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
525 | ierr = PetscMalloc1(nsend+1,&swaits)PetscMallocA(1,PETSC_FALSE,525,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(nsend+1)*sizeof(**(&swaits)),(&swaits));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),525,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
526 | for (proc=0, k=0; proc<size; proc++) { | |||||||||
527 | if (!len_s[proc]) continue; | |||||||||
528 | i = owners_co[proc]; | |||||||||
529 | ierr = MPI_Isend(coj+coi[i],len_s[proc],MPIU_INT,proc,tagj,comm,swaits+k)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(len_s[proc]),(((MPI_Datatype)0x4c000405))) || MPI_Isend((coj +coi[i]),(len_s[proc]),(((MPI_Datatype)0x4c000405)),(proc),(tagj ),(comm),(swaits+k)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),529,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
530 | k++; | |||||||||
531 | } | |||||||||
532 | ||||||||||
533 | /* (2-2) compute symbolic C_loc = Rd*AP_loc */ | |||||||||
534 | /* ---------------------------------------- */ | |||||||||
535 | ierr = MatSetOptionsPrefix(ptap->Rd,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),535,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
536 | ierr = MatAppendOptionsPrefix(ptap->Rd,"inner_diag_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),536,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
537 | ierr = MatMatMultSymbolic_SeqAIJ_SeqAIJ(ptap->Rd,ptap->AP_loc,fill,&ptap->C_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),537,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
538 | c_loc = (Mat_SeqAIJ*)ptap->C_loc->data; | |||||||||
539 | ierr = ISLocalToGlobalMappingApply(ptap->ltog,c_loc->i[ptap->C_loc->rmap->n],c_loc->j,c_loc->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),539,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
540 | ||||||||||
541 | /* receives coj are complete */ | |||||||||
542 | for (i=0; i<nrecv; i++) { | |||||||||
543 | ierr = MPI_Waitany(nrecv,rwaits,&icompleted,&rstatus)((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany ((nrecv),(rwaits),(&icompleted),(&rstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),543,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
544 | } | |||||||||
545 | ierr = PetscFree(rwaits)((*PetscTrFree)((void*)(rwaits),545,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((rwaits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),545,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
546 | if (nsend) {ierr = MPI_Waitall(nsend,swaits,sstatus)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nsend),0) || MPI_Waitall((nsend),(swaits),(sstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),546,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||||||||
547 | ||||||||||
548 | /* add received column indices into ta to update Crmax */ | |||||||||
549 | for (k=0; k<nrecv; k++) {/* k-th received message */ | |||||||||
550 | Jptr = buf_rj[k]; | |||||||||
551 | for (j=0; j<len_r[k]; j++) { | |||||||||
552 | ierr = PetscTableAdd(ta,*(Jptr+j)+1,1,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),552,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
553 | } | |||||||||
554 | } | |||||||||
555 | ierr = PetscTableGetCount(ta,&Crmax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),555,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
556 | ierr = PetscTableDestroy(&ta);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),556,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
557 | ||||||||||
558 | /* (4) send and recv coi */ | |||||||||
559 | /*-----------------------*/ | |||||||||
560 | ierr = PetscCommGetNewTag(comm,&tagi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),560,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
561 | ierr = PetscPostIrecvInt(comm,tagi,nrecv,id_r,len_ri,&buf_ri,&rwaits);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),561,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
562 | ierr = PetscMalloc1(len+1,&buf_s)PetscMallocA(1,PETSC_FALSE,562,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(len+1)*sizeof(**(&buf_s)),(&buf_s));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),562,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
563 | buf_si = buf_s; /* points to the beginning of k-th msg to be sent */ | |||||||||
564 | for (proc=0,k=0; proc<size; proc++) { | |||||||||
565 | if (!len_s[proc]) continue; | |||||||||
566 | /* form outgoing message for i-structure: | |||||||||
567 | buf_si[0]: nrows to be sent | |||||||||
568 | [1:nrows]: row index (global) | |||||||||
569 | [nrows+1:2*nrows+1]: i-structure index | |||||||||
570 | */ | |||||||||
571 | /*-------------------------------------------*/ | |||||||||
572 | nrows = len_si[proc]/2 - 1; /* num of rows in Co to be sent to [proc] */ | |||||||||
573 | buf_si_i = buf_si + nrows+1; | |||||||||
574 | buf_si[0] = nrows; | |||||||||
575 | buf_si_i[0] = 0; | |||||||||
576 | nrows = 0; | |||||||||
577 | for (i=owners_co[proc]; i<owners_co[proc+1]; i++) { | |||||||||
578 | nzi = coi[i+1] - coi[i]; | |||||||||
579 | buf_si_i[nrows+1] = buf_si_i[nrows] + nzi; /* i-structure */ | |||||||||
580 | buf_si[nrows+1] = prmap[i] -owners[proc]; /* local row index */ | |||||||||
581 | nrows++; | |||||||||
582 | } | |||||||||
583 | ierr = MPI_Isend(buf_si,len_si[proc],MPIU_INT,proc,tagi,comm,swaits+k)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(len_si[proc]),(((MPI_Datatype)0x4c000405))) || MPI_Isend(( buf_si),(len_si[proc]),(((MPI_Datatype)0x4c000405)),(proc),(tagi ),(comm),(swaits+k)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),583,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
584 | k++; | |||||||||
585 | buf_si += len_si[proc]; | |||||||||
586 | } | |||||||||
587 | for (i=0; i<nrecv; i++) { | |||||||||
588 | ierr = MPI_Waitany(nrecv,rwaits,&icompleted,&rstatus)((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany ((nrecv),(rwaits),(&icompleted),(&rstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),588,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
589 | } | |||||||||
590 | ierr = PetscFree(rwaits)((*PetscTrFree)((void*)(rwaits),590,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((rwaits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),590,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
591 | if (nsend) {ierr = MPI_Waitall(nsend,swaits,sstatus)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nsend),0) || MPI_Waitall((nsend),(swaits),(sstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),591,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||||||||
592 | ||||||||||
593 | ierr = PetscFree4(len_s,len_si,sstatus,owners_co)PetscFreeA(4,593,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(len_s),&(len_si),&(sstatus),&(owners_co));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),593,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
594 | ierr = PetscFree(len_ri)((*PetscTrFree)((void*)(len_ri),594,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((len_ri) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),594,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
595 | ierr = PetscFree(swaits)((*PetscTrFree)((void*)(swaits),595,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((swaits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),595,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
596 | ierr = PetscFree(buf_s)((*PetscTrFree)((void*)(buf_s),596,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_s) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),596,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
597 | ||||||||||
598 | /* (5) compute the local portion of Cmpi */ | |||||||||
599 | /* ------------------------------------------ */ | |||||||||
600 | /* set initial free space to be Crmax, sufficient for holding nozeros in each row of Cmpi */ | |||||||||
601 | ierr = PetscFreeSpaceGet(Crmax,&free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),601,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
602 | current_space = free_space; | |||||||||
603 | ||||||||||
604 | ierr = PetscMalloc3(nrecv,&buf_ri_k,nrecv,&nextrow,nrecv,&nextci)PetscMallocA(3,PETSC_FALSE,604,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(nrecv)*sizeof(**(&buf_ri_k)),(&buf_ri_k),(size_t )(nrecv)*sizeof(**(&nextrow)),(&nextrow),(size_t)(nrecv )*sizeof(**(&nextci)),(&nextci));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),604,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
605 | for (k=0; k<nrecv; k++) { | |||||||||
606 | buf_ri_k[k] = buf_ri[k]; /* beginning of k-th recved i-structure */ | |||||||||
607 | nrows = *buf_ri_k[k]; | |||||||||
608 | nextrow[k] = buf_ri_k[k] + 1; /* next row number of k-th recved i-structure */ | |||||||||
609 | nextci[k] = buf_ri_k[k] + (nrows + 1); /* poins to the next i-structure of k-th recved i-structure */ | |||||||||
610 | } | |||||||||
611 | ||||||||||
612 | ierr = MatPreallocateInitialize(comm,pn,pn,dnz,onz)0; { PetscErrorCode _4_ierr; PetscInt __nrows = (pn),__ncols = (pn),__rstart,__start,__end; _4_ierr = PetscMallocA(2,PETSC_TRUE ,612,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)((size_t)__nrows)*sizeof(**(&dnz)),(&dnz),(size_t )((size_t)__nrows)*sizeof(**(&onz)),(&onz));do {if (__builtin_expect (!!(_4_ierr),0)) return PetscError(((MPI_Comm)0x44000001),612 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0); __start = 0; __end = __start; _4_ierr = MPI_Scan(&__ncols,&__end,1,((MPI_Datatype )0x4c000405),(MPI_Op)(0x58000003),comm);do {if (__builtin_expect (!!(_4_ierr),0)) return PetscError(((MPI_Comm)0x44000001),612 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0); __start = __end - __ncols; _4_ierr = MPI_Scan(&__nrows,&__rstart,1,( (MPI_Datatype)0x4c000405),(MPI_Op)(0x58000003),comm);do {if ( __builtin_expect(!!(_4_ierr),0)) return PetscError(((MPI_Comm )0x44000001),612,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0); __rstart = __rstart - __nrows;;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),612,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
613 | ierr = PetscLLCondensedCreate_Scalable(Crmax,&lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),613,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
614 | for (i=0; i<pn; i++) { | |||||||||
615 | /* add C_loc into Cmpi */ | |||||||||
616 | nzi = c_loc->i[i+1] - c_loc->i[i]; | |||||||||
617 | Jptr = c_loc->j + c_loc->i[i]; | |||||||||
618 | ierr = PetscLLCondensedAddSorted_Scalable(nzi,Jptr,lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),618,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
619 | ||||||||||
620 | /* add received col data into lnk */ | |||||||||
621 | for (k=0; k<nrecv; k++) { /* k-th received message */ | |||||||||
622 | if (i == *nextrow[k]) { /* i-th row */ | |||||||||
623 | nzi = *(nextci[k]+1) - *nextci[k]; | |||||||||
624 | Jptr = buf_rj[k] + *nextci[k]; | |||||||||
625 | ierr = PetscLLCondensedAddSorted_Scalable(nzi,Jptr,lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),625,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
626 | nextrow[k]++; nextci[k]++; | |||||||||
627 | } | |||||||||
628 | } | |||||||||
629 | nzi = lnk[0]; | |||||||||
630 | ||||||||||
631 | /* copy data into free space, then initialize lnk */ | |||||||||
632 | ierr = PetscLLCondensedClean_Scalable(nzi,current_space->array,lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),632,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
633 | ierr = MatPreallocateSet(i+owners[rank],nzi,current_space->array,dnz,onz)0;{ PetscInt __i; if (i+owners[rank] < __rstart) return PetscError (((MPI_Comm)0x44000001),633,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,63,PETSC_ERROR_INITIAL,"Trying to set preallocation for row %D less than first local row %D" ,i+owners[rank],__rstart); if (i+owners[rank] >= __rstart+ __nrows) return PetscError(((MPI_Comm)0x44000001),633,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,63,PETSC_ERROR_INITIAL,"Trying to set preallocation for row %D greater than last local row %D" ,i+owners[rank],__rstart+__nrows-1); for (__i=0; __i<nzi; __i ++) { if ((current_space->array)[__i] < __start || (current_space ->array)[__i] >= __end) onz[i+owners[rank] - __rstart]++ ; else if (dnz[i+owners[rank] - __rstart] < __ncols) dnz[i +owners[rank] - __rstart]++; }};CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),633,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
634 | } | |||||||||
635 | ierr = PetscFree3(buf_ri_k,nextrow,nextci)PetscFreeA(3,635,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(buf_ri_k),&(nextrow),&(nextci));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),635,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
636 | ierr = PetscLLCondensedDestroy_Scalable(lnk);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),636,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
637 | ierr = PetscFreeSpaceDestroy(free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),637,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
638 | ||||||||||
639 | /* local sizes and preallocation */ | |||||||||
640 | ierr = MatSetSizes(Cmpi,pn,pn,PETSC_DETERMINE-1,PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),640,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
641 | if (P->cmap->bs > 0) { | |||||||||
642 | ierr = PetscLayoutSetBlockSize(Cmpi->rmap,P->cmap->bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),642,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
643 | ierr = PetscLayoutSetBlockSize(Cmpi->cmap,P->cmap->bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),643,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
644 | } | |||||||||
645 | ierr = MatMPIAIJSetPreallocation(Cmpi,0,dnz,0,onz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),645,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
646 | ierr = MatPreallocateFinalize(dnz,onz)0;_4_ierr = PetscFreeA(2,646,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(dnz),&(onz));do {if (__builtin_expect(!!(_4_ierr), 0)) return PetscError(((MPI_Comm)0x44000001),646,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0);};CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),646,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
647 | ||||||||||
648 | /* members in merge */ | |||||||||
649 | ierr = PetscFree(id_r)((*PetscTrFree)((void*)(id_r),649,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((id_r) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),649,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
650 | ierr = PetscFree(len_r)((*PetscTrFree)((void*)(len_r),650,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((len_r) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),650,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
651 | ierr = PetscFree(buf_ri[0])((*PetscTrFree)((void*)(buf_ri[0]),651,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_ri[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),651,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
652 | ierr = PetscFree(buf_ri)((*PetscTrFree)((void*)(buf_ri),652,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_ri) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),652,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
653 | ierr = PetscFree(buf_rj[0])((*PetscTrFree)((void*)(buf_rj[0]),653,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_rj[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),653,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
654 | ierr = PetscFree(buf_rj)((*PetscTrFree)((void*)(buf_rj),654,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_rj) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),654,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
655 | ierr = PetscLayoutDestroy(&rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),655,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
656 | ||||||||||
657 | /* attach the supporting struct to Cmpi for reuse */ | |||||||||
658 | c = (Mat_MPIAIJ*)Cmpi->data; | |||||||||
659 | c->ap = ptap; | |||||||||
660 | ptap->duplicate = Cmpi->ops->duplicate; | |||||||||
661 | ptap->destroy = Cmpi->ops->destroy; | |||||||||
662 | ptap->view = Cmpi->ops->view; | |||||||||
663 | ||||||||||
664 | /* Cmpi is not ready for use - assembly will be done by MatPtAPNumeric() */ | |||||||||
665 | Cmpi->assembled = PETSC_FALSE; | |||||||||
666 | Cmpi->ops->ptapnumeric = MatPtAPNumeric_MPIAIJ_MPIAIJ_scalable; | |||||||||
667 | Cmpi->ops->destroy = MatDestroy_MPIAIJ_PtAP; | |||||||||
668 | Cmpi->ops->view = MatView_MPIAIJ_PtAP; | |||||||||
669 | Cmpi->ops->freeintermediatedatastructures = MatFreeIntermediateDataStructures_MPIAIJ_AP; | |||||||||
670 | *C = Cmpi; | |||||||||
671 | ||||||||||
672 | nout = 0; | |||||||||
673 | ierr = ISGlobalToLocalMappingApply(ptap->ltog,IS_GTOLM_DROP,c_oth->i[ptap->C_oth->rmap->n],c_oth->j,&nout,c_oth->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),673,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
674 | if (c_oth->i[ptap->C_oth->rmap->n] != nout) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incorrect mapping %D != %D\n",c_oth->i[ptap->C_oth->rmap->n],nout)return PetscError(((MPI_Comm)0x44000001),674,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,75,PETSC_ERROR_INITIAL,"Incorrect mapping %D != %D\n",c_oth-> i[ptap->C_oth->rmap->n],nout); | |||||||||
675 | ierr = ISGlobalToLocalMappingApply(ptap->ltog,IS_GTOLM_DROP,c_loc->i[ptap->C_loc->rmap->n],c_loc->j,&nout,c_loc->j);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),675,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
676 | if (c_loc->i[ptap->C_loc->rmap->n] != nout) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incorrect mapping %D != %D\n",c_loc->i[ptap->C_loc->rmap->n],nout)return PetscError(((MPI_Comm)0x44000001),676,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,75,PETSC_ERROR_INITIAL,"Incorrect mapping %D != %D\n",c_loc-> i[ptap->C_loc->rmap->n],nout); | |||||||||
677 | ||||||||||
678 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
679 | } | |||||||||
680 | ||||||||||
681 | PetscErrorCode MatPtAPSymbolic_MPIAIJ_MPIAIJ(Mat A,Mat P,PetscReal fill,Mat *C) | |||||||||
682 | { | |||||||||
683 | PetscErrorCode ierr; | |||||||||
684 | Mat_APMPI *ptap; | |||||||||
685 | Mat_MPIAIJ *a=(Mat_MPIAIJ*)A->data,*p=(Mat_MPIAIJ*)P->data,*c; | |||||||||
686 | MPI_Comm comm; | |||||||||
687 | PetscMPIInt size,rank; | |||||||||
688 | Mat Cmpi; | |||||||||
689 | PetscFreeSpaceList free_space=NULL((void*)0),current_space=NULL((void*)0); | |||||||||
690 | PetscInt am=A->rmap->n,pm=P->rmap->n,pN=P->cmap->N,pn=P->cmap->n; | |||||||||
691 | PetscInt *lnk,i,k,pnz,row,nsend; | |||||||||
692 | PetscBT lnkbt; | |||||||||
693 | PetscMPIInt tagi,tagj,*len_si,*len_s,*len_ri,icompleted=0,nrecv; | |||||||||
694 | PetscInt **buf_rj,**buf_ri,**buf_ri_k; | |||||||||
695 | PetscInt len,proc,*dnz,*onz,*owners,nzi,nspacedouble; | |||||||||
696 | PetscInt nrows,*buf_s,*buf_si,*buf_si_i,**nextrow,**nextci; | |||||||||
697 | MPI_Request *swaits,*rwaits; | |||||||||
698 | MPI_Status *sstatus,rstatus; | |||||||||
699 | PetscLayout rowmap; | |||||||||
700 | PetscInt *owners_co,*coi,*coj; /* i and j array of (p->B)^T*A*P - used in the communication */ | |||||||||
701 | PetscMPIInt *len_r,*id_r; /* array of length of comm->size, store send/recv matrix values */ | |||||||||
702 | PetscInt *api,*apj,*Jptr,apnz,*prmap=p->garray,con,j,ap_rmax=0,Crmax,*aj,*ai,*pi; | |||||||||
703 | Mat_SeqAIJ *p_loc,*p_oth=NULL((void*)0),*ad=(Mat_SeqAIJ*)(a->A)->data,*ao=NULL((void*)0),*c_loc,*c_oth; | |||||||||
704 | PetscScalar *apv; | |||||||||
705 | PetscTable ta; | |||||||||
706 | MatType mtype; | |||||||||
707 | const char *prefix; | |||||||||
708 | #if defined(PETSC_USE_INFO1) | |||||||||
709 | PetscReal apfill; | |||||||||
710 | #endif | |||||||||
711 | ||||||||||
712 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 712; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
713 | ierr = PetscObjectGetComm((PetscObject)A,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),713,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
714 | ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),714,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
715 | ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),715,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
716 | ||||||||||
717 | if (size > 1) ao = (Mat_SeqAIJ*)(a->B)->data; | |||||||||
718 | ||||||||||
719 | /* create symbolic parallel matrix Cmpi */ | |||||||||
720 | ierr = MatCreate(comm,&Cmpi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),720,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
721 | ierr = MatGetType(A,&mtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),721,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
722 | ierr = MatSetType(Cmpi,mtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),722,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
723 | ||||||||||
724 | /* Do dense axpy in MatPtAPNumeric_MPIAIJ_MPIAIJ() */ | |||||||||
725 | Cmpi->ops->ptapnumeric = MatPtAPNumeric_MPIAIJ_MPIAIJ; | |||||||||
726 | ||||||||||
727 | /* create struct Mat_APMPI and attached it to C later */ | |||||||||
728 | ierr = PetscNew(&ptap)PetscMallocA(1,PETSC_TRUE,728,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(1)*sizeof(**((&ptap))),((&ptap)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),728,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
729 | ptap->reuse = MAT_INITIAL_MATRIX; | |||||||||
730 | ptap->algType = 1; | |||||||||
731 | ||||||||||
732 | /* get P_oth by taking rows of P (= non-zero cols of local A) from other processors */ | |||||||||
733 | ierr = MatGetBrowsOfAoCols_MPIAIJ(A,P,MAT_INITIAL_MATRIX,&ptap->startsj_s,&ptap->startsj_r,&ptap->bufa,&ptap->P_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),733,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
734 | /* get P_loc by taking all local rows of P */ | |||||||||
735 | ierr = MatMPIAIJGetLocalMat(P,MAT_INITIAL_MATRIX,&ptap->P_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),735,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
736 | ||||||||||
737 | /* (0) compute Rd = Pd^T, Ro = Po^T */ | |||||||||
738 | /* --------------------------------- */ | |||||||||
739 | ierr = MatTranspose(p->A,MAT_INITIAL_MATRIX,&ptap->Rd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),739,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
740 | ierr = MatTranspose(p->B,MAT_INITIAL_MATRIX,&ptap->Ro);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),740,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
741 | ||||||||||
742 | /* (1) compute symbolic AP = A_loc*P = Ad*P_loc + Ao*P_oth (api,apj) */ | |||||||||
743 | /* ----------------------------------------------------------------- */ | |||||||||
744 | p_loc = (Mat_SeqAIJ*)(ptap->P_loc)->data; | |||||||||
745 | if (ptap->P_oth) p_oth = (Mat_SeqAIJ*)(ptap->P_oth)->data; | |||||||||
746 | ||||||||||
747 | /* create and initialize a linked list */ | |||||||||
748 | ierr = PetscTableCreate(pn,pN,&ta);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),748,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* for compute AP_loc and Cmpi */ | |||||||||
749 | MatRowMergeMax_SeqAIJ(p_loc,ptap->P_loc->rmap->N,ta){ PetscInt _j,_row,_nz,*_col; if (p_loc) { for (_row=0; _row< ptap->P_loc->rmap->N; _row++) { _nz = p_loc->i[_row +1] - p_loc->i[_row]; for (_j=0; _j<_nz; _j++) { _col = _j + p_loc->j + p_loc->i[_row]; PetscTableAdd(ta,*_col +1,1,INSERT_VALUES); } } } }; | |||||||||
750 | MatRowMergeMax_SeqAIJ(p_oth,ptap->P_oth->rmap->N,ta){ PetscInt _j,_row,_nz,*_col; if (p_oth) { for (_row=0; _row< ptap->P_oth->rmap->N; _row++) { _nz = p_oth->i[_row +1] - p_oth->i[_row]; for (_j=0; _j<_nz; _j++) { _col = _j + p_oth->j + p_oth->i[_row]; PetscTableAdd(ta,*_col +1,1,INSERT_VALUES); } } } }; | |||||||||
751 | ierr = PetscTableGetCount(ta,&Crmax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),751,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* Crmax = nnz(sum of Prows) */ | |||||||||
752 | /* printf("[%d] est %d, Crmax %d; pN %d\n",rank,5*(p_loc->rmax+p_oth->rmax + (PetscInt)(1.e-2*pN)),Crmax,pN); */ | |||||||||
753 | ||||||||||
754 | ierr = PetscLLCondensedCreate(Crmax,pN,&lnk,&lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),754,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
755 | ||||||||||
756 | /* Initial FreeSpace size is fill*(nnz(A) + nnz(P)) */ | |||||||||
757 | if (ao) { | |||||||||
758 | ierr = PetscFreeSpaceGet(PetscRealIntMultTruncate(fill,PetscIntSumTruncate(ad->i[am],PetscIntSumTruncate(ao->i[am],p_loc->i[pm]))),&free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),758,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
759 | } else { | |||||||||
760 | ierr = PetscFreeSpaceGet(PetscRealIntMultTruncate(fill,PetscIntSumTruncate(ad->i[am],p_loc->i[pm])),&free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),760,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
761 | } | |||||||||
762 | current_space = free_space; | |||||||||
763 | nspacedouble = 0; | |||||||||
764 | ||||||||||
765 | ierr = PetscMalloc1(am+1,&api)PetscMallocA(1,PETSC_FALSE,765,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(am+1)*sizeof(**(&api)),(&api));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),765,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
766 | api[0] = 0; | |||||||||
767 | for (i=0; i<am; i++) { | |||||||||
768 | /* diagonal portion: Ad[i,:]*P */ | |||||||||
769 | ai = ad->i; pi = p_loc->i; | |||||||||
770 | nzi = ai[i+1] - ai[i]; | |||||||||
771 | aj = ad->j + ai[i]; | |||||||||
772 | for (j=0; j<nzi; j++) { | |||||||||
773 | row = aj[j]; | |||||||||
774 | pnz = pi[row+1] - pi[row]; | |||||||||
775 | Jptr = p_loc->j + pi[row]; | |||||||||
776 | /* add non-zero cols of P into the sorted linked list lnk */ | |||||||||
777 | ierr = PetscLLCondensedAddSorted(pnz,Jptr,lnk,lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),777,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
778 | } | |||||||||
779 | /* off-diagonal portion: Ao[i,:]*P */ | |||||||||
780 | if (ao) { | |||||||||
781 | ai = ao->i; pi = p_oth->i; | |||||||||
782 | nzi = ai[i+1] - ai[i]; | |||||||||
783 | aj = ao->j + ai[i]; | |||||||||
784 | for (j=0; j<nzi; j++) { | |||||||||
785 | row = aj[j]; | |||||||||
786 | pnz = pi[row+1] - pi[row]; | |||||||||
787 | Jptr = p_oth->j + pi[row]; | |||||||||
788 | ierr = PetscLLCondensedAddSorted(pnz,Jptr,lnk,lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),788,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
789 | } | |||||||||
790 | } | |||||||||
791 | apnz = lnk[0]; | |||||||||
792 | api[i+1] = api[i] + apnz; | |||||||||
793 | if (ap_rmax < apnz) ap_rmax = apnz; | |||||||||
794 | ||||||||||
795 | /* if free space is not available, double the total space in the list */ | |||||||||
796 | if (current_space->local_remaining<apnz) { | |||||||||
797 | ierr = PetscFreeSpaceGet(PetscIntSumTruncate(apnz,current_space->total_array_size),¤t_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),797,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
798 | nspacedouble++; | |||||||||
799 | } | |||||||||
800 | ||||||||||
801 | /* Copy data into free space, then initialize lnk */ | |||||||||
802 | ierr = PetscLLCondensedClean(pN,apnz,current_space->array,lnk,lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),802,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
803 | ||||||||||
804 | current_space->array += apnz; | |||||||||
805 | current_space->local_used += apnz; | |||||||||
806 | current_space->local_remaining -= apnz; | |||||||||
807 | } | |||||||||
808 | /* Allocate space for apj and apv, initialize apj, and */ | |||||||||
809 | /* destroy list of free space and other temporary array(s) */ | |||||||||
810 | ierr = PetscMalloc2(api[am],&apj,api[am],&apv)PetscMallocA(2,PETSC_FALSE,810,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(api[am])*sizeof(**(&apj)),(&apj),(size_t)(api [am])*sizeof(**(&apv)),(&apv));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),810,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
811 | ierr = PetscFreeSpaceContiguous(&free_space,apj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),811,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
812 | ierr = PetscLLDestroy(lnk,lnkbt)(((*PetscTrFree)((void*)(lnk),812,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((lnk) = 0,0)) || PetscBTDestroy(&(lnkbt)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),812,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
813 | ||||||||||
814 | /* Create AP_loc for reuse */ | |||||||||
815 | ierr = MatCreateSeqAIJWithArrays(PETSC_COMM_SELF((MPI_Comm)0x44000001),am,pN,api,apj,apv,&ptap->AP_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),815,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
816 | ||||||||||
817 | #if defined(PETSC_USE_INFO1) | |||||||||
818 | if (ao) { | |||||||||
819 | apfill = (PetscReal)api[am]/(ad->i[am]+ao->i[am]+p_loc->i[pm]+1); | |||||||||
820 | } else { | |||||||||
821 | apfill = (PetscReal)api[am]/(ad->i[am]+p_loc->i[pm]+1); | |||||||||
822 | } | |||||||||
823 | ptap->AP_loc->info.mallocs = nspacedouble; | |||||||||
824 | ptap->AP_loc->info.fill_ratio_given = fill; | |||||||||
825 | ptap->AP_loc->info.fill_ratio_needed = apfill; | |||||||||
826 | ||||||||||
827 | if (api[am]) { | |||||||||
828 | ierr = PetscInfo3(ptap->AP_loc,"Nonscalable algorithm, AP_loc reallocs %D; Fill ratio: given %g needed %g.\n",nspacedouble,(double)fill,(double)apfill)PetscInfo_Private(__func__,ptap->AP_loc,"Nonscalable algorithm, AP_loc reallocs %D; Fill ratio: given %g needed %g.\n" ,nspacedouble,(double)fill,(double)apfill);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),828,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
829 | ierr = PetscInfo1(ptap->AP_loc,"Use MatPtAP(A,B,MatReuse,%g,&C) for best AP_loc performance.;\n",(double)apfill)PetscInfo_Private(__func__,ptap->AP_loc,"Use MatPtAP(A,B,MatReuse,%g,&C) for best AP_loc performance.;\n" ,(double)apfill);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),829,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
830 | } else { | |||||||||
831 | ierr = PetscInfo(ptap->AP_loc,"Nonscalable algorithm, AP_loc is empty \n")PetscInfo_Private(__func__,ptap->AP_loc,"Nonscalable algorithm, AP_loc is empty \n" );CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),831,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
832 | } | |||||||||
833 | #endif | |||||||||
834 | ||||||||||
835 | /* (2-1) compute symbolic Co = Ro*AP_loc */ | |||||||||
836 | /* ------------------------------------ */ | |||||||||
837 | ierr = MatGetOptionsPrefix(A,&prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),837,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
838 | ierr = MatSetOptionsPrefix(ptap->Ro,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),838,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
839 | ierr = MatAppendOptionsPrefix(ptap->Ro,"inner_offdiag_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),839,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
840 | ierr = MatMatMultSymbolic_SeqAIJ_SeqAIJ(ptap->Ro,ptap->AP_loc,fill,&ptap->C_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),840,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
841 | ||||||||||
842 | /* (3) send coj of C_oth to other processors */ | |||||||||
843 | /* ------------------------------------------ */ | |||||||||
844 | /* determine row ownership */ | |||||||||
845 | ierr = PetscLayoutCreate(comm,&rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),845,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
846 | rowmap->n = pn; | |||||||||
847 | rowmap->bs = 1; | |||||||||
848 | ierr = PetscLayoutSetUp(rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),848,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
849 | owners = rowmap->range; | |||||||||
850 | ||||||||||
851 | /* determine the number of messages to send, their lengths */ | |||||||||
852 | ierr = PetscMalloc4(size,&len_s,size,&len_si,size,&sstatus,size+2,&owners_co)PetscMallocA(4,PETSC_FALSE,852,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(size)*sizeof(**(&len_s)),(&len_s),(size_t)( size)*sizeof(**(&len_si)),(&len_si),(size_t)(size)*sizeof (**(&sstatus)),(&sstatus),(size_t)(size+2)*sizeof(**( &owners_co)),(&owners_co));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),852,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
853 | ierr = PetscMemzero(len_s,size*sizeof(PetscMPIInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),853,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
854 | ierr = PetscMemzero(len_si,size*sizeof(PetscMPIInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),854,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
855 | ||||||||||
856 | c_oth = (Mat_SeqAIJ*)ptap->C_oth->data; | |||||||||
857 | coi = c_oth->i; coj = c_oth->j; | |||||||||
858 | con = ptap->C_oth->rmap->n; | |||||||||
859 | proc = 0; | |||||||||
860 | for (i=0; i<con; i++) { | |||||||||
861 | while (prmap[i] >= owners[proc+1]) proc++; | |||||||||
862 | len_si[proc]++; /* num of rows in Co(=Pt*AP) to be sent to [proc] */ | |||||||||
863 | len_s[proc] += coi[i+1] - coi[i]; /* num of nonzeros in Co to be sent to [proc] */ | |||||||||
864 | } | |||||||||
865 | ||||||||||
866 | len = 0; /* max length of buf_si[], see (4) */ | |||||||||
867 | owners_co[0] = 0; | |||||||||
868 | nsend = 0; | |||||||||
869 | for (proc=0; proc<size; proc++) { | |||||||||
870 | owners_co[proc+1] = owners_co[proc] + len_si[proc]; | |||||||||
871 | if (len_s[proc]) { | |||||||||
872 | nsend++; | |||||||||
873 | len_si[proc] = 2*(len_si[proc] + 1); /* length of buf_si to be sent to [proc] */ | |||||||||
874 | len += len_si[proc]; | |||||||||
875 | } | |||||||||
876 | } | |||||||||
877 | ||||||||||
878 | /* determine the number and length of messages to receive for coi and coj */ | |||||||||
879 | ierr = PetscGatherNumberOfMessages(comm,NULL((void*)0),len_s,&nrecv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),879,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
880 | ierr = PetscGatherMessageLengths2(comm,nsend,nrecv,len_s,len_si,&id_r,&len_r,&len_ri);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),880,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
881 | ||||||||||
882 | /* post the Irecv and Isend of coj */ | |||||||||
883 | ierr = PetscCommGetNewTag(comm,&tagj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),883,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
884 | ierr = PetscPostIrecvInt(comm,tagj,nrecv,id_r,len_r,&buf_rj,&rwaits);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),884,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
885 | ierr = PetscMalloc1(nsend+1,&swaits)PetscMallocA(1,PETSC_FALSE,885,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(nsend+1)*sizeof(**(&swaits)),(&swaits));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),885,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
886 | for (proc=0, k=0; proc<size; proc++) { | |||||||||
887 | if (!len_s[proc]) continue; | |||||||||
888 | i = owners_co[proc]; | |||||||||
889 | ierr = MPI_Isend(coj+coi[i],len_s[proc],MPIU_INT,proc,tagj,comm,swaits+k)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(len_s[proc]),(((MPI_Datatype)0x4c000405))) || MPI_Isend((coj +coi[i]),(len_s[proc]),(((MPI_Datatype)0x4c000405)),(proc),(tagj ),(comm),(swaits+k)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),889,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
890 | k++; | |||||||||
891 | } | |||||||||
892 | ||||||||||
893 | /* (2-2) compute symbolic C_loc = Rd*AP_loc */ | |||||||||
894 | /* ---------------------------------------- */ | |||||||||
895 | ierr = MatSetOptionsPrefix(ptap->Rd,prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),895,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
896 | ierr = MatAppendOptionsPrefix(ptap->Rd,"inner_diag_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),896,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
897 | ierr = MatMatMultSymbolic_SeqAIJ_SeqAIJ(ptap->Rd,ptap->AP_loc,fill,&ptap->C_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),897,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
898 | c_loc = (Mat_SeqAIJ*)ptap->C_loc->data; | |||||||||
899 | ||||||||||
900 | /* receives coj are complete */ | |||||||||
901 | for (i=0; i<nrecv; i++) { | |||||||||
902 | ierr = MPI_Waitany(nrecv,rwaits,&icompleted,&rstatus)((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany ((nrecv),(rwaits),(&icompleted),(&rstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),902,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
903 | } | |||||||||
904 | ierr = PetscFree(rwaits)((*PetscTrFree)((void*)(rwaits),904,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((rwaits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),904,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
905 | if (nsend) {ierr = MPI_Waitall(nsend,swaits,sstatus)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nsend),0) || MPI_Waitall((nsend),(swaits),(sstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),905,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||||||||
906 | ||||||||||
907 | /* add received column indices into ta to update Crmax */ | |||||||||
908 | for (k=0; k<nrecv; k++) {/* k-th received message */ | |||||||||
909 | Jptr = buf_rj[k]; | |||||||||
910 | for (j=0; j<len_r[k]; j++) { | |||||||||
911 | ierr = PetscTableAdd(ta,*(Jptr+j)+1,1,INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),911,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
912 | } | |||||||||
913 | } | |||||||||
914 | ierr = PetscTableGetCount(ta,&Crmax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),914,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
915 | ierr = PetscTableDestroy(&ta);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),915,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
916 | ||||||||||
917 | /* (4) send and recv coi */ | |||||||||
918 | /*-----------------------*/ | |||||||||
919 | ierr = PetscCommGetNewTag(comm,&tagi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),919,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
920 | ierr = PetscPostIrecvInt(comm,tagi,nrecv,id_r,len_ri,&buf_ri,&rwaits);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),920,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
921 | ierr = PetscMalloc1(len+1,&buf_s)PetscMallocA(1,PETSC_FALSE,921,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(len+1)*sizeof(**(&buf_s)),(&buf_s));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),921,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
922 | buf_si = buf_s; /* points to the beginning of k-th msg to be sent */ | |||||||||
923 | for (proc=0,k=0; proc<size; proc++) { | |||||||||
924 | if (!len_s[proc]) continue; | |||||||||
925 | /* form outgoing message for i-structure: | |||||||||
926 | buf_si[0]: nrows to be sent | |||||||||
927 | [1:nrows]: row index (global) | |||||||||
928 | [nrows+1:2*nrows+1]: i-structure index | |||||||||
929 | */ | |||||||||
930 | /*-------------------------------------------*/ | |||||||||
931 | nrows = len_si[proc]/2 - 1; /* num of rows in Co to be sent to [proc] */ | |||||||||
932 | buf_si_i = buf_si + nrows+1; | |||||||||
933 | buf_si[0] = nrows; | |||||||||
934 | buf_si_i[0] = 0; | |||||||||
935 | nrows = 0; | |||||||||
936 | for (i=owners_co[proc]; i<owners_co[proc+1]; i++) { | |||||||||
937 | nzi = coi[i+1] - coi[i]; | |||||||||
938 | buf_si_i[nrows+1] = buf_si_i[nrows] + nzi; /* i-structure */ | |||||||||
939 | buf_si[nrows+1] = prmap[i] -owners[proc]; /* local row index */ | |||||||||
940 | nrows++; | |||||||||
941 | } | |||||||||
942 | ierr = MPI_Isend(buf_si,len_si[proc],MPIU_INT,proc,tagi,comm,swaits+k)((petsc_isend_ct++,0) || PetscMPITypeSize(&(petsc_isend_len ),(len_si[proc]),(((MPI_Datatype)0x4c000405))) || MPI_Isend(( buf_si),(len_si[proc]),(((MPI_Datatype)0x4c000405)),(proc),(tagi ),(comm),(swaits+k)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),942,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
943 | k++; | |||||||||
944 | buf_si += len_si[proc]; | |||||||||
945 | } | |||||||||
946 | for (i=0; i<nrecv; i++) { | |||||||||
947 | ierr = MPI_Waitany(nrecv,rwaits,&icompleted,&rstatus)((petsc_wait_any_ct++,petsc_sum_of_waits_ct++,0) || MPI_Waitany ((nrecv),(rwaits),(&icompleted),(&rstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),947,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
948 | } | |||||||||
949 | ierr = PetscFree(rwaits)((*PetscTrFree)((void*)(rwaits),949,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((rwaits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),949,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
950 | if (nsend) {ierr = MPI_Waitall(nsend,swaits,sstatus)((petsc_wait_all_ct++,petsc_sum_of_waits_ct += (PetscLogDouble ) (nsend),0) || MPI_Waitall((nsend),(swaits),(sstatus)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),950,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||||||||
951 | ||||||||||
952 | ierr = PetscFree4(len_s,len_si,sstatus,owners_co)PetscFreeA(4,952,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(len_s),&(len_si),&(sstatus),&(owners_co));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),952,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
953 | ierr = PetscFree(len_ri)((*PetscTrFree)((void*)(len_ri),953,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((len_ri) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),953,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
954 | ierr = PetscFree(swaits)((*PetscTrFree)((void*)(swaits),954,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((swaits) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),954,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
955 | ierr = PetscFree(buf_s)((*PetscTrFree)((void*)(buf_s),955,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_s) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),955,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
956 | ||||||||||
957 | /* (5) compute the local portion of Cmpi */ | |||||||||
958 | /* ------------------------------------------ */ | |||||||||
959 | /* set initial free space to be Crmax, sufficient for holding nozeros in each row of Cmpi */ | |||||||||
960 | ierr = PetscFreeSpaceGet(Crmax,&free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),960,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
961 | current_space = free_space; | |||||||||
962 | ||||||||||
963 | ierr = PetscMalloc3(nrecv,&buf_ri_k,nrecv,&nextrow,nrecv,&nextci)PetscMallocA(3,PETSC_FALSE,963,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(nrecv)*sizeof(**(&buf_ri_k)),(&buf_ri_k),(size_t )(nrecv)*sizeof(**(&nextrow)),(&nextrow),(size_t)(nrecv )*sizeof(**(&nextci)),(&nextci));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),963,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
964 | for (k=0; k<nrecv; k++) { | |||||||||
965 | buf_ri_k[k] = buf_ri[k]; /* beginning of k-th recved i-structure */ | |||||||||
966 | nrows = *buf_ri_k[k]; | |||||||||
967 | nextrow[k] = buf_ri_k[k] + 1; /* next row number of k-th recved i-structure */ | |||||||||
968 | nextci[k] = buf_ri_k[k] + (nrows + 1); /* poins to the next i-structure of k-th recved i-structure */ | |||||||||
969 | } | |||||||||
970 | ||||||||||
971 | ierr = MatPreallocateInitialize(comm,pn,pn,dnz,onz)0; { PetscErrorCode _4_ierr; PetscInt __nrows = (pn),__ncols = (pn),__rstart,__start,__end; _4_ierr = PetscMallocA(2,PETSC_TRUE ,971,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)((size_t)__nrows)*sizeof(**(&dnz)),(&dnz),(size_t )((size_t)__nrows)*sizeof(**(&onz)),(&onz));do {if (__builtin_expect (!!(_4_ierr),0)) return PetscError(((MPI_Comm)0x44000001),971 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0); __start = 0; __end = __start; _4_ierr = MPI_Scan(&__ncols,&__end,1,((MPI_Datatype )0x4c000405),(MPI_Op)(0x58000003),comm);do {if (__builtin_expect (!!(_4_ierr),0)) return PetscError(((MPI_Comm)0x44000001),971 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0); __start = __end - __ncols; _4_ierr = MPI_Scan(&__nrows,&__rstart,1,( (MPI_Datatype)0x4c000405),(MPI_Op)(0x58000003),comm);do {if ( __builtin_expect(!!(_4_ierr),0)) return PetscError(((MPI_Comm )0x44000001),971,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0); __rstart = __rstart - __nrows;;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),971,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
972 | ierr = PetscLLCondensedCreate(Crmax,pN,&lnk,&lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),972,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
973 | for (i=0; i<pn; i++) { | |||||||||
974 | /* add C_loc into Cmpi */ | |||||||||
975 | nzi = c_loc->i[i+1] - c_loc->i[i]; | |||||||||
976 | Jptr = c_loc->j + c_loc->i[i]; | |||||||||
977 | ierr = PetscLLCondensedAddSorted(nzi,Jptr,lnk,lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),977,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
978 | ||||||||||
979 | /* add received col data into lnk */ | |||||||||
980 | for (k=0; k<nrecv; k++) { /* k-th received message */ | |||||||||
981 | if (i == *nextrow[k]) { /* i-th row */ | |||||||||
982 | nzi = *(nextci[k]+1) - *nextci[k]; | |||||||||
983 | Jptr = buf_rj[k] + *nextci[k]; | |||||||||
984 | ierr = PetscLLCondensedAddSorted(nzi,Jptr,lnk,lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),984,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
985 | nextrow[k]++; nextci[k]++; | |||||||||
986 | } | |||||||||
987 | } | |||||||||
988 | nzi = lnk[0]; | |||||||||
989 | ||||||||||
990 | /* copy data into free space, then initialize lnk */ | |||||||||
991 | ierr = PetscLLCondensedClean(pN,nzi,current_space->array,lnk,lnkbt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),991,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
992 | ierr = MatPreallocateSet(i+owners[rank],nzi,current_space->array,dnz,onz)0;{ PetscInt __i; if (i+owners[rank] < __rstart) return PetscError (((MPI_Comm)0x44000001),992,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,63,PETSC_ERROR_INITIAL,"Trying to set preallocation for row %D less than first local row %D" ,i+owners[rank],__rstart); if (i+owners[rank] >= __rstart+ __nrows) return PetscError(((MPI_Comm)0x44000001),992,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,63,PETSC_ERROR_INITIAL,"Trying to set preallocation for row %D greater than last local row %D" ,i+owners[rank],__rstart+__nrows-1); for (__i=0; __i<nzi; __i ++) { if ((current_space->array)[__i] < __start || (current_space ->array)[__i] >= __end) onz[i+owners[rank] - __rstart]++ ; else if (dnz[i+owners[rank] - __rstart] < __ncols) dnz[i +owners[rank] - __rstart]++; }};CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),992,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
993 | } | |||||||||
994 | ierr = PetscFree3(buf_ri_k,nextrow,nextci)PetscFreeA(3,994,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(buf_ri_k),&(nextrow),&(nextci));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),994,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
995 | ierr = PetscLLDestroy(lnk,lnkbt)(((*PetscTrFree)((void*)(lnk),995,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((lnk) = 0,0)) || PetscBTDestroy(&(lnkbt)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),995,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
996 | ierr = PetscFreeSpaceDestroy(free_space);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),996,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
997 | ||||||||||
998 | /* local sizes and preallocation */ | |||||||||
999 | ierr = MatSetSizes(Cmpi,pn,pn,PETSC_DETERMINE-1,PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),999,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1000 | if (P->cmap->bs > 0) { | |||||||||
1001 | ierr = PetscLayoutSetBlockSize(Cmpi->rmap,P->cmap->bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1001,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1002 | ierr = PetscLayoutSetBlockSize(Cmpi->cmap,P->cmap->bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1002,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1003 | } | |||||||||
1004 | ierr = MatMPIAIJSetPreallocation(Cmpi,0,dnz,0,onz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1004,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1005 | ierr = MatPreallocateFinalize(dnz,onz)0;_4_ierr = PetscFreeA(2,1005,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,&(dnz),&(onz));do {if (__builtin_expect(!!(_4_ierr), 0)) return PetscError(((MPI_Comm)0x44000001),1005,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,_4_ierr,PETSC_ERROR_REPEAT," ");} while (0);};CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1005,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1006 | ||||||||||
1007 | /* members in merge */ | |||||||||
1008 | ierr = PetscFree(id_r)((*PetscTrFree)((void*)(id_r),1008,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((id_r) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1008,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1009 | ierr = PetscFree(len_r)((*PetscTrFree)((void*)(len_r),1009,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((len_r) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1009,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1010 | ierr = PetscFree(buf_ri[0])((*PetscTrFree)((void*)(buf_ri[0]),1010,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_ri[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1010,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1011 | ierr = PetscFree(buf_ri)((*PetscTrFree)((void*)(buf_ri),1011,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_ri) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1011,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1012 | ierr = PetscFree(buf_rj[0])((*PetscTrFree)((void*)(buf_rj[0]),1012,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_rj[0]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1012,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1013 | ierr = PetscFree(buf_rj)((*PetscTrFree)((void*)(buf_rj),1013,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ) || ((buf_rj) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1013,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1014 | ierr = PetscLayoutDestroy(&rowmap);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1014,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1015 | ||||||||||
1016 | /* attach the supporting struct to Cmpi for reuse */ | |||||||||
1017 | c = (Mat_MPIAIJ*)Cmpi->data; | |||||||||
1018 | c->ap = ptap; | |||||||||
1019 | ptap->duplicate = Cmpi->ops->duplicate; | |||||||||
1020 | ptap->destroy = Cmpi->ops->destroy; | |||||||||
1021 | ptap->view = Cmpi->ops->view; | |||||||||
1022 | ierr = PetscCalloc1(pN,&ptap->apa)PetscMallocA(1,PETSC_TRUE,1022,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,(size_t)(pN)*sizeof(**(&ptap->apa)),(&ptap->apa ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1022,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1023 | ||||||||||
1024 | /* Cmpi is not ready for use - assembly will be done by MatPtAPNumeric() */ | |||||||||
1025 | Cmpi->assembled = PETSC_FALSE; | |||||||||
1026 | Cmpi->ops->destroy = MatDestroy_MPIAIJ_PtAP; | |||||||||
1027 | Cmpi->ops->view = MatView_MPIAIJ_PtAP; | |||||||||
1028 | Cmpi->ops->freeintermediatedatastructures = MatFreeIntermediateDataStructures_MPIAIJ_AP; | |||||||||
1029 | *C = Cmpi; | |||||||||
1030 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
1031 | } | |||||||||
1032 | ||||||||||
1033 | PetscErrorCode MatPtAPNumeric_MPIAIJ_MPIAIJ(Mat A,Mat P,Mat C) | |||||||||
1034 | { | |||||||||
1035 | PetscErrorCode ierr; | |||||||||
1036 | Mat_MPIAIJ *a=(Mat_MPIAIJ*)A->data,*p=(Mat_MPIAIJ*)P->data,*c=(Mat_MPIAIJ*)C->data; | |||||||||
1037 | Mat_SeqAIJ *ad=(Mat_SeqAIJ*)(a->A)->data,*ao=(Mat_SeqAIJ*)(a->B)->data; | |||||||||
1038 | Mat_SeqAIJ *ap,*p_loc,*p_oth=NULL((void*)0),*c_seq; | |||||||||
| ||||||||||
1039 | Mat_APMPI *ptap = c->ap; | |||||||||
1040 | Mat AP_loc,C_loc,C_oth; | |||||||||
1041 | PetscInt i,rstart,rend,cm,ncols,row; | |||||||||
1042 | PetscInt *api,*apj,am = A->rmap->n,j,col,apnz; | |||||||||
1043 | PetscScalar *apa; | |||||||||
1044 | const PetscInt *cols; | |||||||||
1045 | const PetscScalar *vals; | |||||||||
1046 | ||||||||||
1047 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ; petscstack->line[petscstack->currentsize] = 1047; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||||||||
1048 | if (!ptap) { | |||||||||
1049 | MPI_Comm comm; | |||||||||
1050 | ierr = PetscObjectGetComm((PetscObject)C,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1050,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1051 | SETERRQ(comm,PETSC_ERR_ARG_WRONGSTATE,"PtAP cannot be reused. Do not call MatFreeIntermediateDataStructures() or use '-mat_freeintermediatedatastructures'")return PetscError(comm,1051,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,73,PETSC_ERROR_INITIAL,"PtAP cannot be reused. Do not call MatFreeIntermediateDataStructures() or use '-mat_freeintermediatedatastructures'" ); | |||||||||
1052 | } | |||||||||
1053 | ||||||||||
1054 | ierr = MatZeroEntries(C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1054,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1055 | /* 1) get R = Pd^T,Ro = Po^T */ | |||||||||
1056 | if (ptap->reuse == MAT_REUSE_MATRIX) { | |||||||||
1057 | ierr = MatTranspose(p->A,MAT_REUSE_MATRIX,&ptap->Rd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1057,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1058 | ierr = MatTranspose(p->B,MAT_REUSE_MATRIX,&ptap->Ro);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1058,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1059 | } | |||||||||
1060 | ||||||||||
1061 | /* 2) get AP_loc */ | |||||||||
1062 | AP_loc = ptap->AP_loc; | |||||||||
1063 | ap = (Mat_SeqAIJ*)AP_loc->data; | |||||||||
1064 | ||||||||||
1065 | /* 2-1) get P_oth = ptap->P_oth and P_loc = ptap->P_loc */ | |||||||||
1066 | /*-----------------------------------------------------*/ | |||||||||
1067 | if (ptap->reuse == MAT_REUSE_MATRIX) { | |||||||||
1068 | /* P_oth and P_loc are obtained in MatPtASymbolic() when reuse == MAT_INITIAL_MATRIX */ | |||||||||
1069 | ierr = MatGetBrowsOfAoCols_MPIAIJ(A,P,MAT_REUSE_MATRIX,&ptap->startsj_s,&ptap->startsj_r,&ptap->bufa,&ptap->P_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1069,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1070 | ierr = MatMPIAIJGetLocalMat(P,MAT_REUSE_MATRIX,&ptap->P_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1070,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1071 | } | |||||||||
1072 | ||||||||||
1073 | /* 2-2) compute numeric A_loc*P - dominating part */ | |||||||||
1074 | /* ---------------------------------------------- */ | |||||||||
1075 | /* get data from symbolic products */ | |||||||||
1076 | p_loc = (Mat_SeqAIJ*)(ptap->P_loc)->data; | |||||||||
1077 | if (ptap->P_oth) { | |||||||||
1078 | p_oth = (Mat_SeqAIJ*)(ptap->P_oth)->data; | |||||||||
1079 | } | |||||||||
1080 | apa = ptap->apa; | |||||||||
1081 | api = ap->i; | |||||||||
1082 | apj = ap->j; | |||||||||
1083 | for (i=0; i<am; i++) { | |||||||||
1084 | /* AP[i,:] = A[i,:]*P = Ad*P_loc Ao*P_oth */ | |||||||||
1085 | AProw_nonscalable(i,ad,ao,p_loc,p_oth,apa){ PetscInt _anz,_pnz,_j,_k,*_ai,*_aj,_row,*_pi,*_pj; PetscScalar *_aa,_valtmp,*_pa; _ai = ad->i; _anz = _ai[i+1] - _ai[i]; _aj = ad->j + _ai[i]; _aa = ad->a + _ai[i]; for (_j=0; _j<_anz; _j++) { _row = _aj[_j]; _pi = p_loc->i; _pnz = _pi[_row+1] - _pi[_row]; _pj = p_loc->j + _pi[_row]; _pa = p_loc->a + _pi[_row]; _valtmp = _aa[_j]; for (_k=0; _k< _pnz; _k++) { apa[_pj[_k]] += _valtmp*_pa[_k]; } (void)PetscLogFlops (2.0*_pnz); } _ai = ao->i; _anz = _ai[i+1] - _ai[i]; _aj = ao->j + _ai[i]; _aa = ao->a + _ai[i]; for (_j=0; _j< _anz; _j++) { _row = _aj[_j]; _pi = p_oth->i; _pnz = _pi[_row +1] - _pi[_row]; _pj = p_oth->j + _pi[_row]; _pa = p_oth-> a + _pi[_row]; _valtmp = _aa[_j]; for (_k=0; _k<_pnz; _k++ ) { apa[_pj[_k]] += _valtmp*_pa[_k]; } (void)PetscLogFlops(2.0 *_pnz); } }; | |||||||||
| ||||||||||
1086 | apnz = api[i+1] - api[i]; | |||||||||
1087 | for (j=0; j<apnz; j++) { | |||||||||
1088 | col = apj[j+api[i]]; | |||||||||
1089 | ap->a[j+ap->i[i]] = apa[col]; | |||||||||
1090 | apa[col] = 0.0; | |||||||||
1091 | } | |||||||||
1092 | ierr = PetscLogFlops(2.0*apnz);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1092,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1093 | } | |||||||||
1094 | ||||||||||
1095 | /* 3) C_loc = Rd*AP_loc, C_oth = Ro*AP_loc */ | |||||||||
1096 | ierr = ((ptap->C_loc)->ops->matmultnumeric)(ptap->Rd,AP_loc,ptap->C_loc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1096,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1097 | ierr = ((ptap->C_oth)->ops->matmultnumeric)(ptap->Ro,AP_loc,ptap->C_oth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1097,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1098 | C_loc = ptap->C_loc; | |||||||||
1099 | C_oth = ptap->C_oth; | |||||||||
1100 | ||||||||||
1101 | /* add C_loc and Co to to C */ | |||||||||
1102 | ierr = MatGetOwnershipRange(C,&rstart,&rend);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1102,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1103 | ||||||||||
1104 | /* C_loc -> C */ | |||||||||
1105 | cm = C_loc->rmap->N; | |||||||||
1106 | c_seq = (Mat_SeqAIJ*)C_loc->data; | |||||||||
1107 | cols = c_seq->j; | |||||||||
1108 | vals = c_seq->a; | |||||||||
1109 | ||||||||||
1110 | ||||||||||
1111 | /* The (fast) MatSetValues_MPIAIJ_CopyFromCSRFormat function can only be used when C->was_assembled is PETSC_FALSE and */ | |||||||||
1112 | /* when there are no off-processor parts. */ | |||||||||
1113 | /* If was_assembled is true, then the statement aj[rowstart_diag+dnz_row] = mat_j[col] - cstart; in MatSetValues_MPIAIJ_CopyFromCSRFormat */ | |||||||||
1114 | /* is no longer true. Then the more complex function MatSetValues_MPIAIJ() has to be used, where the column index is looked up from */ | |||||||||
1115 | /* a table, and other, more complex stuff has to be done. */ | |||||||||
1116 | if (C->assembled) { | |||||||||
1117 | C->was_assembled = PETSC_TRUE; | |||||||||
1118 | C->assembled = PETSC_FALSE; | |||||||||
1119 | } | |||||||||
1120 | if (C->was_assembled) { | |||||||||
1121 | for (i=0; i<cm; i++) { | |||||||||
1122 | ncols = c_seq->i[i+1] - c_seq->i[i]; | |||||||||
1123 | row = rstart + i; | |||||||||
1124 | ierr = MatSetValues_MPIAIJ(C,1,&row,ncols,cols,vals,ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1124,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1125 | cols += ncols; vals += ncols; | |||||||||
1126 | } | |||||||||
1127 | } else { | |||||||||
1128 | ierr = MatSetValues_MPIAIJ_CopyFromCSRFormat(C,c_seq->j,c_seq->i,c_seq->a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1128,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1129 | } | |||||||||
1130 | ||||||||||
1131 | /* Co -> C, off-processor part */ | |||||||||
1132 | cm = C_oth->rmap->N; | |||||||||
1133 | c_seq = (Mat_SeqAIJ*)C_oth->data; | |||||||||
1134 | cols = c_seq->j; | |||||||||
1135 | vals = c_seq->a; | |||||||||
1136 | for (i=0; i<cm; i++) { | |||||||||
1137 | ncols = c_seq->i[i+1] - c_seq->i[i]; | |||||||||
1138 | row = p->garray[i]; | |||||||||
1139 | ierr = MatSetValues(C,1,&row,ncols,cols,vals,ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1139,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1140 | cols += ncols; vals += ncols; | |||||||||
1141 | } | |||||||||
1142 | ||||||||||
1143 | ierr = MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1143,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1144 | ierr = MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1144,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1145 | ||||||||||
1146 | ptap->reuse = MAT_REUSE_MATRIX; | |||||||||
1147 | ||||||||||
1148 | /* supporting struct ptap consumes almost same amount of memory as C=PtAP, release it if C will not be updated by A and P */ | |||||||||
1149 | if (ptap->freestruct) { | |||||||||
1150 | ierr = MatFreeIntermediateDataStructures(C);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1150,__func__,"/sandbox/petsc/petsc.next-tmp/src/mat/impls/aij/mpi/mpiptap.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||||||||
1151 | } | |||||||||
1152 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||||||||
1153 | } |