Skip to content

Commit 5e6e9de

Browse files
committed
Change the way MUMPS uses the Triplet data on sequential runs
1 parent 05d3c47 commit 5e6e9de

File tree

1 file changed

+60
-22
lines changed

1 file changed

+60
-22
lines changed

la/sparse_solver_mumps.go

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func (o *sparseSolverMumps) Init(t *Triplet, args *SparseConfig) {
6363

6464
// set comm
6565
o.comm = args.communicator
66+
mpiSize := o.comm.Size()
6667

6768
// allocate data
6869
if C.NumData == C.NumMaxData {
@@ -99,12 +100,19 @@ func (o *sparseSolverMumps) Init(t *Triplet, args *SparseConfig) {
99100

100101
// set pointers
101102
o.data.n = C.int(o.t.m)
102-
o.data.nz_loc = C.int(o.t.pos)
103-
o.data.irn_loc = (*C.int)(unsafe.Pointer(&o.mi[0]))
104-
o.data.jcn_loc = (*C.int)(unsafe.Pointer(&o.mj[0]))
105-
o.data.a_loc = (*C.double)(unsafe.Pointer(&o.t.x[0]))
103+
if mpiSize > 1 {
104+
o.data.nz_loc = C.int(o.t.pos)
105+
o.data.irn_loc = (*C.int)(unsafe.Pointer(&o.mi[0]))
106+
o.data.jcn_loc = (*C.int)(unsafe.Pointer(&o.mj[0]))
107+
o.data.a_loc = (*C.double)(unsafe.Pointer(&o.t.x[0]))
108+
} else {
109+
o.data.nz = C.int(o.t.pos)
110+
o.data.irn = (*C.int)(unsafe.Pointer(&o.mi[0]))
111+
o.data.jcn = (*C.int)(unsafe.Pointer(&o.mj[0]))
112+
o.data.a = (*C.double)(unsafe.Pointer(&o.t.x[0]))
113+
}
106114

107-
// control
115+
// verbose level
108116
if args.Verbose {
109117
o.data.icntl[1-1] = 6 // output stream for error messages
110118
o.data.icntl[2-1] = 0 // output stream for statistics and warnings
@@ -116,15 +124,26 @@ func (o *sparseSolverMumps) Init(t *Triplet, args *SparseConfig) {
116124
o.data.icntl[3-1] = -1 // no global information
117125
o.data.icntl[4-1] = -1 // message level
118126
}
119-
o.data.icntl[5-1] = 0 // assembled matrix (needed for distributed matrix)
120-
o.data.icntl[6-1] = 0 // must be zero because matrix is distributed
121-
o.data.icntl[18-1] = 3 // distributed matrix
122-
o.data.icntl[14-1] = C.int(args.MumpsIncreaseOfWorkingSpacePct)
123-
o.data.icntl[23-1] = C.int(args.MumpsMaxMemoryPerProcessor)
124127

125-
// set ordering and scaling
128+
// handle args
126129
o.data.icntl[7-1] = C.int(args.mumpsOrdering) // ordering
127130
o.data.icntl[8-1] = C.int(args.mumpsScaling) // scaling
131+
o.data.icntl[14-1] = C.int(args.MumpsIncreaseOfWorkingSpacePct)
132+
o.data.icntl[23-1] = C.int(args.MumpsMaxMemoryPerProcessor)
133+
134+
// options
135+
o.data.icntl[5-1] = 0 // assembled matrix (not elemental)
136+
if mpiSize > 1 {
137+
o.data.icntl[6-1] = 0 // no col perm for distr matrix => set this to remove warning
138+
o.data.icntl[18-1] = 3 // use distributed matrix
139+
o.data.icntl[28-1] = 2 // parallel computation
140+
o.data.icntl[29-1] = 0 // parallel ordering tool => auto
141+
} else {
142+
o.data.icntl[6-1] = 7 // automatic col perm
143+
o.data.icntl[18-1] = 0 // matrix is centralized on the host
144+
o.data.icntl[28-1] = 1 // sequential computation
145+
o.data.icntl[29-1] = 0 // auto => ignored
146+
}
128147

129148
// analysis step
130149
o.data.job = 1 // analysis code
@@ -241,6 +260,7 @@ func (o *MumpsC) Init(t *TripletC, args *SparseConfig) {
241260

242261
// set comm
243262
o.comm = args.communicator
263+
mpiSize := o.comm.Size()
244264

245265
// allocate data
246266
if C.NumDataC == C.NumMaxData {
@@ -277,12 +297,19 @@ func (o *MumpsC) Init(t *TripletC, args *SparseConfig) {
277297

278298
// set pointers
279299
o.data.n = C.int(o.t.m)
280-
o.data.nz_loc = C.int(o.t.pos)
281-
o.data.irn_loc = (*C.int)(unsafe.Pointer(&o.mi[0]))
282-
o.data.jcn_loc = (*C.int)(unsafe.Pointer(&o.mj[0]))
283-
o.data.a_loc = (*C.ZMUMPS_COMPLEX)(unsafe.Pointer(&o.t.x[0]))
300+
if mpiSize > 1 {
301+
o.data.nz_loc = C.int(o.t.pos)
302+
o.data.irn_loc = (*C.int)(unsafe.Pointer(&o.mi[0]))
303+
o.data.jcn_loc = (*C.int)(unsafe.Pointer(&o.mj[0]))
304+
o.data.a_loc = (*C.ZMUMPS_COMPLEX)(unsafe.Pointer(&o.t.x[0]))
305+
} else {
306+
o.data.nz = C.int(o.t.pos)
307+
o.data.irn = (*C.int)(unsafe.Pointer(&o.mi[0]))
308+
o.data.jcn = (*C.int)(unsafe.Pointer(&o.mj[0]))
309+
o.data.a = (*C.ZMUMPS_COMPLEX)(unsafe.Pointer(&o.t.x[0]))
310+
}
284311

285-
// control
312+
// verbose level
286313
if args.Verbose {
287314
o.data.icntl[1-1] = 6 // output stream for error messages
288315
o.data.icntl[2-1] = 0 // output stream for statistics and warnings
@@ -294,15 +321,26 @@ func (o *MumpsC) Init(t *TripletC, args *SparseConfig) {
294321
o.data.icntl[3-1] = -1 // no global information
295322
o.data.icntl[4-1] = -1 // message level
296323
}
297-
o.data.icntl[5-1] = 0 // assembled matrix (needed for distributed matrix)
298-
o.data.icntl[6-1] = 7 // automatic (default) permuting strategy for diagonal terms
299-
o.data.icntl[18-1] = 3 // distributed matrix
300-
o.data.icntl[14-1] = C.int(args.MumpsIncreaseOfWorkingSpacePct)
301-
o.data.icntl[23-1] = C.int(args.MumpsMaxMemoryPerProcessor)
302324

303-
// set ordering and scaling
325+
// handle args
304326
o.data.icntl[7-1] = C.int(args.mumpsOrdering) // ordering
305327
o.data.icntl[8-1] = C.int(args.mumpsScaling) // scaling
328+
o.data.icntl[14-1] = C.int(args.MumpsIncreaseOfWorkingSpacePct)
329+
o.data.icntl[23-1] = C.int(args.MumpsMaxMemoryPerProcessor)
330+
331+
// options
332+
o.data.icntl[5-1] = 0 // assembled matrix (not elemental)
333+
if mpiSize > 1 {
334+
o.data.icntl[6-1] = 0 // no col perm for distr matrix => set this to remove warning
335+
o.data.icntl[18-1] = 3 // use distributed matrix
336+
o.data.icntl[28-1] = 2 // parallel computation
337+
o.data.icntl[29-1] = 0 // parallel ordering tool => auto
338+
}else{
339+
o.data.icntl[6-1] = 7 // automatic col perm
340+
o.data.icntl[18-1] = 0 // matrix is centralized on the host
341+
o.data.icntl[28-1] = 1 // sequential computation
342+
o.data.icntl[29-1] = 0 // auto => ignored
343+
}
306344

307345
// analysis step
308346
o.data.job = 1 // analysis code

0 commit comments

Comments
 (0)