Bug Summary

File:vec/is/sf/impls/basic/neighbor/sfneighbor.c
Warning:line 287, column 29
Array access (via field 'leaf') results in a null pointer dereference

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1#include <../src/vec/is/sf/impls/basic/sfpack.h>
2#include <../src/vec/is/sf/impls/basic/sfbasic.h>
3
4#if defined(PETSC_HAVE_MPI_NEIGHBORHOOD_COLLECTIVES1)
5
6/* SF Neighbor completely relies on the two sided info built by SF Basic. Therefore we build Neighbor as a subclass of Basic */
7
8typedef struct {
9 SPPACKBASICHEADERPetscErrorCode (*Pack) (PetscInt,PetscInt,const PetscInt*,PetscInt
,PetscSFPackOpt,const void*,void*); PetscErrorCode (*UnpackAndInsert
)(PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void
*,const void*); PetscErrorCode (*UnpackAndAdd) (PetscInt,PetscInt
,const PetscInt*,PetscInt,PetscSFPackOpt,void*,const void*); PetscErrorCode
(*UnpackAndMin) (PetscInt,PetscInt,const PetscInt*,PetscInt,
PetscSFPackOpt,void*,const void*); PetscErrorCode (*UnpackAndMax
) (PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,
void*,const void*); PetscErrorCode (*UnpackAndMinloc)(PetscInt
,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void*,const
void*); PetscErrorCode (*UnpackAndMaxloc)(PetscInt,PetscInt,
const PetscInt*,PetscInt,PetscSFPackOpt,void*,const void*); PetscErrorCode
(*UnpackAndMult) (PetscInt,PetscInt,const PetscInt*,PetscInt
,PetscSFPackOpt,void*,const void*); PetscErrorCode (*UnpackAndLAND
) (PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,
void*,const void*); PetscErrorCode (*UnpackAndBAND) (PetscInt
,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void*,const
void*); PetscErrorCode (*UnpackAndLOR) (PetscInt,PetscInt,const
PetscInt*,PetscInt,PetscSFPackOpt,void*,const void*); PetscErrorCode
(*UnpackAndBOR) (PetscInt,PetscInt,const PetscInt*,PetscInt,
PetscSFPackOpt,void*,const void*); PetscErrorCode (*UnpackAndLXOR
) (PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,
void*,const void*); PetscErrorCode (*UnpackAndBXOR) (PetscInt
,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void*,const
void*); PetscErrorCode (*FetchAndInsert) (PetscInt,PetscInt,
const PetscInt*,PetscInt,PetscSFPackOpt,void*,void*); PetscErrorCode
(*FetchAndAdd) (PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt
,void*,void*); PetscErrorCode (*FetchAndMin) (PetscInt,PetscInt
,const PetscInt*,PetscInt,PetscSFPackOpt,void*,void*); PetscErrorCode
(*FetchAndMax) (PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt
,void*,void*); PetscErrorCode (*FetchAndMinloc) (PetscInt,PetscInt
,const PetscInt*,PetscInt,PetscSFPackOpt,void*,void*); PetscErrorCode
(*FetchAndMaxloc) (PetscInt,PetscInt,const PetscInt*,PetscInt
,PetscSFPackOpt,void*,void*); PetscErrorCode (*FetchAndMult) (
PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void
*,void*); PetscErrorCode (*FetchAndLAND) (PetscInt,PetscInt,const
PetscInt*,PetscInt,PetscSFPackOpt,void*,void*); PetscErrorCode
(*FetchAndBAND) (PetscInt,PetscInt,const PetscInt*,PetscInt,
PetscSFPackOpt,void*,void*); PetscErrorCode (*FetchAndLOR) (PetscInt
,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void*,void*
); PetscErrorCode (*FetchAndBOR) (PetscInt,PetscInt,const PetscInt
*,PetscInt,PetscSFPackOpt,void*,void*); PetscErrorCode (*FetchAndLXOR
) (PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,
void*,void*); PetscErrorCode (*FetchAndBXOR) (PetscInt,PetscInt
,const PetscInt*,PetscInt,PetscSFPackOpt,void*,void*); PetscMPIInt
tag; MPI_Datatype unit; MPI_Datatype basicunit; PetscBool isbuiltin
; size_t unitbytes; PetscInt bs; const void *rkey,*lkey; PetscSFPack
next; char **root; char **leaf; PetscMPIInt half; MPI_Request
*requests
;
10 char *rootbuf; /* contiguous buffer for all root ranks */
11 char *leafbuf; /* contiguous buffer for all non-distinguished leaf ranks. Distiguished ones share root buffers. */
12} *PetscSFPack_Neighbor;
13
14typedef struct {
15 SFBASICHEADERPetscMPIInt niranks; PetscMPIInt ndiranks; PetscMPIInt *iranks
; PetscInt itotal; PetscInt *ioffset; PetscInt *irootloc; PetscSFPackOpt
rootpackopt; PetscSFPack avail; PetscSFPack inuse
;
16 MPI_Comm comms[2]; /* Communicators with distributed topology in both directions */
17 PetscBool initialized[2]; /* Are the two communicators initialized? */
18 PetscMPIInt *rootdispls,*rootcounts,*leafdispls,*leafcounts; /* displs/counts for non-distinguished ranks */
19} PetscSF_Neighbor;
20
21/*===================================================================================*/
22/* Internal utility routines */
23/*===================================================================================*/
24
25/* Get the communicator with distributed graph topology, which is not cheap to build so we do it on demand (instead of at PetscSFSetUp time) */
26static PetscErrorCode PetscSFGetDistComm_Neighbor(PetscSF sf,PetscSFDirection direction,MPI_Comm *distcomm)
27{
28 PetscErrorCode ierr;
29 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
30 PetscInt nrootranks,ndrootranks,nleafranks,ndleafranks;
31 const PetscMPIInt *rootranks,*leafranks;
32 MPI_Comm comm;
33
34 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 34; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
35 ierr = PetscSFGetRootInfo_Basic(sf,&nrootranks,&ndrootranks,&rootranks,NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),35,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Which ranks will access my roots (I am a destination) */
36 ierr = PetscSFGetLeafInfo_Basic(sf,&nleafranks,&ndleafranks,&leafranks,NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),36,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* My leaves will access whose roots (I am a source) */
37
38 if (!dat->initialized[direction]) {
39 const PetscMPIInt indegree = nrootranks-ndrootranks,*sources = rootranks+ndrootranks;
40 const PetscMPIInt outdegree = nleafranks-ndleafranks,*destinations = leafranks+ndleafranks;
41 MPI_Comm *mycomm = &dat->comms[direction];
42 ierr = PetscObjectGetComm((PetscObject)sf,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),42,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
43 if (direction == PETSCSF_LEAF2ROOT_REDUCE) {
44 ierr = MPI_Dist_graph_create_adjacent(comm,indegree,sources,dat->rootcounts/*src weights*/,outdegree,destinations,dat->leafcounts/*dest weights*/,MPI_INFO_NULL((MPI_Info)0x1c000000),1/*reorder*/,mycomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),44,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
45 } else { /* PETSCSF_ROOT2LEAF_BCAST, reverse src & dest */
46 ierr = MPI_Dist_graph_create_adjacent(comm,outdegree,destinations,dat->leafcounts/*src weights*/,indegree,sources,dat->rootcounts/*dest weights*/,MPI_INFO_NULL((MPI_Info)0x1c000000),1/*reorder*/,mycomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),46,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
47 }
48 dat->initialized[direction] = PETSC_TRUE;
49 }
50 *distcomm = dat->comms[direction];
51 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)
;
52}
53
54static PetscErrorCode PetscSFPackGet_Neighbor(PetscSF sf,MPI_Datatype unit,const void *rkey,const void *lkey,PetscSFDirection direction,PetscSFPack_Neighbor *mylink)
55{
56 PetscErrorCode ierr;
57 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
58 PetscInt i,nrootranks,ndrootranks,nleafranks,ndleafranks;
59 const PetscInt *rootoffset,*leafoffset;
60 PetscSFPack *p;
61 PetscSFPack_Neighbor link;
62
63 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 63; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
64 ierr = PetscSFPackSetErrorOnUnsupportedOverlap(sf,unit,rkey,lkey);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),64,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
65 ierr = PetscSFGetRootInfo_Basic(sf,&nrootranks,&ndrootranks,NULL((void*)0),&rootoffset,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
66 ierr = PetscSFGetLeafInfo_Basic(sf,&nleafranks,&ndleafranks,NULL((void*)0),&leafoffset,NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
67
68 /* Look for types in cache */
69 for (p=&dat->avail; (link=(PetscSFPack_Neighbor)*p); p=&link->next) {
70 PetscBool match;
71 ierr = MPIPetsc_Type_compare(unit,link->unit,&match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),71,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
72 if (match) {
73 *p = link->next; /* Remove from available list */
74 goto found;
75 }
76 }
77
78 ierr = PetscNew(&link)PetscMallocA(1,PETSC_TRUE,78,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,(size_t)(1)*sizeof(**((&link))),((&link)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),78,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
79 ierr = PetscSFPackSetupType((PetscSFPack)link,unit);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),79,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
80 ierr = PetscMalloc2(nrootranks,&link->root,nleafranks,&link->leaf)PetscMallocA(2,PETSC_FALSE,80,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,(size_t)(nrootranks)*sizeof(**(&link->root)),(&link
->root),(size_t)(nleafranks)*sizeof(**(&link->leaf)
),(&link->leaf))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),80,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
81 /* Double the requests. First half are used for reduce (leaf2root) communication, second half for bcast (root2leaf) communication */
82 link->half = 1;
83 ierr = PetscMalloc1(link->half*2,&link->requests)PetscMallocA(1,PETSC_FALSE,83,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,(size_t)(link->half*2)*sizeof(**(&link->requests))
,(&link->requests))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),83,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
84 ierr = PetscCommGetNewTag(PetscObjectComm((PetscObject)sf),&link->tag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),84,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Actually, tag is not need for neighborhood collectives */
85
86 /* Allocate root and leaf buffers */
87 ierr = PetscMalloc2(rootoffset[nrootranks]*link->unitbytes,&link->rootbuf,(leafoffset[nleafranks]-leafoffset[ndleafranks])*link->unitbytes,&link->leafbuf)PetscMallocA(2,PETSC_FALSE,87,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,(size_t)(rootoffset[nrootranks]*link->unitbytes)*sizeof(*
*(&link->rootbuf)),(&link->rootbuf),(size_t)((leafoffset
[nleafranks]-leafoffset[ndleafranks])*link->unitbytes)*sizeof
(**(&link->leafbuf)),(&link->leafbuf))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),87,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
88 for (i=0; i<nrootranks; i++) link->root[i] = link->rootbuf + rootoffset[i]*link->unitbytes;
89 for (i=0; i<nleafranks; i++) {
90 if (i < ndleafranks) { /* Leaf buffers for distinguished ranks are pointers directly into root buffers */
91 if (ndrootranks != 1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Cannot match distinguished ranks")return PetscError(((MPI_Comm)0x44000001),91,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,77,PETSC_ERROR_INITIAL,"Cannot match distinguished ranks")
;
92 link->leaf[i] = link->root[0];
93 continue;
94 }
95 link->leaf[i] = link->leafbuf + (leafoffset[i] - leafoffset[ndleafranks])*link->unitbytes;
96 }
97
98found:
99 link->rkey = rkey;
100 link->lkey = lkey;
101 link->next = dat->inuse;
102 dat->inuse = (PetscSFPack)link;
103 *mylink = link;
104 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)
;
105}
106
107/*===================================================================================*/
108/* Implementations of SF public APIs */
109/*===================================================================================*/
110static PetscErrorCode PetscSFSetUp_Neighbor(PetscSF sf)
111{
112 PetscErrorCode ierr;
113 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
114 PetscInt i,j,nrootranks,ndrootranks,nleafranks,ndleafranks;
115 const PetscInt *rootoffset,*leafoffset;
116 PetscMPIInt m,n;
117
118 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 118; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
119 ierr = PetscSFSetUp_Basic(sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),119,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
120 ierr = PetscSFGetRootInfo_Basic(sf,&nrootranks,&ndrootranks,NULL((void*)0),&rootoffset,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
121 ierr = PetscSFGetLeafInfo_Basic(sf,&nleafranks,&ndleafranks,NULL((void*)0),&leafoffset,NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),121,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
122
123 /* Only setup MPI displs/counts for non-distinguished ranks. Distinguished ranks use shared memory */
124 ierr = PetscMalloc4(nrootranks-ndrootranks,&dat->rootdispls,nrootranks-ndrootranks,&dat->rootcounts,nleafranks-ndleafranks,&dat->leafdispls,nleafranks-ndleafranks,&dat->leafcounts)PetscMallocA(4,PETSC_FALSE,124,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,(size_t)(nrootranks-ndrootranks)*sizeof(**(&dat->rootdispls
)),(&dat->rootdispls),(size_t)(nrootranks-ndrootranks)
*sizeof(**(&dat->rootcounts)),(&dat->rootcounts
),(size_t)(nleafranks-ndleafranks)*sizeof(**(&dat->leafdispls
)),(&dat->leafdispls),(size_t)(nleafranks-ndleafranks)
*sizeof(**(&dat->leafcounts)),(&dat->leafcounts
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),124,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
125 for (i=ndrootranks,j=0; i<nrootranks; i++,j++) {
126 ierr = PetscMPIIntCast(rootoffset[i]-rootoffset[ndrootranks],&m);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),126,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; dat->rootdispls[j] = m;
127 ierr = PetscMPIIntCast(rootoffset[i+1]-rootoffset[i], &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),127,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; dat->rootcounts[j] = n;
128 }
129
130 for (i=ndleafranks,j=0; i<nleafranks; i++,j++) {
131 ierr = PetscMPIIntCast(leafoffset[i]-leafoffset[ndleafranks],&m);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),131,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; dat->leafdispls[j] = m;
132 ierr = PetscMPIIntCast(leafoffset[i+1]-leafoffset[i], &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),132,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; dat->leafcounts[j] = n;
133 }
134 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)
;
135}
136
137static PetscErrorCode PetscSFReset_Neighbor(PetscSF sf)
138{
139 PetscErrorCode ierr;
140 PetscInt i;
141 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
142 PetscSFPack_Neighbor link,next;
143
144 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 144; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
145 if (dat->inuse) SETERRQ(PetscObjectComm((PetscObject)sf),PETSC_ERR_ARG_WRONGSTATE,"Outstanding operation has not been completed")return PetscError(PetscObjectComm((PetscObject)sf),145,__func__
,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,73,PETSC_ERROR_INITIAL,"Outstanding operation has not been completed"
)
;
146 ierr = PetscFree4(dat->rootdispls,dat->rootcounts,dat->leafdispls,dat->leafcounts)PetscFreeA(4,146,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,&(dat->rootdispls),&(dat->rootcounts),&(dat
->leafdispls),&(dat->leafcounts))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),146,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
147 for (i=0; i<2; i++) {
148 if (dat->initialized[i]) {
149 ierr = MPI_Comm_free(&dat->comms[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),149,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
150 dat->initialized[i] = PETSC_FALSE;
151 }
152 }
153
154 ierr = PetscFree2(dat->iranks,dat->ioffset)PetscFreeA(2,154,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,&(dat->iranks),&(dat->ioffset))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),154,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
155 ierr = PetscFree(dat->irootloc)((*PetscTrFree)((void*)(dat->irootloc),155,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
) || ((dat->irootloc) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),155,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
156 for (link=(PetscSFPack_Neighbor)dat->avail; link; link=next) {
157 next = (PetscSFPack_Neighbor)link->next;
158 if (!link->isbuiltin) {ierr = MPI_Type_free(&link->unit);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),158,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
159 ierr = PetscFree2(link->root,link->leaf)PetscFreeA(2,159,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,&(link->root),&(link->leaf))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
160 ierr = PetscFree2(link->rootbuf,link->leafbuf)PetscFreeA(2,160,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,&(link->rootbuf),&(link->leafbuf))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),160,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
161 ierr = PetscFree(link->requests)((*PetscTrFree)((void*)(link->requests),161,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
) || ((link->requests) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),161,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
162 ierr = PetscFree(link)((*PetscTrFree)((void*)(link),162,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
) || ((link) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),162,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
163 }
164 dat->avail = NULL((void*)0);
165 ierr = PetscSFPackDestoryOptimization(&sf->leafpackopt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),165,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
166 ierr = PetscSFPackDestoryOptimization(&dat->rootpackopt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),166,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
167 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)
;
168}
169
170static PetscErrorCode PetscSFDestroy_Neighbor(PetscSF sf)
171{
172 PetscErrorCode ierr;
173
174 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 174; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
175 ierr = PetscSFReset_Neighbor(sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),175,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
176 ierr = PetscFree(sf->data)((*PetscTrFree)((void*)(sf->data),176,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
) || ((sf->data) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),176,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
177 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)
;
178}
179
180static PetscErrorCode PetscSFBcastAndOpBegin_Neighbor(PetscSF sf,MPI_Datatype unit,const void *rootdata,void *leafdata,MPI_Op op)
181{
182 PetscErrorCode ierr;
183 PetscSFPack_Neighbor link;
184 PetscInt i,nrootranks,ndrootranks,nleafranks,ndleafranks;
185 const PetscInt *rootoffset,*rootloc;
186 PetscMPIInt n,ind,outd;
187 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
188 MPI_Comm distcomm;
189 MPI_Request *req;
190 void *sbuf,*rbuf;
191
192 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 192; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
193 ierr = PetscSFGetRootInfo_Basic(sf,&nrootranks,&ndrootranks,NULL((void*)0),&rootoffset,&rootloc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),193,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
194 ierr = PetscSFGetLeafInfo_Basic(sf,&nleafranks,&ndleafranks,NULL((void*)0),NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),194,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
195 ierr = PetscSFPackGet_Neighbor(sf,unit,rootdata,leafdata,PETSCSF_ROOT2LEAF_BCAST,&link);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),195,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
196
197 /* Pack root data */
198 for (i=0; i<nrootranks; i++) {
199 void *packstart = link->root[i];
200 ierr = PetscMPIIntCast(rootoffset[i+1]-rootoffset[i],&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),200,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
201 (*link->Pack)(n,link->bs,rootloc+rootoffset[i],i,dat->rootpackopt,rootdata,packstart);
202 }
203
204 /* Do neighborhood alltoallv for non-distinguished ranks */
205 req = &link->requests[PETSCSF_ROOT2LEAF_BCAST];
206 ierr = PetscSFGetDistComm_Neighbor(sf,PETSCSF_ROOT2LEAF_BCAST,&distcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),206,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
207 outd = nrootranks - ndrootranks;
208 ind = nleafranks - ndleafranks;
209 sbuf = link->root ? link->root[ndrootranks] : NULL((void*)0);
210 rbuf = link->leaf ? link->leaf[ndleafranks] : NULL((void*)0);
211 ierr = MPI_Start_ineighbor_alltoallv(outd,ind,sbuf,dat->rootcounts,dat->rootdispls,unit,rbuf,dat->leafcounts,dat->leafdispls,unit,distcomm,req)((petsc_isend_ct += (PetscLogDouble)(outd),0) || (petsc_irecv_ct
+= (PetscLogDouble)(ind),0) || PetscMPITypeSizeCount((outd),
(dat->rootcounts),(unit),(&petsc_isend_len)) || PetscMPITypeSizeCount
((ind),(dat->leafcounts),(unit),(&petsc_irecv_len)) ||
(((outd) || (ind)) && MPI_Ineighbor_alltoallv((sbuf)
,(dat->rootcounts),(dat->rootdispls),(unit),(rbuf),(dat
->leafcounts),(dat->leafdispls),(unit),(distcomm),(req)
)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),211,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
212 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)
;
213}
214
215static PetscErrorCode PetscSFReduceBegin_Neighbor(PetscSF sf,MPI_Datatype unit,const void *leafdata,void *rootdata,MPI_Op op)
216{
217 PetscErrorCode ierr;
218 PetscInt i,nrootranks,ndrootranks,nleafranks,ndleafranks;
219 const PetscInt *leafoffset,*leafloc;
220 PetscMPIInt n,ind,outd;
221 PetscSFPack_Neighbor link;
222 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
223 MPI_Comm distcomm;
224 MPI_Request *req;
225 void *sbuf,*rbuf;
226
227 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 227; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
228 ierr = PetscSFGetRootInfo_Basic(sf,&nrootranks,&ndrootranks,NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),228,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
229 ierr = PetscSFGetLeafInfo_Basic(sf,&nleafranks,&ndleafranks,NULL((void*)0),&leafoffset,&leafloc,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),229,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
230 ierr = PetscSFPackGet_Neighbor(sf,unit,rootdata,leafdata,PETSCSF_LEAF2ROOT_REDUCE,&link);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),230,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
231
232 /* Pack leaf data */
233 for (i=0; i<nleafranks; i++) {
234 void *packstart = link->leaf[i];
235 ierr = PetscMPIIntCast(leafoffset[i+1]-leafoffset[i],&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),235,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
236 (*link->Pack)(n,link->bs,leafloc+leafoffset[i],i,sf->leafpackopt,leafdata,packstart);
237 }
238
239 /* Do neighborhood alltoallv for non-distinguished ranks */
240 req = &link->requests[PETSCSF_LEAF2ROOT_REDUCE];
241 ierr = PetscSFGetDistComm_Neighbor(sf,PETSCSF_LEAF2ROOT_REDUCE,&distcomm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),241,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
242 ind = nrootranks - ndrootranks;
243 outd = nleafranks - ndleafranks;
244 sbuf = link->leaf ? link->leaf[ndleafranks] : NULL((void*)0);
245 rbuf = link->root ? link->root[ndrootranks] : NULL((void*)0);
246 ierr = MPI_Start_ineighbor_alltoallv(outd,ind,sbuf,dat->leafcounts,dat->leafdispls,unit,rbuf,dat->rootcounts,dat->rootdispls,unit,distcomm,req)((petsc_isend_ct += (PetscLogDouble)(outd),0) || (petsc_irecv_ct
+= (PetscLogDouble)(ind),0) || PetscMPITypeSizeCount((outd),
(dat->leafcounts),(unit),(&petsc_isend_len)) || PetscMPITypeSizeCount
((ind),(dat->rootcounts),(unit),(&petsc_irecv_len)) ||
(((outd) || (ind)) && MPI_Ineighbor_alltoallv((sbuf)
,(dat->leafcounts),(dat->leafdispls),(unit),(rbuf),(dat
->rootcounts),(dat->rootdispls),(unit),(distcomm),(req)
)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),246,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
247 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)
;
248}
249
250static PetscErrorCode PetscSFFetchAndOpEnd_Neighbor(PetscSF sf,MPI_Datatype unit,void *rootdata,const void *leafdata,void *leafupdate,MPI_Op op)
251{
252 PetscErrorCode ierr;
253 PetscErrorCode (*FetchAndOp)(PetscInt,PetscInt,const PetscInt*,PetscInt,PetscSFPackOpt,void*,void*);
254 PetscSFPack_Basic link;
255 PetscInt i,nrootranks,ndrootranks,nleafranks,ndleafranks;
256 const PetscInt *rootoffset,*leafoffset,*rootloc,*leafloc;
257 const PetscMPIInt *rootranks,*leafranks;
258 MPI_Comm comm;
259 PetscMPIInt n,ind,outd;
260 PetscSF_Neighbor *dat = (PetscSF_Neighbor*)sf->data;
261 void *sbuf,*rbuf;
262
263 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 263; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
264 ierr = PetscSFPackGetInUse(sf,unit,rootdata,leafdata,PETSC_OWN_POINTER,(PetscSFPack*)&link);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),264,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
265 ierr = PetscSFPackWaitall_Basic(link,PETSCSF_LEAF2ROOT_REDUCE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),265,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
266
267 ierr = PetscSFGetRootInfo_Basic(sf,&nrootranks,&ndrootranks,&rootranks,&rootoffset,&rootloc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),267,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
268 ierr = PetscSFGetLeafInfo_Basic(sf,&nleafranks,&ndleafranks,&leafranks,&leafoffset,&leafloc,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269
270 /* Process local fetch-and-op */
271 ierr = PetscSFPackGetFetchAndOp(sf,(PetscSFPack)link,op,&FetchAndOp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),271,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1
Value assigned to field 'leaf'
272 for (i=0; i<nrootranks; i++) {
2
Assuming 'i' is >= 'nrootranks'
3
Loop condition is false. Execution continues on line 279
273 void *packstart = link->root[i];
274 ierr = PetscMPIIntCast(rootoffset[i+1]-rootoffset[i],&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),274,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
275 (*FetchAndOp)(n,link->bs,rootloc+rootoffset[i],i,dat->rootpackopt,rootdata,packstart);
276 }
277
278 /* Bcast the updated root buffer back to leaves */
279 ierr = PetscSFGetDistComm_Neighbor(sf,PETSCSF_ROOT2LEAF_BCAST,&comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),279,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
280 outd = nrootranks - ndrootranks;
281 ind = nleafranks - ndleafranks;
282 sbuf = link->root ? link->root[ndrootranks] : NULL((void*)0);
4
Assuming the condition is false
5
'?' condition is false
283 rbuf = link->leaf ? link->leaf[ndleafranks] : NULL((void*)0);
6
Assuming pointer value is null
7
'?' condition is false
284 ierr = MPI_Start_neighbor_alltoallv(outd,ind,sbuf,dat->rootcounts,dat->rootdispls,unit,rbuf,dat->leafcounts,dat->leafdispls,unit,comm)((petsc_isend_ct += (PetscLogDouble)(outd),0) || (petsc_irecv_ct
+= (PetscLogDouble)(ind),0) || PetscMPITypeSizeCount((outd),
(dat->rootcounts),(unit),(&petsc_isend_len)) || PetscMPITypeSizeCount
((ind),(dat->leafcounts),(unit),(&petsc_irecv_len)) ||
(((outd) || (ind)) && MPI_Neighbor_alltoallv((sbuf),
(dat->rootcounts),(dat->rootdispls),(unit),(rbuf),(dat->
leafcounts),(dat->leafdispls),(unit),(comm))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
285
286 for (i=0; i<nleafranks; i++) {
8
Assuming 'i' is < 'nleafranks'
9
Loop condition is true. Entering loop body
287 const void *packstart = link->leaf[i];
10
Array access (via field 'leaf') results in a null pointer dereference
288 ierr = PetscMPIIntCast(leafoffset[i+1]-leafoffset[i],&n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),288,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
289 (*link->UnpackAndInsert)(n,link->bs,leafloc+leafoffset[i],i,sf->leafpackopt,leafupdate,packstart);
290 }
291
292 ierr = PetscSFPackReclaim(sf,(PetscSFPack*)&link);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),292,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
293 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)
;
294}
295
296PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode PetscSFCreate_Neighbor(PetscSF sf)
297{
298 PetscErrorCode ierr;
299 PetscSF_Neighbor *dat;
300
301 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
; petscstack->line[petscstack->currentsize] = 301; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
302 sf->ops->CreateEmbeddedSF = PetscSFCreateEmbeddedSF_Basic;
303 sf->ops->CreateEmbeddedLeafSF = PetscSFCreateEmbeddedLeafSF_Basic;
304 sf->ops->BcastAndOpEnd = PetscSFBcastAndOpEnd_Basic;
305 sf->ops->ReduceEnd = PetscSFReduceEnd_Basic;
306 sf->ops->FetchAndOpBegin = PetscSFFetchAndOpBegin_Basic;
307 sf->ops->GetLeafRanks = PetscSFGetLeafRanks_Basic;
308 sf->ops->View = PetscSFView_Basic;
309
310 sf->ops->SetUp = PetscSFSetUp_Neighbor;
311 sf->ops->Reset = PetscSFReset_Neighbor;
312 sf->ops->Destroy = PetscSFDestroy_Neighbor;
313 sf->ops->BcastAndOpBegin = PetscSFBcastAndOpBegin_Neighbor;
314 sf->ops->ReduceBegin = PetscSFReduceBegin_Neighbor;
315 sf->ops->FetchAndOpEnd = PetscSFFetchAndOpEnd_Neighbor;
316
317 ierr = PetscNewLog(sf,&dat)(PetscMallocA(1,PETSC_TRUE,317,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,(size_t)(1)*sizeof(**(((&dat)))),(((&dat)))) || PetscLogObjectMemory
((PetscObject)sf,sizeof(**(&dat))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),317,__func__,"/sandbox/petsc/petsc.next-tmp/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
318 sf->data = (void*)dat;
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#endif