| 1 | /* |
|---|
| 2 | * ppuzzle.h |
|---|
| 3 | * |
|---|
| 4 | * |
|---|
| 5 | * Part of TREE-PUZZLE 5.0 (June 2000) |
|---|
| 6 | * |
|---|
| 7 | * (c) 1999-2000 by Heiko A. Schmidt, Korbinian Strimmer, |
|---|
| 8 | * M. Vingron, and Arndt von Haeseler |
|---|
| 9 | * (c) 1995-1999 by Korbinian Strimmer and Arndt von Haeseler |
|---|
| 10 | * |
|---|
| 11 | * All parts of the source except where indicated are distributed under |
|---|
| 12 | * the GNU public licence. See http://www.opensource.org for details. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #ifndef _PPUZZLE_ |
|---|
| 17 | #define _PPUZZLE_ |
|---|
| 18 | |
|---|
| 19 | #include "puzzle.h" |
|---|
| 20 | #include "util.h" |
|---|
| 21 | #include "ml.h" |
|---|
| 22 | #include "sched.h" |
|---|
| 23 | |
|---|
| 24 | extern int PP_IamSlave; |
|---|
| 25 | extern int PP_IamMaster; |
|---|
| 26 | |
|---|
| 27 | #ifdef PARALLEL |
|---|
| 28 | # ifdef SEQUENTIAL |
|---|
| 29 | # undef SEQUENTIAL |
|---|
| 30 | # endif |
|---|
| 31 | # define SEQUENTIAL 0 |
|---|
| 32 | # undef PARALLEL |
|---|
| 33 | # define PARALLEL 1 |
|---|
| 34 | # include "mpi.h" |
|---|
| 35 | #else |
|---|
| 36 | # ifdef SEQUENTIAL |
|---|
| 37 | # undef SEQUENTIAL |
|---|
| 38 | # endif |
|---|
| 39 | # define SEQUENTIAL 1 |
|---|
| 40 | # define PARALLEL 0 |
|---|
| 41 | # undef PVERBOSE |
|---|
| 42 | # undef PVERBOSE1 |
|---|
| 43 | # undef PVERBOSE2 |
|---|
| 44 | # undef PVERBOSE3 |
|---|
| 45 | #endif |
|---|
| 46 | |
|---|
| 47 | /* PVERBOSE3 includes PVERBOSE2 includes PVERBOSE1 */ |
|---|
| 48 | /* PVERBOSE1 is default (PVERBOSE) */ |
|---|
| 49 | |
|---|
| 50 | #ifdef PVERBOSE |
|---|
| 51 | # undef PVERBOSE1 |
|---|
| 52 | # define PVERBOSE1 |
|---|
| 53 | #endif |
|---|
| 54 | #ifdef PVERBOSE3 |
|---|
| 55 | # undef PVERBOSE2 |
|---|
| 56 | # define PVERBOSE2 |
|---|
| 57 | #endif |
|---|
| 58 | #ifdef PVERBOSE2 |
|---|
| 59 | # undef PVERBOSE1 |
|---|
| 60 | # define PVERBOSE1 |
|---|
| 61 | #endif |
|---|
| 62 | |
|---|
| 63 | #if PARALLEL |
|---|
| 64 | # define PP_DONE 0 /* Finished M->S */ |
|---|
| 65 | # define PP_SIZES 1 /* Array sizes needed M->S */ |
|---|
| 66 | # define PP_DATA 2 /* Data Arrays M->S */ |
|---|
| 67 | |
|---|
| 68 | # define PP_ALLQUARTS 3 /* All Quartets M->S */ |
|---|
| 69 | |
|---|
| 70 | # define PP_DOQUART 4 /* do 4Specs M->S */ |
|---|
| 71 | # define PP_DOQUARTX2 5 /* do 4Specs + X^2 M->S */ |
|---|
| 72 | # define PP_QUART 6 /* quartet back S->M */ |
|---|
| 73 | # define PP_QUARTX2 7 /* quartet + X^2 back S->M */ |
|---|
| 74 | |
|---|
| 75 | # define PP_DOQUARTBLOCKSPECS 8 /* do block Specs M->S */ |
|---|
| 76 | # define PP_DOQUARTBLOCK 9 /* do block of Quarts M->S */ |
|---|
| 77 | # define PP_QUARTBLOCKSPECS 10 /* block Specs S->M */ |
|---|
| 78 | # define PP_QUARTBLOCK 11 /* block of Quarts S->M */ |
|---|
| 79 | |
|---|
| 80 | # define PP_DOPUZZLE 12 /* do Puzzling step M->S */ |
|---|
| 81 | # define PP_PUZZLE 13 /* Puzzling tree back S->M */ |
|---|
| 82 | # define PP_DOPUZZLEBLOCK 14 /* do Puzzling block M->S */ |
|---|
| 83 | # define PP_DOPUZZLEBLOCKSPECS 15 /* do Puzzling block M->S */ |
|---|
| 84 | # define PP_PUZZLEBLOCK 16 /* Puzzling block S->M */ |
|---|
| 85 | # define PP_PUZZLEBLOCKSPECS 17 /* Puzzling block S->M */ |
|---|
| 86 | |
|---|
| 87 | # define PP_STATS 18 /* Slave Statistics S->M */ |
|---|
| 88 | |
|---|
| 89 | # define PP_WAIT 18 /* waiting for work S->M */ |
|---|
| 90 | # define PP_TEST 100 /* testing */ |
|---|
| 91 | |
|---|
| 92 | # define PERMUTQUEUESIZE 100 |
|---|
| 93 | # define QUARTQUEUESIZE 100 |
|---|
| 94 | |
|---|
| 95 | extern int PP_IamMaster; |
|---|
| 96 | extern int PP_IamSlave; |
|---|
| 97 | extern int PP_Myid; |
|---|
| 98 | extern int PP_MyMaster; |
|---|
| 99 | extern int PP_NumProcs; |
|---|
| 100 | extern MPI_Comm PP_Comm; |
|---|
| 101 | #endif /* PARALLEL */ |
|---|
| 102 | |
|---|
| 103 | extern int *permutsent, |
|---|
| 104 | *permutrecved, |
|---|
| 105 | *quartsent, |
|---|
| 106 | *quartrecved, |
|---|
| 107 | *doquartsent, |
|---|
| 108 | *doquartrecved, |
|---|
| 109 | *splitsent, |
|---|
| 110 | *splitrecved, |
|---|
| 111 | *permutsentn, |
|---|
| 112 | *permutrecvedn, |
|---|
| 113 | *quartsentn, |
|---|
| 114 | *quartrecvedn, |
|---|
| 115 | *doquartsentn, |
|---|
| 116 | *doquartrecvedn, |
|---|
| 117 | *splitsentn, |
|---|
| 118 | *splitrecvedn; |
|---|
| 119 | extern double *walltimes, |
|---|
| 120 | *cputimes; |
|---|
| 121 | extern double *fullwalltimes, |
|---|
| 122 | *fullcputimes; |
|---|
| 123 | extern double *altwalltimes, |
|---|
| 124 | *altcputimes; |
|---|
| 125 | |
|---|
| 126 | extern int PP_permutsent, |
|---|
| 127 | PP_permutrecved, |
|---|
| 128 | PP_quartsent, |
|---|
| 129 | PP_quartrecved, |
|---|
| 130 | PP_doquartsent, |
|---|
| 131 | PP_doquartrecved, |
|---|
| 132 | PP_splitsent, |
|---|
| 133 | PP_splitrecved, |
|---|
| 134 | PP_permutsentn, |
|---|
| 135 | PP_permutrecvedn, |
|---|
| 136 | PP_quartsentn, |
|---|
| 137 | PP_quartrecvedn, |
|---|
| 138 | PP_doquartsentn, |
|---|
| 139 | PP_doquartrecvedn, |
|---|
| 140 | PP_splitsentn, |
|---|
| 141 | PP_splitrecvedn; |
|---|
| 142 | |
|---|
| 143 | extern double PP_starttime, |
|---|
| 144 | PP_stoptime, |
|---|
| 145 | PP_inittime, |
|---|
| 146 | PP_paramcomptime, |
|---|
| 147 | PP_paramsendtime, |
|---|
| 148 | PP_quartcomptime, |
|---|
| 149 | PP_quartsendtime, |
|---|
| 150 | PP_puzzletime, |
|---|
| 151 | PP_treetime; |
|---|
| 152 | |
|---|
| 153 | void num2quart(uli qnum, int *a, int *b, int *c, int *d); |
|---|
| 154 | uli numquarts(int maxspc); |
|---|
| 155 | uli quart2num (int a, int b, int c, int d); |
|---|
| 156 | |
|---|
| 157 | int slave_main(int argc, char *argv[]); |
|---|
| 158 | void PP_Init(int *argc, char **argv[]); |
|---|
| 159 | void PP_Finalize(); |
|---|
| 160 | void PP_Printerror(FILE *of, int id, int err); |
|---|
| 161 | void PP_do_puzzling(ivector trueID); |
|---|
| 162 | |
|---|
| 163 | void PP_RecvDoQuart(int *a, |
|---|
| 164 | int *b, |
|---|
| 165 | int *c, |
|---|
| 166 | int *d, |
|---|
| 167 | int *approx); |
|---|
| 168 | void PP_SendDoQuart(int dest, |
|---|
| 169 | int a, |
|---|
| 170 | int b, |
|---|
| 171 | int c, |
|---|
| 172 | int d, |
|---|
| 173 | int approx); |
|---|
| 174 | void PP_RecvQuart(int *a, |
|---|
| 175 | int *b, |
|---|
| 176 | int *c, |
|---|
| 177 | int *d, |
|---|
| 178 | double *d1, |
|---|
| 179 | double *d2, |
|---|
| 180 | double *d3, |
|---|
| 181 | int *approx); |
|---|
| 182 | void PP_SendQuart(int a, |
|---|
| 183 | int b, |
|---|
| 184 | int c, |
|---|
| 185 | int d, |
|---|
| 186 | double d1, |
|---|
| 187 | double d2, |
|---|
| 188 | double d3, |
|---|
| 189 | int approx); |
|---|
| 190 | void PP_SendSizes(int mspc, |
|---|
| 191 | int msite, |
|---|
| 192 | int ncats, |
|---|
| 193 | int nptrn, |
|---|
| 194 | int rad, |
|---|
| 195 | int outgr, |
|---|
| 196 | double frconst, |
|---|
| 197 | int rseed); |
|---|
| 198 | void PP_RecvSizes(int *mspc, |
|---|
| 199 | int *msite, |
|---|
| 200 | int *ncats, |
|---|
| 201 | int *nptrn, |
|---|
| 202 | int *rad, |
|---|
| 203 | int *outgr, |
|---|
| 204 | double *frconst, |
|---|
| 205 | int *rseed); |
|---|
| 206 | void PP_RecvData( |
|---|
| 207 | cmatrix Seqpat, /* cmatrix (Maxspc x Numptrn) */ |
|---|
| 208 | ivector Alias, /* ivector (Maxsite) */ |
|---|
| 209 | ivector Weight, /* ivector (Numptrn) */ |
|---|
| 210 | ivector constpat, |
|---|
| 211 | dvector Rates, /* dvector (numcats) */ |
|---|
| 212 | dvector Eval, /* dvector (tpmradix) */ |
|---|
| 213 | dvector Freqtpm, |
|---|
| 214 | dmatrix Evec, /* dmatrix (tpmradix x tpmradix) */ |
|---|
| 215 | dmatrix Ievc, |
|---|
| 216 | dmatrix iexp, |
|---|
| 217 | dmatrix Distanmat, /* dmatrix (Maxspc x Maxspc) */ |
|---|
| 218 | dcube ltprobr); /* dcube (numcats x tpmradix x tpmradix) */ |
|---|
| 219 | void PP_SendData( |
|---|
| 220 | cmatrix Seqpat, /* cmatrix (Maxspc x Numptrn) */ |
|---|
| 221 | ivector Alias, /* ivector (Maxsite) */ |
|---|
| 222 | ivector Weight, /* ivector (Numptrn) */ |
|---|
| 223 | ivector constpat, |
|---|
| 224 | dvector Rates, /* dvector (numcats) */ |
|---|
| 225 | dvector Eval, /* dvector (tpmradix) */ |
|---|
| 226 | dvector Freqtpm, |
|---|
| 227 | dmatrix Evec, /* dmatrix (tpmradix x tpmradix) */ |
|---|
| 228 | dmatrix Ievc, |
|---|
| 229 | dmatrix iexp, |
|---|
| 230 | dmatrix Distanmat, /* dmatrix (Maxspc x Maxspc) */ |
|---|
| 231 | dcube ltprobr); /* dcube (numcats x tpmradix x tpmradix) */ |
|---|
| 232 | void PP_SendAllQuarts(unsigned long Numquartets, |
|---|
| 233 | unsigned char *local_quartetinfo); |
|---|
| 234 | void PP_RecvAllQuarts(int taxa, |
|---|
| 235 | unsigned long *Numquartets, |
|---|
| 236 | unsigned char *local_quartetinfo); |
|---|
| 237 | |
|---|
| 238 | void PP_SendDoQuartBlock(int dest, uli firstq, uli amount, int approx); |
|---|
| 239 | void PP_RecvDoQuartBlock(uli *firstq, uli *amount, uli **bq, int *approx); |
|---|
| 240 | void PP_SendQuartBlock(uli startq, |
|---|
| 241 | uli numofq, |
|---|
| 242 | unsigned char *local_quartetinfo, |
|---|
| 243 | uli numofbq, |
|---|
| 244 | uli *bq, |
|---|
| 245 | int approx); |
|---|
| 246 | void PP_RecvQuartBlock(int slave, |
|---|
| 247 | uli *startq, |
|---|
| 248 | uli *numofq, |
|---|
| 249 | unsigned char *local_quartetinfo, |
|---|
| 250 | int *approx); |
|---|
| 251 | |
|---|
| 252 | void PP_SendPermut(int dest, |
|---|
| 253 | int taxa, |
|---|
| 254 | ivector permut); |
|---|
| 255 | void PP_RecvPermut(int taxa, |
|---|
| 256 | ivector permut); |
|---|
| 257 | void PP_SendDoPermutBlock(uli puzzlings); |
|---|
| 258 | void PP_RecvDoPermutBlock(uli *taxa); |
|---|
| 259 | |
|---|
| 260 | void PP_SendSplits(int taxa, |
|---|
| 261 | cmatrix biparts); |
|---|
| 262 | void PP_RecvSplits(int taxa, |
|---|
| 263 | cmatrix biparts); |
|---|
| 264 | void PP_SendDone(); |
|---|
| 265 | void PP_RecvDone(); |
|---|
| 266 | |
|---|
| 267 | int PP_emptyslave(); |
|---|
| 268 | void PP_putslave(int sl); |
|---|
| 269 | int PP_getslave(); |
|---|
| 270 | |
|---|
| 271 | void PP_cmpd(int rank, double a, double b); |
|---|
| 272 | void PP_cmpi(int rank, int a, int b); |
|---|
| 273 | |
|---|
| 274 | #endif /* _PPUZZLE_ */ |
|---|