1 /* factorSetup.c */
2
3 #include "../BridgeMPI.h"
4
5 /*--------------------------------------------------------------------*/
6 /*
7 ----------------------------------------------------------
8 purpose -- to construct the map from fronts to processors,
9 and compute operations for each processor.
10
11 maptype -- type of map for parallel factorization
12 maptype = 1 --> wrap map
13 maptype = 2 --> balanced map
14 maptype = 3 --> subtree-subset map
15 maptype = 4 --> domain decomposition map
16 cutoff -- used when maptype = 4 as upper bound on
17 relative domain size
18
19 return value --
20 1 -- success
21 -1 -- bridge is NULL
22 -2 -- front tree is NULL
23
24 created -- 98sep25, cca
25 ----------------------------------------------------------
26 */
27 int
BridgeMPI_factorSetup(BridgeMPI * bridge,int maptype,double cutoff)28 BridgeMPI_factorSetup (
29 BridgeMPI *bridge,
30 int maptype,
31 double cutoff
32 ) {
33 double t1, t2 ;
34 DV *cumopsDV ;
35 ETree *frontETree ;
36 FILE *msgFile ;
37 int msglvl, nproc ;
38 /*
39 ---------------
40 check the input
41 ---------------
42 */
43 MARKTIME(t1) ;
44 if ( bridge == NULL ) {
45 fprintf(stderr, "\n error in BridgeMPI_factorSetup()"
46 "\n bridge is NULL") ;
47 return(-1) ;
48 }
49 if ( (frontETree = bridge->frontETree) == NULL ) {
50 fprintf(stderr, "\n error in BridgeMPI_factorSetup()"
51 "\n frontETree is NULL") ;
52 return(-2) ;
53 }
54 nproc = bridge->nproc ;
55 msglvl = bridge->msglvl ;
56 msgFile = bridge->msgFile ;
57 /*
58 -------------------------------------------
59 allocate and initialize the cumopsDV object
60 -------------------------------------------
61 */
62 if ( (cumopsDV = bridge->cumopsDV) == NULL ) {
63 cumopsDV = bridge->cumopsDV = DV_new() ;
64 }
65 DV_setSize(cumopsDV, nproc) ;
66 DV_zero(cumopsDV) ;
67 /*
68 ----------------------------
69 create the owners map object
70 ----------------------------
71 */
72 switch ( maptype ) {
73 case 1 :
74 bridge->ownersIV = ETree_wrapMap(frontETree, bridge->type,
75 bridge->symmetryflag, cumopsDV) ;
76 break ;
77 case 2 :
78 bridge->ownersIV = ETree_balancedMap(frontETree, bridge->type,
79 bridge->symmetryflag, cumopsDV) ;
80 break ;
81 case 3 :
82 bridge->ownersIV = ETree_subtreeSubsetMap(frontETree, bridge->type,
83 bridge->symmetryflag, cumopsDV) ;
84 break ;
85 case 4 :
86 bridge->ownersIV = ETree_ddMap(frontETree, bridge->type,
87 bridge->symmetryflag, cumopsDV, cutoff) ;
88 break ;
89 default :
90 bridge->ownersIV = ETree_ddMap(frontETree, bridge->type,
91 bridge->symmetryflag, cumopsDV, 1./(2*nproc)) ;
92 break ;
93 }
94 MARKTIME(t2) ;
95 bridge->cpus[7] = t2 - t1 ;
96 if ( msglvl > 1 ) {
97 fprintf(msgFile, "\n\n parallel factor setup") ;
98 fprintf(msgFile, "\n type = %d, symmetryflag = %d",
99 bridge->type, bridge->symmetryflag) ;
100 fprintf(msgFile, "\n total factor operations = %.0f",
101 DV_sum(cumopsDV)) ;
102 fprintf(msgFile,
103 "\n upper bound on speedup due to load balance = %.2f",
104 DV_max(cumopsDV)/DV_sum(cumopsDV)) ;
105 fprintf(msgFile, "\n operations distributions over threads") ;
106 DV_writeForHumanEye(cumopsDV, msgFile) ;
107 fflush(msgFile) ;
108 }
109 if ( msglvl > 2 ) {
110 fprintf(msgFile, "\n\n owners map IV object") ;
111 IV_writeForHumanEye(bridge->ownersIV, msgFile) ;
112 fflush(msgFile) ;
113 }
114 /*
115 ----------------------------
116 create the vertex map object
117 ----------------------------
118 */
119 bridge->vtxmapIV = IV_new() ;
120 IV_init(bridge->vtxmapIV, bridge->neqns, NULL) ;
121 IVgather(bridge->neqns, IV_entries(bridge->vtxmapIV),
122 IV_entries(bridge->ownersIV),
123 ETree_vtxToFront(bridge->frontETree)) ;
124 if ( msglvl > 2 ) {
125 fprintf(msgFile, "\n\n vertex map IV object") ;
126 IV_writeForHumanEye(bridge->vtxmapIV, msgFile) ;
127 fflush(msgFile) ;
128 }
129
130 return(1) ; }
131
132 /*--------------------------------------------------------------------*/
133