File: factorSetup.c

package info (click to toggle)
spooles 2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 19,012 kB
  • sloc: ansic: 146,834; csh: 3,615; makefile: 2,040; perl: 74
file content (125 lines) | stat: -rw-r--r-- 3,707 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*  factorSetup.c  */

#include "../BridgeMT.h"

/*--------------------------------------------------------------------*/
/*
   -------------------------------------------------------
   purpose -- to construct the map from fronts to threads,
      and compute operations for each thread.

   nthread -- number of threads
   maptype -- type of map for parallel factorization
     maptype = 1 --> wrap map
     maptype = 2 --> balanced map
     maptype = 3 --> subtree-subset map
     maptype = 4 --> domain decomposition map
   cutoff -- used when maptype = 4 as upper bound on
     relative domain size
  default is maptype = 4 and cutoff = 1/(2*nthread)

   return value --
      1 -- success
     -1 -- bridge is NULL
     -2 -- nthread is invalid, must be > 0
     -3 -- front tree is NULL

   created -- 98sep24, cca
   -------------------------------------------------------
*/
int
BridgeMT_factorSetup (
   BridgeMT   *bridge,
   int        nthread,
   int        maptype,
   double     cutoff
) {
double   t1, t2 ;
DV       *cumopsDV ;
ETree    *frontETree ;
FILE     *msgFile ;
int      msglvl ;
/*
   ---------------
   check the input
   ---------------
*/
MARKTIME(t1) ;
if ( bridge == NULL ) {
   fprintf(stderr, "\n error in BridgeMT_factorSetup()"
           "\n bridge is NULL") ;
   return(-1) ;
}
if ( nthread < 1 ) {
   fprintf(stderr, "\n error in BridgeMT_factorSetup()"
           "\n nthread = %d, is invalid", nthread) ;
   return(-2) ;
}
if ( (frontETree = bridge->frontETree) == NULL ) {
   fprintf(stderr, "\n error in BridgeMT_factorSetup()"
           "\n frontETree is NULL") ;
   return(-5) ;
}
bridge->nthread = nthread ;
/*
   -------------------------------------------
   allocate and initialize the cumopsDV object
   -------------------------------------------
*/
if ( (cumopsDV = bridge->cumopsDV) == NULL ) {
   cumopsDV = bridge->cumopsDV = DV_new() ;
}
DV_setSize(cumopsDV, nthread) ;
DV_zero(cumopsDV) ;
/*
   ----------------------------
   create the owners map object
   ----------------------------
*/
switch ( maptype ) {
case 1 :
   bridge->ownersIV = ETree_wrapMap(frontETree, bridge->type, 
                                  bridge->symmetryflag, cumopsDV) ;
   break ;
case 2 :
   bridge->ownersIV = ETree_balancedMap(frontETree, bridge->type,
                                  bridge->symmetryflag, cumopsDV) ;
   break ;
case 3 :
   bridge->ownersIV = ETree_subtreeSubsetMap(frontETree, bridge->type,
                                  bridge->symmetryflag, cumopsDV) ;
   break ;
case 4 :
   bridge->ownersIV = ETree_ddMap(frontETree, bridge->type,
                               bridge->symmetryflag, cumopsDV, cutoff) ;
   break ;
default :
   bridge->ownersIV = ETree_ddMap(frontETree, bridge->type,
                       bridge->symmetryflag, cumopsDV, 1./(2*nthread)) ;
   break ;
}
MARKTIME(t2) ;
bridge->cpus[5] = t2 - t1 ;
msglvl  = bridge->msglvl ;
msgFile = bridge->msgFile ;
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n\n parallel factor setup") ;
   fprintf(msgFile, "\n type = %d, symmetryflag = %d",
           bridge->type, bridge->symmetryflag) ;
   fprintf(msgFile, "\n total factor operations = %.0f",
           DV_sum(cumopsDV)) ;
   fprintf(msgFile, 
           "\n upper bound on speedup due to load balance = %.2f",
           DV_max(cumopsDV)/DV_sum(cumopsDV)) ;
   fprintf(msgFile, "\n operations distributions over threads") ;
   DV_writeForHumanEye(cumopsDV, msgFile) ;
   fflush(msgFile) ;
}
if ( msglvl > 2 ) {
   fprintf(msgFile, "\n\n owners map IV object") ;
   IV_writeForHumanEye(bridge->ownersIV, msgFile) ;
   fflush(msgFile) ;
}
return(1) ; }

/*--------------------------------------------------------------------*/