31 Int *Cstart, *Sched, *Childp ;
32 Int c,
n, ncomponents, myid ;
62 LU->
W =
CHOLMOD (malloc) (n,
sizeof (double), cm) ;
69 for (c = 0 ; c < ncomponents ; c++)
75 Cstart = LUsymbolic->
Cstart ;
76 Sched = LUsymbolic->
Sched ;
77 Childp = LUsymbolic->
Childp ;
86 for (c = 0 ; c < ncomponents ; c++)
95 LUnode->
nk = Cstart [c+1] - Cstart [c] ;
96 LUnode->
nchild = Childp [c+1] - Childp [c] ;
101 LUnode->PK_NPIV = 0 ;
102 LUnode->PK_NFOUND = 0 ;
103 LUnode->PK_NLOST = 0 ;
112 if (Sched [c] == myid)
119 sizeof (MPI_Request), cm)) ;
137 LUnode->PK_SSIZE = 0 ;
164 PR1 ((Common->
file,
"proc "ID" LU done\n", myid)) ;
186 if (LUHandle ==
NULL)
205 CHOLMOD (free) (LU->
n,
sizeof (double), LU->
W, cm) ;
217 PR2 ((Common->
file,
"proc "ID" node "ID" free numeric, nk "ID" B %p\n",
218 Common->
myid, c, LUnode->
nk, (
void *) (LUnode->
B))) ;
219 CHOLMOD (free) (LUnode->
nk,
sizeof (double), LUnode->
B, cm) ;
220 CHOLMOD (free) (LUnode->PK_NN,
sizeof (double), LUnode->
X, cm) ;
223 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int), LUnode->
llen, cm) ;
224 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int), LUnode->
lp, cm) ;
226 CHOLMOD (free) (LUnode->PK_NN,
sizeof (
Int), LUnode->
up, cm) ;
232 sizeof (MPI_Request), LUnode->Req, cm)) ;
235 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int),
237 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int),
239 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int),
241 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int),
243 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int), LUnode->
Pinv, cm) ;
244 CHOLMOD (free) (LUnode->PK_NPIV,
sizeof (
Int), LUnode->
Qinv, cm) ;
247 CHOLMOD (free) (LUnode->PK_SN,
sizeof (
Int), LUnode->
sp, cm) ;
249 CHOLMOD (free) (LUnode->PK_SSIZE,
sizeof (double),
285 Int *Ap, *Ai, *Ep2, *Ep, *Ei, *Cperm, *RpermInv, *Rperm ;
288 Int n, enz, anz, k, j, p ;
293 Cperm = LUsymbolic->
Cperm ;
294 Rperm = LUsymbolic->
Rperm ;
295 Rperm = (Rperm ==
NULL) ? Cperm : Rperm ;
307 for (k = 0 ; k < n ; k++)
309 PR3 ((Common->
file,
"Cperm ("ID") = "ID" ;\n", k+1, Cperm[k]+1));
311 for (k = 0 ; k < n ; k++)
313 PR3 ((Common->
file,
"Rperm ("ID") = "ID" ;\n", k+1, Rperm[k]+1));
315 for (k = 0 ; k < n ; k++)
317 PR3 ((Common->
file,
"RpermInv ("ID") = "ID" ;\n", k+1, RpermInv [k]+1)) ;
326 PR0 ((Common->
file,
"failed to allocate E\n")) ;
334 for (k = 0 ; k < n ; k++)
338 PR1 ((Common->
file,
"Col "ID" of A becomes col "ID" of E\n", j, k)) ;
340 for (p = Ap [j] ; p < Ap [j+1] ; p++)
343 PR2 ((Common->
file,
" "ID
" %g -> "ID
"\n",
344 Ai [p], Ax [p], RpermInv [Ai [p]])) ;
345 Ei [enz] = RpermInv [Ai [p]] ;
358 PR0 ((Common->
file,
"out of memory to sort E\n")) ;
364 for (k = 0 ; k <= n ; k++)
389 Int *Cperm, *Cn, *Cnz, *Ep, *Ei, *Ep2, *Map, *Cparent, *Rperm,
390 *Cstart, *
P, *Q, *Cp, *Ci, *Pc, *Qc, *Pinv, *Qinv, *Sched ;
391 Int cj, i,
n, ncomponents, k, p, c, a, cn, k1, k2, kk, cnz,
395 MPI (MPI_Status ms) ;
396 MPI (MPI_Request req) ;
409 myid = Common->
myid ;
411 PR0 ((Common->
file,
"proc "ID" start factorize\n", myid)) ;
418 Cperm = LUsymbolic->
Cperm ;
419 Rperm = LUsymbolic->
Rperm ;
420 Rperm = (Rperm ==
NULL) ? Cperm : Rperm ;
421 Cn = LUsymbolic->
Cn ;
422 Cnz = LUsymbolic->
Cnz ;
423 Cparent = LUsymbolic->
Cparent ;
424 Cstart = LUsymbolic->
Cstart ;
425 Sched = LUsymbolic->
Sched ;
430 for (c = 0 ; c < ncomponents ; c++)
432 PR1 ((Common->
file,
"proc: "ID
" node "ID
": "ID
" to "ID
", parent "ID
" Sched "ID
"\n",
433 Common->
myid, c, Cstart [c], Cstart [c+1]-1, Cparent [c],
444 PR1 ((Common->
file,
"factor proc "ID
" alloc ok: "ID
"\n", myid, ok)) ;
465 for (c = 0 ; ok && c < ncomponents ; c++)
467 if (myid == 0 || Sched [c] == myid)
484 MPI (MPI_Allreduce (&ok, &all_ok, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD)) ;
488 PR0 ((Common->
file,
"proc "ID
" all fail factorize\n", Common->
myid)) ;
510 for (k = 0 ; k < n ; k++)
512 for (p = Ep [k] ; p < Ep [k+1] ; p++)
514 PR3 ((Common->
file,
"E ("ID
","ID
") = %g ;\n", 1+Ei[p], 1+k, Ex[p]));
517 for (c = 0 ; c <= ncomponents ; c++)
519 PR3 ((Common->
file,
"Cstart ("ID
") = "ID
" ;\n", 1+c, 1+Cstart [c])) ;
525 for (c = 0 ; c < ncomponents ; c++)
527 PR1 ((Common->
file,
"distribute node c = "ID
"\n", c)) ;
532 for (a = c ; a !=
EMPTY ; a = Cparent [a])
534 PR2 ((Common->
file,
"ancestor "ID
", for c "ID
", ncomp "ID
"\n",
535 a, c, ncomponents)) ;
536 ASSERT (a >= c && a < ncomponents) ;
539 PR2 ((Common->
file,
"k1 "ID
" k2 "ID
"\n", k1, k2)) ;
540 for (k = k1 ; k < k2 ; k++)
543 PR3 ((Common->
file,
" global: "ID
" local "ID
"\n", k, cj)) ;
562 PR2 ((Common->
file,
"c: "ID
" k1 to k2-1: "ID
" "ID
"\n", c, k1, k2-1)) ;
563 for (k = k1 ; k < k2 ; k++)
566 for (p = Ep2 [k] ; p < Ep [k+1] ; p++)
571 "E(1+"ID
",1+"ID
") = %g ; ce(1+"ID
",1+"ID
") = "ID
"\n",
572 i,k, Ex[p], i,k,c)) ;
582 for (a = Cparent [c] ; a !=
EMPTY ; a = Cparent [a])
584 PR2 ((Common->
file,
"ancestor "ID
"\n", a)) ;
585 PR2 ((Common->
file,
"k1 "ID
" k2 "ID
"\n", Cstart [a], Cstart [a+1]));
586 for (k = Cstart [a] ; k < Cstart [a+1] ; k++)
590 for (p = Ep2 [k] ; p < Ep [k+1] ; p++)
600 "E(1+"ID
",1+"ID
") = %g ; ce(1+"ID
",1+"ID
") = "ID
"\n",
601 i,k, Ex[p], i,k,c)) ;
616 PR2 ((Common->
file,
"node: "ID
" sched: "ID
"\n", c, Sched [c])) ;
618 if (Sched [c] != myid)
634 PR2 ((Common->
file,
"n "ID
" nz "ID
"\n", cn, cnz)) ;
638 TAG0, MPI_COMM_WORLD, &req)) ;
639 MPI (MPI_Request_free (&req)) ;
641 TAG0, MPI_COMM_WORLD, &req)) ;
642 MPI (MPI_Request_free (&req)) ;
643 MPI (MPI_Isend (Cx, cnz, MPI_DOUBLE, Sched [c],
644 TAG0, MPI_COMM_WORLD, &req)) ;
645 MPI (MPI_Request_free (&req)) ;
657 for (c = 0 ; c < ncomponents ; c++)
659 if (Sched [c] == myid)
673 TAG0, MPI_COMM_WORLD, &ms)) ;
675 TAG0, MPI_COMM_WORLD, &ms)) ;
676 MPI (MPI_Recv (LU->
LUnode [c]->
A->
x, Cnz [c], MPI_DOUBLE, 0,
677 TAG0, MPI_COMM_WORLD, &ms)) ;
698 PR1 ((Common->
file,
"proc "ID
" Node "ID
" got orig:\n", myid, c));
699 PR2 ((Common->
file,
"n "ID
" nz "ID
"\n", Cn [c], Cnz [c])) ;
737 MPI (MPI_Barrier (MPI_COMM_WORLD)) ;
738 PR1 ((Common->
file,
"proc "ID
" everybody OK so far2\n", Common->
myid)) ;
741 for (c = 0 ; c < ncomponents ; c++)
752 for (c = 0 ; c < ncomponents ; c++)
754 if (Sched [c] == myid)
756 PR1 ((Common->
file,
"proc "ID
" Node "ID
" original matrix:\n", myid, c));
767 for (c = 0 ; c < ncomponents ; c++)
769 if (Sched [c] == myid)
771 PR1 ((Common->
file,
"proc "ID
" doing node "ID
"\n", myid, c)) ;
787 for (c = 0 ; c < ncomponents ; c++)
793 Sched [c], MPI_COMM_WORLD)) ;
794 kk += LU->
LUnode [c]->PK_NFOUND ;
800 PR0 ((Common->
file,
"proc "ID
" Singular: "ID
" of "ID
"\n", myid, kk, n)) ;
815 for (c = 0 ; c < ncomponents ; c++)
817 npiv = LU->
LUnode [c]->PK_NPIV ;
828 PR1 ((Common->
file,
"proc "ID
" here in PQ: ok "ID
"\n", Common->
myid, ok)) ;
830 MPI (MPI_Allreduce (&ok, &all_ok, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD)) ;
838 for (c = 0 ; c < ncomponents ; c++)
840 npiv = LU->
LUnode [c]->PK_NPIV ;
851 nfound = LU->
LUnode [c]->PK_NFOUND ;
852 for (k = 0 ; k < nfound ; k++)
857 P [kk] = Rperm [Pc [k]] ;
858 Q [kk] = Cperm [Qc [k]] ;
867 for (k = 0 ; k < n ; k++)
879 if (Common->
dump > 1)
892 for (k = 0 ; k < n ; k++) printf (
"P (1+"ID
") = "ID
" ;\n", k, P [k]) ;
893 for (k = 0 ; k < n ; k++) printf (
"Q (1+"ID
") = "ID
" ;\n", k, Q [k]) ;
895 printf (
"P = 1+P ;\n") ;
896 printf (
"Q = 1+Q ;\n") ;
898 for (j = 0 ; j < n ; j++)
900 for (p = Ap [j] ; p < Ap [j+1] ; p++)
902 printf (
"A (1+"ID
",1+"ID
") = %.16g ;\n", Ai [p], j, Ax [p]) ;
907 for (c = 0 ; c < ncomponents ; c++)
910 Int *Lip, *Llen, *Li, *Uip, *Ulen, *Ui ;
911 double *LUix, *Lx, *Ux ;
914 MPI (MPI_Barrier (MPI_COMM_WORLD)) ;
915 if (Sched [c] != myid) continue ;
916 printf (
"\n%% ---- node "ID
"\n", c) ;
921 Llen = LUnode->
llen ;
923 nfound = LUnode->PK_NFOUND ;
924 for (j = 0 ; j < nfound ; j++)
926 GET_COLUMN (Lip, Llen, LUix, j, Li, Lx, llen) ;
927 printf (
"\nL (1+"ID
",1+"ID
") = 1 ;\n", j, j) ;
928 for (p = 1 ; p < llen ; p++)
930 printf (
"L (1+"ID
",1+"ID
") = %.16g ;\n", Li [p], j, Lx [p]) ;
937 Ulen = LUnode->
ulen ;
938 for (j = cn-1 ; j >= nfound ; j--)
941 GET_COLUMN (Uip, Ulen, LUix, j, Ui, Ux, ulen) ;
942 for (p = 0 ; p < ulen ; p++)
944 printf (
"U (1+"ID
",1+"ID
") = %.16g ;\n", Ui [p], j, Ux [p]) ;
947 for ( ; j >= 0 ; j--)
949 GET_COLUMN (Uip, Ulen, LUix, j, Ui, Ux, ulen) ;
950 printf (
"\nU (1+"ID
",1+"ID
") = %.16g ; %% pivot\n",
952 for (p = 0 ; p < ulen-1 ; p++)
954 printf (
"U (1+"ID
",1+"ID
") = %.16g ;\n", Ui [p], j, Ux [p]) ;
959 if (Common->
nproc == 1 && Common->
dump > 1)
961 printf (
"norm (L*U-A(P,Q))\n") ;
static paraklete_numeric * amesos_paraklete_allocate_numeric(paraklete_symbolic *LUsymbolic, paraklete_common *Common)
struct paraklete_numeric_struct paraklete_numeric
#define PARAKLETE_ERROR(status, message)
Int amesos_paraklete_factorize_node(Int c, paraklete_numeric *LU, paraklete_symbolic *LUsymbolic, paraklete_common *Common)
int CHOLMOD() print_sparse(cholmod_sparse *A, char *name, cholmod_common *Common)
int CHOLMOD() sort(cholmod_sparse *A, cholmod_common *Common)
int CHOLMOD() free_sparse(cholmod_sparse **AHandle, cholmod_common *Common)
#define GET_COLUMN(Ap, Anz, Aix, j, Ai, Ax, len)
void amesos_paraklete_free_numeric(paraklete_numeric **LUHandle, paraklete_common *Common)
#define ASSERT(expression)
paraklete_numeric * amesos_paraklete_factorize(cholmod_sparse *A, paraklete_symbolic *LUsymbolic, paraklete_common *Common)
static cholmod_sparse * paraklete_permute(cholmod_sparse *A, paraklete_numeric *LU, paraklete_symbolic *LUsymbolic, paraklete_common *Common)
cholmod_sparse *CHOLMOD() allocate_sparse(size_t nrow, size_t ncol, size_t nzmax, int sorted, int packed, int stype, int xtype, cholmod_common *Common)
struct paraklete_node_struct paraklete_node