| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#include <p7_config.h> |
| 13 |
|
| 14 |
#ifdef HMMER_MPI |
| 15 |
#include <stdlib.h> |
| 16 |
#include <stdio.h> |
| 17 |
#include <string.h> |
| 18 |
|
| 19 |
#include "mpi.h" |
| 20 |
|
| 21 |
#include "easel.h" |
| 22 |
#include "esl_mpi.h" |
| 23 |
#include "esl_getopts.h" |
| 24 |
|
| 25 |
#include "hmmer.h" |
| 26 |
|
| 27 |
static int p7_hit_MPISend(P7_HIT *hit, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc); |
| 28 |
static int p7_hit_MPIPackSize(P7_HIT *hit, MPI_Comm comm, int *ret_n); |
| 29 |
static int p7_hit_MPIPack(P7_HIT *hit, char *buf, int n, int *pos, MPI_Comm comm); |
| 30 |
static int p7_hit_MPIUnpack(char *buf, int n, int *pos, MPI_Comm comm, P7_HIT *hit); |
| 31 |
static int p7_hit_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, P7_HIT *hit); |
| 32 |
|
| 33 |
static int p7_dcl_MPISend(P7_DOMAIN *dcl, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc); |
| 34 |
static int p7_dcl_MPIPackSize(P7_DOMAIN *dcl, MPI_Comm comm, int *ret_n); |
| 35 |
static int p7_dcl_MPIPack(P7_DOMAIN *dcl, char *buf, int n, int *pos, MPI_Comm comm); |
| 36 |
static int p7_dcl_MPIUnpack(char *buf, int n, int *pos, MPI_Comm comm, P7_DOMAIN *dcl); |
| 37 |
static int p7_dcl_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, P7_DOMAIN *dcl); |
| 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 |
int |
| 79 |
p7_hmm_MPISend(P7_HMM *hmm, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc) |
| 80 |
{ |
| 81 |
int status; |
| 82 |
int code; |
| 83 |
int sz, n, pos; |
| 84 |
|
| 85 |
|
| 86 |
if (MPI_Pack_size(1, MPI_INT, comm, &n) != 0) ESL_XEXCEPTION(eslESYS, "mpi pack size failed"); |
| 87 |
if (hmm != NULL) { |
| 88 |
if ((status = p7_hmm_MPIPackSize(hmm, comm, &sz)) != eslOK) return status; |
| 89 |
n += sz; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
if (*buf == NULL || n > *nalloc) { |
| 94 |
void *tmp; |
| 95 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 96 |
*nalloc = n; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
pos = 0; |
| 101 |
code = (hmm == NULL) ? eslEOD : eslOK; |
| 102 |
if (MPI_Pack(&code, 1, MPI_INT, *buf, n, &pos, comm) != 0) ESL_EXCEPTION(eslESYS, "mpi pack failed"); |
| 103 |
if (hmm != NULL) { |
| 104 |
if ((status = p7_hmm_MPIPack(hmm, *buf, n, &pos, comm)) != eslOK) return status; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
if (MPI_Send(*buf, n, MPI_PACKED, dest, tag, comm) != 0) ESL_EXCEPTION(eslESYS, "mpi send failed"); |
| 109 |
return eslOK; |
| 110 |
|
| 111 |
ERROR: |
| 112 |
return status; |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
int |
| 128 |
p7_hmm_MPIPackSize(P7_HMM *hmm, MPI_Comm comm, int *ret_n) |
| 129 |
{ |
| 130 |
int status; |
| 131 |
int n = 0; |
| 132 |
int K = hmm->abc->K; |
| 133 |
int M = hmm->M; |
| 134 |
int sz; |
| 135 |
|
| 136 |
if (MPI_Pack_size(1, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += 6*sz; |
| 137 |
if (MPI_Pack_size(1, MPI_FLOAT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += 6*sz; |
| 138 |
if (MPI_Pack_size(7*(M+1), MPI_FLOAT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 139 |
if (MPI_Pack_size(K*(M+1), MPI_FLOAT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += 2*sz; |
| 140 |
|
| 141 |
if ((status = esl_mpi_PackOptSize(hmm->name, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n += sz; |
| 142 |
if ((status = esl_mpi_PackOptSize(hmm->acc, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n += sz; |
| 143 |
if ((status = esl_mpi_PackOptSize(hmm->desc, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n += sz; |
| 144 |
|
| 145 |
if (hmm->flags & p7H_RF) { if (MPI_Pack_size(M+2, MPI_CHAR, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; } |
| 146 |
if (hmm->flags & p7H_MMASK) { if (MPI_Pack_size(M+2, MPI_CHAR, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; } |
| 147 |
if (hmm->flags & p7H_CONS) { if (MPI_Pack_size(M+2, MPI_CHAR, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; } |
| 148 |
if (hmm->flags & p7H_CS) { if (MPI_Pack_size(M+2, MPI_CHAR, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; } |
| 149 |
if (hmm->flags & p7H_CA) { if (MPI_Pack_size(M+2, MPI_CHAR, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; } |
| 150 |
if ((status = esl_mpi_PackOptSize(hmm->comlog, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n+= sz; |
| 151 |
if ((status = esl_mpi_PackOptSize(hmm->ctime, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n+= sz; |
| 152 |
if (hmm->flags & p7H_MAP) { if (MPI_Pack_size(M+1, MPI_INT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; } |
| 153 |
if (MPI_Pack_size(p7_NEVPARAM, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; |
| 154 |
if (MPI_Pack_size(p7_NCUTOFFS, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; |
| 155 |
if (MPI_Pack_size(p7_MAXABET, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n+= sz; |
| 156 |
*ret_n = n; |
| 157 |
return eslOK; |
| 158 |
|
| 159 |
ERROR: |
| 160 |
*ret_n = 0; |
| 161 |
return status; |
| 162 |
|
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
int |
| 190 |
p7_hmm_MPIPack(P7_HMM *hmm, char *buf, int n, int *pos, MPI_Comm comm) |
| 191 |
{ |
| 192 |
int status; |
| 193 |
int K = hmm->abc->K; |
| 194 |
int M = hmm->M; |
| 195 |
|
| 196 |
if (MPI_Pack( &M, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 197 |
if (MPI_Pack( &(hmm->flags), 1, MPI_INT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 198 |
if (MPI_Pack( (void *) &(hmm->abc->type), 1, MPI_INT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 199 |
if (MPI_Pack( hmm->t[0], 7*(M+1), MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 200 |
if (MPI_Pack( hmm->mat[0], K*(M+1), MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 201 |
if (MPI_Pack( hmm->ins[0], K*(M+1), MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 202 |
|
| 203 |
if ((status = esl_mpi_PackOpt( hmm->name, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 204 |
if ((status = esl_mpi_PackOpt( hmm->acc, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 205 |
if ((status = esl_mpi_PackOpt( hmm->desc, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 206 |
if (hmm->flags & p7H_RF) { if (MPI_Pack(hmm->rf, M+2, MPI_CHAR, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); } |
| 207 |
if (hmm->flags & p7H_MMASK) { if (MPI_Pack(hmm->mm, M+2, MPI_CHAR, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); } |
| 208 |
if (hmm->flags & p7H_CONS) { if (MPI_Pack(hmm->consensus, M+2, MPI_CHAR, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); } |
| 209 |
if (hmm->flags & p7H_CS) { if (MPI_Pack(hmm->cs, M+2, MPI_CHAR, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); } |
| 210 |
if (hmm->flags & p7H_CA) { if (MPI_Pack(hmm->ca, M+2, MPI_CHAR, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); } |
| 211 |
if ((status = esl_mpi_PackOpt( hmm->comlog, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 212 |
if (MPI_Pack( &(hmm->nseq), 1, MPI_INT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 213 |
if (MPI_Pack( &(hmm->eff_nseq), 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 214 |
if ((status = esl_mpi_PackOpt( hmm->ctime, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 215 |
if (hmm->flags & p7H_MAP) { if (MPI_Pack(hmm->map, M+1, MPI_INT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); } |
| 216 |
if (MPI_Pack( &(hmm->checksum), 1, MPI_INT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 217 |
if (MPI_Pack( hmm->evparam, p7_NEVPARAM, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 218 |
if (MPI_Pack( hmm->cutoff, p7_NCUTOFFS, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 219 |
if (MPI_Pack( hmm->compo, p7_MAXABET, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_EXCEPTION(eslESYS, "pack failed"); |
| 220 |
|
| 221 |
if (*pos > n) ESL_EXCEPTION(eslEMEM, "buffer overflow"); |
| 222 |
return eslOK; |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
int |
| 264 |
p7_hmm_MPIUnpack(char *buf, int n, int *pos, MPI_Comm comm, ESL_ALPHABET **abc, P7_HMM **ret_hmm) |
| 265 |
{ |
| 266 |
int status; |
| 267 |
P7_HMM *hmm = NULL; |
| 268 |
int M, K, atype; |
| 269 |
|
| 270 |
if ((hmm = p7_hmm_CreateShell()) == NULL) { status = eslEMEM; goto ERROR; } |
| 271 |
if (MPI_Unpack(buf, n, pos, &(hmm->M), 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 272 |
if (MPI_Unpack(buf, n, pos, &(hmm->flags), 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 273 |
if (MPI_Unpack(buf, n, pos, &atype, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 274 |
|
| 275 |
|
| 276 |
if (*abc == NULL) { |
| 277 |
if ((*abc = esl_alphabet_Create(atype)) == NULL) { status = eslEMEM; goto ERROR; } |
| 278 |
} else { |
| 279 |
if ((*abc)->type != atype) { status = eslEINCOMPAT; goto ERROR; } |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
K = (*abc)->K; |
| 284 |
M = hmm->M; |
| 285 |
|
| 286 |
|
| 287 |
if ((status = p7_hmm_CreateBody(hmm, M, *abc)) != eslOK) goto ERROR; |
| 288 |
|
| 289 |
|
| 290 |
if (MPI_Unpack( buf, n, pos, hmm->t[0], 7*(M+1), MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 291 |
if (MPI_Unpack( buf, n, pos, hmm->mat[0], K*(M+1), MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 292 |
if (MPI_Unpack( buf, n, pos, hmm->ins[0], K*(M+1), MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 293 |
if ((status = esl_mpi_UnpackOpt( buf, n, pos, (void**)&(hmm->name), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 294 |
if ((status = esl_mpi_UnpackOpt( buf, n, pos, (void**)&(hmm->acc), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 295 |
if ((status = esl_mpi_UnpackOpt( buf, n, pos, (void**)&(hmm->desc), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 296 |
if (hmm->flags & p7H_RF) { if (MPI_Unpack(buf, n, pos, hmm->rf, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); } |
| 297 |
if (hmm->flags & p7H_MMASK) { if (MPI_Unpack(buf, n, pos, hmm->mm, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); } |
| 298 |
if (hmm->flags & p7H_CONS) { if (MPI_Unpack(buf, n, pos, hmm->consensus, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); } |
| 299 |
if (hmm->flags & p7H_CS) { if (MPI_Unpack(buf, n, pos, hmm->cs, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); } |
| 300 |
if (hmm->flags & p7H_CA) { if (MPI_Unpack(buf, n, pos, hmm->ca, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); } |
| 301 |
if ((status = esl_mpi_UnpackOpt( buf, n, pos, (void**)&(hmm->comlog), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 302 |
if (MPI_Unpack( buf, n, pos, &(hmm->nseq), 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 303 |
if (MPI_Unpack( buf, n, pos, &(hmm->eff_nseq), 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 304 |
if ((status = esl_mpi_UnpackOpt( buf, n, pos, (void**)&(hmm->ctime), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 305 |
if (hmm->flags & p7H_MAP) { if (MPI_Unpack(buf, n, pos, hmm->map, M+1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); } |
| 306 |
if (MPI_Unpack( buf, n, pos, &(hmm->checksum), 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 307 |
if (MPI_Unpack( buf, n, pos, hmm->evparam, p7_NEVPARAM, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 308 |
if (MPI_Unpack( buf, n, pos, hmm->cutoff, p7_NCUTOFFS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 309 |
if (MPI_Unpack( buf, n, pos, hmm->compo, p7_MAXABET, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 310 |
|
| 311 |
*ret_hmm = hmm; |
| 312 |
return eslOK; |
| 313 |
|
| 314 |
ERROR: |
| 315 |
if (hmm != NULL) p7_hmm_Destroy(hmm); |
| 316 |
return status; |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
int |
| 377 |
p7_hmm_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, ESL_ALPHABET **abc, P7_HMM **ret_hmm) |
| 378 |
{ |
| 379 |
int status; |
| 380 |
int code; |
| 381 |
P7_HMM *hmm = NULL; |
| 382 |
int n; |
| 383 |
int pos; |
| 384 |
MPI_Status mpistatus; |
| 385 |
|
| 386 |
|
| 387 |
MPI_Probe(source, tag, comm, &mpistatus); |
| 388 |
MPI_Get_count(&mpistatus, MPI_PACKED, &n); |
| 389 |
|
| 390 |
|
| 391 |
if (*buf == NULL || n > *nalloc) { |
| 392 |
void *tmp; |
| 393 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 394 |
*nalloc = n; |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
MPI_Recv(*buf, n, MPI_PACKED, source, tag, comm, &mpistatus); |
| 399 |
|
| 400 |
|
| 401 |
pos = 0; |
| 402 |
if (MPI_Unpack(*buf, n, &pos, &code, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 403 |
if (code == eslEOD) { *ret_hmm = NULL; return eslEOD; } |
| 404 |
|
| 405 |
return p7_hmm_MPIUnpack(*buf, *nalloc, &pos, comm, abc, ret_hmm); |
| 406 |
|
| 407 |
ERROR: |
| 408 |
if (hmm != NULL) p7_hmm_Destroy(hmm); |
| 409 |
return status; |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
int |
| 471 |
p7_profile_MPISend(P7_PROFILE *gm, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc) |
| 472 |
{ |
| 473 |
int status; |
| 474 |
int sz, n, position; |
| 475 |
int Kp; |
| 476 |
int M; |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
if (gm == NULL) { |
| 482 |
if (MPI_Pack_size(1, MPI_INT, comm, &n) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); |
| 483 |
Kp = M = 0; |
| 484 |
} else { |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
Kp = gm->abc->Kp; |
| 491 |
M = gm->M; |
| 492 |
n = 0; |
| 493 |
if (MPI_Pack_size( 1, MPI_INT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz*3; |
| 494 |
if (MPI_Pack_size( p7P_NTRANS * M, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz; |
| 495 |
if (MPI_Pack_size( (M+1) * Kp * p7P_NR, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz; |
| 496 |
if (MPI_Pack_size( p7P_NXTRANS, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz*p7P_NXSTATES; |
| 497 |
if (MPI_Pack_size( 1, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz; |
| 498 |
if ((status = esl_mpi_PackOptSize(gm->name, -1, MPI_CHAR, comm, &sz))!= eslOK) goto ERROR; else n += sz; |
| 499 |
if ((status = esl_mpi_PackOptSize(gm->acc, -1, MPI_CHAR, comm, &sz))!= eslOK) goto ERROR; else n += sz; |
| 500 |
if ((status = esl_mpi_PackOptSize(gm->desc, -1, MPI_CHAR, comm, &sz))!= eslOK) goto ERROR; else n += sz; |
| 501 |
if (MPI_Pack_size( (M+2), MPI_CHAR, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz*4; |
| 502 |
if (MPI_Pack_size( p7_NEVPARAM, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz; |
| 503 |
if (MPI_Pack_size( p7_NCUTOFFS, MPI_FLOAT, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); else n += sz; |
| 504 |
} |
| 505 |
|
| 506 |
|
| 507 |
if (*buf == NULL || n > *nalloc) { |
| 508 |
void *tmp; |
| 509 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 510 |
*nalloc = n; |
| 511 |
} |
| 512 |
|
| 513 |
|
| 514 |
position = 0; |
| 515 |
if (gm == NULL) |
| 516 |
{ |
| 517 |
int eod_code = -1; |
| 518 |
if (MPI_Pack(&eod_code, 1, MPI_INT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 519 |
} |
| 520 |
else |
| 521 |
{ |
| 522 |
if (MPI_Pack(&M, 1, MPI_INT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 523 |
if (MPI_Pack(&(gm->mode), 1, MPI_INT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 524 |
if (MPI_Pack(&(gm->L), 1, MPI_INT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 525 |
if (MPI_Pack(gm->tsc, p7P_NTRANS *M, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 526 |
if (MPI_Pack(gm->rsc[0], (M+1)* Kp * p7P_NR, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 527 |
if (MPI_Pack(gm->xsc[0], p7P_NXTRANS, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 528 |
if (MPI_Pack(gm->xsc[1], p7P_NXTRANS, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 529 |
if (MPI_Pack(gm->xsc[2], p7P_NXTRANS, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 530 |
if (MPI_Pack(gm->xsc[3], p7P_NXTRANS, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 531 |
if (MPI_Pack(&(gm->nj), 1, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 532 |
if ((status = esl_mpi_PackOpt(gm->name, -1, MPI_CHAR, *buf, n, &position, comm)) != eslOK) goto ERROR; |
| 533 |
if ((status = esl_mpi_PackOpt(gm->acc, -1, MPI_CHAR, *buf, n, &position, comm)) != eslOK) goto ERROR; |
| 534 |
if ((status = esl_mpi_PackOpt(gm->desc, -1, MPI_CHAR, *buf, n, &position, comm)) != eslOK) goto ERROR; |
| 535 |
if (MPI_Pack(gm->rf, M+2, MPI_CHAR, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 536 |
if (MPI_Pack(gm->mm, M+2, MPI_CHAR, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 537 |
if (MPI_Pack(gm->cs, M+2, MPI_CHAR, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 538 |
if (MPI_Pack(gm->consensus, M+2, MPI_CHAR, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 539 |
if (MPI_Pack(gm->evparam, p7_NEVPARAM, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 540 |
if (MPI_Pack(gm->cutoff, p7_NCUTOFFS, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 541 |
if (MPI_Pack(gm->compo, p7_MAXABET, MPI_FLOAT, *buf, n, &position, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
MPI_Send(*buf, n, MPI_PACKED, dest, tag, comm); |
| 546 |
return eslOK; |
| 547 |
|
| 548 |
ERROR: |
| 549 |
return status; |
| 550 |
} |
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
int |
| 584 |
p7_profile_MPIRecv(int source, int tag, MPI_Comm comm, const ESL_ALPHABET *abc, const P7_BG *bg, char **buf, int *nalloc, P7_PROFILE **ret_gm) |
| 585 |
{ |
| 586 |
int status; |
| 587 |
P7_PROFILE *gm = NULL; |
| 588 |
int n; |
| 589 |
int position; |
| 590 |
MPI_Status mpistatus; |
| 591 |
int M; |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
MPI_Probe(source, tag, comm, &mpistatus); |
| 596 |
MPI_Get_count(&mpistatus, MPI_PACKED, &n); |
| 597 |
|
| 598 |
|
| 599 |
if (*buf == NULL || n > *nalloc) { |
| 600 |
void *tmp; |
| 601 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 602 |
*nalloc = n; |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
MPI_Recv(*buf, n, MPI_PACKED, source, tag, comm, &mpistatus); |
| 607 |
|
| 608 |
|
| 609 |
position = 0; |
| 610 |
if (MPI_Unpack(*buf, n, &position, &M, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 611 |
if (M == -1) { *ret_gm = NULL; return eslEOD; } |
| 612 |
|
| 613 |
if ((gm = p7_profile_Create(M, abc)) == NULL) { status = eslEMEM; goto ERROR; } |
| 614 |
if (MPI_Unpack(*buf, n, &position, &(gm->mode), 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 615 |
if (MPI_Unpack(*buf, n, &position, &(gm->L), 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 616 |
if (MPI_Unpack(*buf, n, &position, gm->tsc, p7P_NTRANS*M, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 617 |
if (MPI_Unpack(*buf, n, &position, gm->rsc[0], p7P_NR*(M+1)*abc->Kp, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 618 |
if (MPI_Unpack(*buf, n, &position, gm->xsc[0], p7P_NXTRANS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 619 |
if (MPI_Unpack(*buf, n, &position, gm->xsc[1], p7P_NXTRANS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 620 |
if (MPI_Unpack(*buf, n, &position, gm->xsc[2], p7P_NXTRANS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 621 |
if (MPI_Unpack(*buf, n, &position, gm->xsc[3], p7P_NXTRANS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 622 |
if (MPI_Unpack(*buf, n, &position, &(gm->nj), 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 623 |
|
| 624 |
if ((status = esl_mpi_UnpackOpt( *buf, n, &position, (void**)&(gm->name), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 625 |
if ((status = esl_mpi_UnpackOpt( *buf, n, &position, (void**)&(gm->acc), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 626 |
if ((status = esl_mpi_UnpackOpt( *buf, n, &position, (void**)&(gm->desc), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 627 |
|
| 628 |
if (MPI_Unpack(*buf, n, &position, gm->rf, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 629 |
if (MPI_Unpack(*buf, n, &position, gm->mm, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 630 |
if (MPI_Unpack(*buf, n, &position, gm->cs, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 631 |
if (MPI_Unpack(*buf, n, &position, gm->consensus, M+2, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 632 |
if (MPI_Unpack(*buf, n, &position, gm->evparam, p7_NEVPARAM, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 633 |
if (MPI_Unpack(*buf, n, &position, gm->cutoff, p7_NCUTOFFS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 634 |
if (MPI_Unpack(*buf, n, &position, gm->compo, p7_NCUTOFFS, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 635 |
|
| 636 |
gm->abc = abc; |
| 637 |
gm->M = M; |
| 638 |
*ret_gm = gm; |
| 639 |
return eslOK; |
| 640 |
|
| 641 |
ERROR: |
| 642 |
if (gm != NULL) p7_profile_Destroy(gm); |
| 643 |
*ret_gm = NULL; |
| 644 |
return status; |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
int |
| 676 |
p7_pipeline_MPISend(P7_PIPELINE *pli, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc) |
| 677 |
{ |
| 678 |
int status; |
| 679 |
int sz, n, pos; |
| 680 |
|
| 681 |
P7_PIPELINE bogus; |
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
n = 0; |
| 689 |
if (MPI_Pack_size(1, MPI_LONG_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 690 |
if (MPI_Pack_size(1, MPI_LONG_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 691 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 692 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 693 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 694 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 695 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 696 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 697 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 698 |
if (MPI_Pack_size(1, MPI_UINT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 699 |
if (MPI_Pack_size(1, MPI_DOUBLE, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 700 |
|
| 701 |
|
| 702 |
if (*buf == NULL || n > *nalloc) { |
| 703 |
void *tmp; |
| 704 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 705 |
*nalloc = n; |
| 706 |
} |
| 707 |
|
| 708 |
|
| 709 |
if (pli == NULL) |
| 710 |
{ |
| 711 |
bogus.mode = p7_SEARCH_SEQS; |
| 712 |
bogus.Z_setby = p7_ZSETBY_NTARGETS; |
| 713 |
bogus.nmodels = 0; |
| 714 |
bogus.nseqs = 0; |
| 715 |
bogus.nres = 0; |
| 716 |
bogus.nnodes = 0; |
| 717 |
bogus.n_past_msv = 0; |
| 718 |
bogus.n_past_bias = 0; |
| 719 |
bogus.n_past_vit = 0; |
| 720 |
bogus.n_past_fwd = 0; |
| 721 |
bogus.Z = 0.0; |
| 722 |
pli = &bogus; |
| 723 |
} |
| 724 |
|
| 725 |
|
| 726 |
pos = 0; |
| 727 |
if (MPI_Pack(&pli->mode, 1, MPI_LONG_INT, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 728 |
if (MPI_Pack(&pli->Z_setby, 1, MPI_LONG_INT, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 729 |
if (MPI_Pack(&pli->nmodels, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 730 |
if (MPI_Pack(&pli->nseqs, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 731 |
if (MPI_Pack(&pli->nres, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 732 |
if (MPI_Pack(&pli->nnodes, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 733 |
if (MPI_Pack(&pli->n_past_msv, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 734 |
if (MPI_Pack(&pli->n_past_bias, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 735 |
if (MPI_Pack(&pli->n_past_vit, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 736 |
if (MPI_Pack(&pli->n_past_fwd, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 737 |
if (MPI_Pack(&pli->Z, 1, MPI_DOUBLE, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 738 |
|
| 739 |
|
| 740 |
MPI_Send(*buf, n, MPI_PACKED, dest, tag, comm); |
| 741 |
return eslOK; |
| 742 |
|
| 743 |
ERROR: |
| 744 |
return status; |
| 745 |
} |
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
int |
| 771 |
p7_pipeline_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, ESL_GETOPTS *go, P7_PIPELINE **ret_pli) |
| 772 |
{ |
| 773 |
int status; |
| 774 |
P7_PIPELINE *pli = NULL; |
| 775 |
int n; |
| 776 |
int pos; |
| 777 |
MPI_Status mpistatus; |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
MPI_Probe(source, tag, comm, &mpistatus); |
| 782 |
MPI_Get_count(&mpistatus, MPI_PACKED, &n); |
| 783 |
|
| 784 |
|
| 785 |
if (*buf == NULL || n > *nalloc) { |
| 786 |
void *tmp; |
| 787 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 788 |
*nalloc = n; |
| 789 |
} |
| 790 |
|
| 791 |
|
| 792 |
MPI_Recv(*buf, n, MPI_PACKED, source, tag, comm, &mpistatus); |
| 793 |
|
| 794 |
|
| 795 |
pos = 0; |
| 796 |
if ((pli = p7_pipeline_Create(go, 0, 0, FALSE, p7_SEARCH_SEQS)) == NULL) { status = eslEMEM; goto ERROR; } |
| 797 |
if (MPI_Unpack(*buf, n, &pos, &(pli->mode), 1, MPI_LONG_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 798 |
if (MPI_Unpack(*buf, n, &pos, &(pli->Z_setby), 1, MPI_LONG_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 799 |
if (MPI_Unpack(*buf, n, &pos, &(pli->nmodels), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 800 |
if (MPI_Unpack(*buf, n, &pos, &(pli->nseqs), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 801 |
if (MPI_Unpack(*buf, n, &pos, &(pli->nres), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 802 |
if (MPI_Unpack(*buf, n, &pos, &(pli->nnodes), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 803 |
if (MPI_Unpack(*buf, n, &pos, &(pli->n_past_msv), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 804 |
if (MPI_Unpack(*buf, n, &pos, &(pli->n_past_bias), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 805 |
if (MPI_Unpack(*buf, n, &pos, &(pli->n_past_vit), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 806 |
if (MPI_Unpack(*buf, n, &pos, &(pli->n_past_fwd), 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 807 |
if (MPI_Unpack(*buf, n, &pos, &(pli->Z), 1, MPI_DOUBLE, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 808 |
|
| 809 |
*ret_pli = pli; |
| 810 |
return eslOK; |
| 811 |
|
| 812 |
ERROR: |
| 813 |
if (pli != NULL) p7_pipeline_Destroy(pli); |
| 814 |
*ret_pli = NULL; |
| 815 |
return status; |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
int |
| 844 |
p7_tophits_MPISend(P7_TOPHITS *th, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc) |
| 845 |
{ |
| 846 |
int status; |
| 847 |
int sz, n, pos; |
| 848 |
int i, j, inx; |
| 849 |
|
| 850 |
P7_DOMAIN *dcl = NULL; |
| 851 |
P7_HIT *hit = NULL; |
| 852 |
|
| 853 |
n = 0; |
| 854 |
sz = 0; |
| 855 |
|
| 856 |
|
| 857 |
hit = th->unsrt; |
| 858 |
for (i = 0; i < th->N; ++i) { |
| 859 |
for (j = 0; j < th->unsrt[i].ndom; ++j) { |
| 860 |
if (sz <= hit->dcl[j].ad->memsize) { |
| 861 |
sz = hit->dcl[j].ad->memsize; |
| 862 |
dcl = &hit->dcl[j]; |
| 863 |
} |
| 864 |
} |
| 865 |
++hit; |
| 866 |
} |
| 867 |
|
| 868 |
if (th->N > 0) { |
| 869 |
if ((status = p7_hit_MPIPackSize(th->unsrt, comm, &n)) != eslOK) goto ERROR; |
| 870 |
if (dcl != NULL) { |
| 871 |
if ((status = p7_dcl_MPIPackSize(dcl, comm, &sz)) != eslOK) goto ERROR; |
| 872 |
n = (n > sz) ? n : sz; |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
if (MPI_Pack_size(3, MPI_UINT64_T, comm, &sz) != 0) ESL_XEXCEPTION(eslESYS, "pack size failed"); |
| 877 |
n = (n > sz) ? n : sz; |
| 878 |
|
| 879 |
|
| 880 |
if (*buf == NULL || n > *nalloc) { |
| 881 |
void *tmp; |
| 882 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 883 |
*nalloc = n; |
| 884 |
} |
| 885 |
|
| 886 |
pos = 0; |
| 887 |
if (MPI_Pack(&th->N, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 888 |
if (MPI_Pack(&th->nreported, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 889 |
if (MPI_Pack(&th->nincluded, 1, MPI_UINT64_T, *buf, n, &pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 890 |
|
| 891 |
|
| 892 |
if (MPI_Send(*buf, n, MPI_PACKED, dest, tag, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi send failed"); |
| 893 |
if (th->N == 0) return eslOK; |
| 894 |
|
| 895 |
|
| 896 |
hit = th->unsrt; |
| 897 |
for (inx = 0; inx < th->N; ++inx) { |
| 898 |
if ((status = p7_hit_MPISend(hit, dest, tag, comm, buf, nalloc)) != eslOK) goto ERROR; |
| 899 |
++hit; |
| 900 |
} |
| 901 |
|
| 902 |
return eslOK; |
| 903 |
|
| 904 |
ERROR: |
| 905 |
return status; |
| 906 |
} |
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
int |
| 927 |
p7_tophits_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, P7_TOPHITS **ret_th) |
| 928 |
{ |
| 929 |
int n; |
| 930 |
int status; |
| 931 |
int pos; |
| 932 |
P7_TOPHITS *th = NULL; |
| 933 |
P7_HIT *hit = NULL; |
| 934 |
MPI_Status mpistatus; |
| 935 |
|
| 936 |
uint64_t nhits; |
| 937 |
uint64_t inx; |
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
MPI_Probe(source, tag, comm, &mpistatus); |
| 942 |
MPI_Get_count(&mpistatus, MPI_PACKED, &n); |
| 943 |
|
| 944 |
|
| 945 |
if (tag != MPI_ANY_TAG && mpistatus.MPI_TAG != tag) { |
| 946 |
status = eslFAIL; |
| 947 |
goto ERROR; |
| 948 |
} |
| 949 |
if (source != MPI_ANY_SOURCE && mpistatus.MPI_SOURCE != source) { |
| 950 |
status = eslFAIL; |
| 951 |
goto ERROR; |
| 952 |
} |
| 953 |
|
| 954 |
|
| 955 |
tag = mpistatus.MPI_TAG; |
| 956 |
source = mpistatus.MPI_SOURCE; |
| 957 |
|
| 958 |
|
| 959 |
if (*buf == NULL || n > *nalloc) { |
| 960 |
void *tmp; |
| 961 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 962 |
*nalloc = n; |
| 963 |
} |
| 964 |
|
| 965 |
|
| 966 |
MPI_Recv(*buf, n, MPI_PACKED, source, tag, comm, &mpistatus); |
| 967 |
|
| 968 |
|
| 969 |
pos = 0; |
| 970 |
if ((th = p7_tophits_Create()) == NULL) { status = eslEMEM; goto ERROR; } |
| 971 |
if (MPI_Unpack(*buf, n, &pos, &nhits, 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 972 |
if (MPI_Unpack(*buf, n, &pos, &th->nreported, 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 973 |
if (MPI_Unpack(*buf, n, &pos, &th->nincluded, 1, MPI_UINT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "unpack failed"); |
| 974 |
|
| 975 |
|
| 976 |
for (inx = 0; inx < nhits; ++inx) { |
| 977 |
if ((status = p7_tophits_CreateNextHit(th, &hit)) != eslOK) goto ERROR; |
| 978 |
if ((status = p7_hit_MPIRecv(source, tag, comm, buf, nalloc, hit)) != eslOK) goto ERROR; |
| 979 |
} |
| 980 |
*ret_th = th; |
| 981 |
return eslOK; |
| 982 |
|
| 983 |
ERROR: |
| 984 |
if (th != NULL) p7_tophits_Destroy(th); |
| 985 |
*ret_th = NULL; |
| 986 |
return status; |
| 987 |
} |
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
int |
| 993 |
p7_hit_MPISend(P7_HIT *hit, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc) |
| 994 |
{ |
| 995 |
int inx; |
| 996 |
int status; |
| 997 |
int pos; |
| 998 |
int n = *nalloc; |
| 999 |
|
| 1000 |
|
| 1001 |
pos = 0; |
| 1002 |
if ((status = p7_hit_MPIPack(hit, *buf, n, &pos, comm)) != eslOK) goto ERROR; |
| 1003 |
|
| 1004 |
|
| 1005 |
if (MPI_Send(*buf, n, MPI_PACKED, dest, tag, comm) != 0) ESL_EXCEPTION(eslESYS, "mpi send failed"); |
| 1006 |
|
| 1007 |
|
| 1008 |
for (inx = 0; inx < hit->ndom; ++inx) { |
| 1009 |
if ((status = p7_dcl_MPISend(hit->dcl + inx, dest, tag, comm, buf, nalloc)) != eslOK) goto ERROR; |
| 1010 |
} |
| 1011 |
|
| 1012 |
return eslOK; |
| 1013 |
|
| 1014 |
ERROR: |
| 1015 |
return status; |
| 1016 |
} |
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
int |
| 1021 |
p7_hit_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, P7_HIT *hit) |
| 1022 |
{ |
| 1023 |
int n; |
| 1024 |
int status; |
| 1025 |
int pos; |
| 1026 |
int inx; |
| 1027 |
MPI_Status mpistatus; |
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
MPI_Probe(source, tag, comm, &mpistatus); |
| 1032 |
MPI_Get_count(&mpistatus, MPI_PACKED, &n); |
| 1033 |
|
| 1034 |
|
| 1035 |
if (tag != MPI_ANY_TAG && mpistatus.MPI_TAG != tag) { |
| 1036 |
status = eslFAIL; |
| 1037 |
goto ERROR; |
| 1038 |
} |
| 1039 |
if (source != MPI_ANY_SOURCE && mpistatus.MPI_SOURCE != source) { |
| 1040 |
status = eslFAIL; |
| 1041 |
goto ERROR; |
| 1042 |
} |
| 1043 |
|
| 1044 |
|
| 1045 |
tag = mpistatus.MPI_TAG; |
| 1046 |
source = mpistatus.MPI_SOURCE; |
| 1047 |
|
| 1048 |
|
| 1049 |
if (*buf == NULL || n > *nalloc) { |
| 1050 |
void *tmp; |
| 1051 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 1052 |
*nalloc = n; |
| 1053 |
} |
| 1054 |
|
| 1055 |
|
| 1056 |
MPI_Recv(*buf, n, MPI_PACKED, source, tag, comm, &mpistatus); |
| 1057 |
|
| 1058 |
|
| 1059 |
pos = 0; |
| 1060 |
if ((status = p7_hit_MPIUnpack(*buf, n, &pos, comm, hit)) != eslOK) goto ERROR; |
| 1061 |
ESL_ALLOC(hit->dcl, sizeof(P7_DOMAIN) * hit->ndom); |
| 1062 |
|
| 1063 |
|
| 1064 |
for (inx = 0; inx < hit->ndom; ++inx) { |
| 1065 |
if ((status = p7_dcl_MPIRecv(source, tag, comm, buf, nalloc, hit->dcl + inx)) != eslOK) goto ERROR; |
| 1066 |
} |
| 1067 |
return eslOK; |
| 1068 |
|
| 1069 |
ERROR: |
| 1070 |
return status; |
| 1071 |
} |
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
int |
| 1086 |
p7_hit_MPIPackSize(P7_HIT *hit, MPI_Comm comm, int *ret_n) |
| 1087 |
{ |
| 1088 |
int status; |
| 1089 |
int n = 0; |
| 1090 |
int sz; |
| 1091 |
|
| 1092 |
|
| 1093 |
if (MPI_Pack_size(1, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1094 |
if (MPI_Pack_size(1, MPI_DOUBLE, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1095 |
if (MPI_Pack_size(3, MPI_FLOAT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1096 |
if (MPI_Pack_size(3, MPI_DOUBLE, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1097 |
if (MPI_Pack_size(1, MPI_FLOAT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1098 |
if (MPI_Pack_size(5, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1099 |
if (MPI_Pack_size(3, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1100 |
if (MPI_Pack_size(1, MPI_UINT32_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1101 |
if (MPI_Pack_size(2, MPI_INT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1102 |
if ((status = esl_mpi_PackOptSize(hit->name, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n += sz; |
| 1103 |
if ((status = esl_mpi_PackOptSize(hit->acc, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n += sz; |
| 1104 |
if ((status = esl_mpi_PackOptSize(hit->desc, -1, MPI_CHAR, comm, &sz)) != eslOK) goto ERROR; else n += sz; |
| 1105 |
|
| 1106 |
*ret_n = n; |
| 1107 |
return eslOK; |
| 1108 |
|
| 1109 |
ERROR: |
| 1110 |
*ret_n = 0; |
| 1111 |
return status; |
| 1112 |
|
| 1113 |
} |
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
int |
| 1140 |
p7_hit_MPIPack(P7_HIT *hit, char *buf, int n, int *pos, MPI_Comm comm) |
| 1141 |
{ |
| 1142 |
int status; |
| 1143 |
if (MPI_Pack(&hit->window_length, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1144 |
if (MPI_Pack(&hit->sortkey, 1, MPI_DOUBLE, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1145 |
if (MPI_Pack(&hit->score, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1146 |
if (MPI_Pack(&hit->pre_score, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1147 |
if (MPI_Pack(&hit->sum_score, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1148 |
if (MPI_Pack(&hit->lnP, 1, MPI_DOUBLE, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1149 |
if (MPI_Pack(&hit->pre_lnP, 1, MPI_DOUBLE, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1150 |
if (MPI_Pack(&hit->sum_lnP, 1, MPI_DOUBLE, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1151 |
if (MPI_Pack(&hit->nexpected, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1152 |
if (MPI_Pack(&hit->nregions, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1153 |
if (MPI_Pack(&hit->nclustered, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1154 |
if (MPI_Pack(&hit->noverlaps, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1155 |
if (MPI_Pack(&hit->nenvelopes, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1156 |
if (MPI_Pack(&hit->ndom, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1157 |
if (MPI_Pack(&hit->flags, 1, MPI_UINT32_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1158 |
if (MPI_Pack(&hit->nreported, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1159 |
if (MPI_Pack(&hit->nincluded, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1160 |
if (MPI_Pack(&hit->best_domain, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1161 |
if (MPI_Pack(&hit->seqidx, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1162 |
if (MPI_Pack(&hit->subseq_start, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1163 |
|
| 1164 |
if ((status = esl_mpi_PackOpt(hit->name, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 1165 |
if ((status = esl_mpi_PackOpt(hit->acc, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 1166 |
if ((status = esl_mpi_PackOpt(hit->desc, -1, MPI_CHAR, buf, n, pos, comm)) != eslOK) return status; |
| 1167 |
|
| 1168 |
if (*pos > n) ESL_EXCEPTION(eslEMEM, "buffer overflow"); |
| 1169 |
return eslOK; |
| 1170 |
|
| 1171 |
ERROR: |
| 1172 |
return status; |
| 1173 |
} |
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
int |
| 1192 |
p7_hit_MPIUnpack(char *buf, int n, int *pos, MPI_Comm comm, P7_HIT *hit) |
| 1193 |
{ |
| 1194 |
int status; |
| 1195 |
|
| 1196 |
if (MPI_Unpack(buf, n, pos, &hit->window_length, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1197 |
if (MPI_Unpack(buf, n, pos, &hit->sortkey, 1, MPI_DOUBLE, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1198 |
if (MPI_Unpack(buf, n, pos, &hit->score, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1199 |
if (MPI_Unpack(buf, n, pos, &hit->pre_score, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1200 |
if (MPI_Unpack(buf, n, pos, &hit->sum_score, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1201 |
if (MPI_Unpack(buf, n, pos, &hit->lnP, 1, MPI_DOUBLE, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1202 |
if (MPI_Unpack(buf, n, pos, &hit->pre_lnP, 1, MPI_DOUBLE, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1203 |
if (MPI_Unpack(buf, n, pos, &hit->sum_lnP, 1, MPI_DOUBLE, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1204 |
if (MPI_Unpack(buf, n, pos, &hit->nexpected, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1205 |
if (MPI_Unpack(buf, n, pos, &hit->nregions, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1206 |
if (MPI_Unpack(buf, n, pos, &hit->nclustered, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1207 |
if (MPI_Unpack(buf, n, pos, &hit->noverlaps, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1208 |
if (MPI_Unpack(buf, n, pos, &hit->nenvelopes, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1209 |
if (MPI_Unpack(buf, n, pos, &hit->ndom, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1210 |
if (MPI_Unpack(buf, n, pos, &hit->flags, 1, MPI_UINT32_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1211 |
if (MPI_Unpack(buf, n, pos, &hit->nreported, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1212 |
if (MPI_Unpack(buf, n, pos, &hit->nincluded, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1213 |
if (MPI_Unpack(buf, n, pos, &hit->best_domain, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1214 |
if (MPI_Unpack(buf, n, pos, &hit->seqidx, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1215 |
if (MPI_Unpack(buf, n, pos, &hit->subseq_start, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1216 |
hit->offset = 0; |
| 1217 |
|
| 1218 |
|
| 1219 |
if ((status = esl_mpi_UnpackOpt(buf, n, pos, (void**)&(hit->name), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 1220 |
if ((status = esl_mpi_UnpackOpt(buf, n, pos, (void**)&(hit->acc), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 1221 |
if ((status = esl_mpi_UnpackOpt(buf, n, pos, (void**)&(hit->desc), NULL, MPI_CHAR, comm)) != eslOK) goto ERROR; |
| 1222 |
|
| 1223 |
return eslOK; |
| 1224 |
|
| 1225 |
ERROR: |
| 1226 |
return status; |
| 1227 |
} |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
int |
| 1232 |
p7_dcl_MPISend(P7_DOMAIN *dcl, int dest, int tag, MPI_Comm comm, char **buf, int *nalloc) |
| 1233 |
{ |
| 1234 |
int status; |
| 1235 |
int pos; |
| 1236 |
int n = *nalloc; |
| 1237 |
|
| 1238 |
|
| 1239 |
pos = 0; |
| 1240 |
if ((status = p7_dcl_MPIPack(dcl, *buf, n, &pos, comm)) != eslOK) goto ERROR; |
| 1241 |
|
| 1242 |
|
| 1243 |
if (MPI_Send(*buf, n, MPI_PACKED, dest, tag, comm) != 0) ESL_EXCEPTION(eslESYS, "mpi send failed"); |
| 1244 |
|
| 1245 |
return eslOK; |
| 1246 |
|
| 1247 |
ERROR: |
| 1248 |
return status; |
| 1249 |
} |
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
int |
| 1255 |
p7_dcl_MPIPackSize(P7_DOMAIN *dcl, MPI_Comm comm, int *ret_n) |
| 1256 |
{ |
| 1257 |
int status; |
| 1258 |
int n = 0; |
| 1259 |
int sz; |
| 1260 |
|
| 1261 |
P7_ALIDISPLAY *ad = dcl->ad; |
| 1262 |
|
| 1263 |
|
| 1264 |
if (MPI_Pack_size(6, MPI_INT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1265 |
if (MPI_Pack_size(5, MPI_FLOAT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1266 |
if (MPI_Pack_size(1, MPI_DOUBLE, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1267 |
if (MPI_Pack_size(2, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1268 |
if(dcl->scores_per_pos != NULL){p7_Fail("Non-NULL scores_per_pos field found int p7_dcl_MPIPackSize. Sending the scores_per_pos field via MPI has not been implemented\n");} |
| 1269 |
|
| 1270 |
|
| 1271 |
if (MPI_Pack_size(18, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1272 |
if (MPI_Pack_size(3, MPI_INT64_T, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1273 |
if (MPI_Pack_size(1, MPI_INT, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1274 |
if (MPI_Pack_size(ad->memsize, MPI_CHAR, comm, &sz) != 0) { ESL_XEXCEPTION(eslESYS, "pack size failed"); } n += sz; |
| 1275 |
|
| 1276 |
*ret_n = n; |
| 1277 |
return eslOK; |
| 1278 |
|
| 1279 |
ERROR: |
| 1280 |
*ret_n = 0; |
| 1281 |
return status; |
| 1282 |
|
| 1283 |
} |
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
int |
| 1288 |
p7_dcl_MPIPack(P7_DOMAIN *dcl, char *buf, int n, int *pos, MPI_Comm comm) |
| 1289 |
{ |
| 1290 |
int status; |
| 1291 |
int offset; |
| 1292 |
|
| 1293 |
P7_ALIDISPLAY *ad = dcl->ad; |
| 1294 |
|
| 1295 |
if (MPI_Pack(&dcl->ienv, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1296 |
if (MPI_Pack(&dcl->jenv, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1297 |
if (MPI_Pack(&dcl->iali, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1298 |
if (MPI_Pack(&dcl->jali, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1299 |
if (MPI_Pack(&dcl->iorf, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1300 |
if (MPI_Pack(&dcl->jorf, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1301 |
if (MPI_Pack(&dcl->envsc, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1302 |
if (MPI_Pack(&dcl->domcorrection, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1303 |
if (MPI_Pack(&dcl->dombias, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1304 |
if (MPI_Pack(&dcl->oasc, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1305 |
if (MPI_Pack(&dcl->bitscore, 1, MPI_FLOAT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1306 |
if (MPI_Pack(&dcl->lnP, 1, MPI_DOUBLE, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1307 |
if (MPI_Pack(&dcl->is_reported, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1308 |
if (MPI_Pack(&dcl->is_included, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1309 |
if(dcl->scores_per_pos != NULL){p7_Fail("Non-NULL scores_per_pos field found int p7_dcl_MPIPack. Sending the scores_per_pos field via MPI has not been implemented\n");} |
| 1310 |
|
| 1311 |
offset = (ad->rfline == NULL) ? -1 : ad->rfline - ad->mem; |
| 1312 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1313 |
offset = (ad->mmline == NULL) ? -1 : ad->mmline - ad->mem; |
| 1314 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1315 |
offset = (ad->csline == NULL) ? -1 : ad->csline - ad->mem; |
| 1316 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1317 |
offset = (ad->model == NULL) ? -1 : ad->model - ad->mem; |
| 1318 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1319 |
offset = (ad->mline == NULL) ? -1 : ad->mline - ad->mem; |
| 1320 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1321 |
offset = (ad->aseq == NULL) ? -1 : ad->aseq - ad->mem; |
| 1322 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1323 |
offset = (ad->ntseq == NULL) ? -1 : ad->ntseq - ad->mem; |
| 1324 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1325 |
offset = (ad->ppline == NULL) ? -1 : ad->ppline - ad->mem; |
| 1326 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1327 |
if (MPI_Pack(&ad->N, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1328 |
offset = (ad->hmmname == NULL) ? -1 : ad->hmmname - ad->mem; |
| 1329 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1330 |
offset = (ad->hmmacc == NULL) ? -1 : ad->hmmacc - ad->mem; |
| 1331 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1332 |
offset = (ad->hmmdesc == NULL) ? -1 : ad->hmmdesc - ad->mem; |
| 1333 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1334 |
if (MPI_Pack(&ad->hmmfrom, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1335 |
if (MPI_Pack(&ad->hmmto, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1336 |
if (MPI_Pack(&ad->M, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1337 |
offset = (ad->sqname == NULL) ? -1 : ad->sqname - ad->mem; |
| 1338 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1339 |
offset = (ad->sqacc == NULL) ? -1 : ad->sqacc - ad->mem; |
| 1340 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1341 |
offset = (ad->sqdesc == NULL) ? -1 : ad->sqdesc - ad->mem; |
| 1342 |
if (MPI_Pack(&offset, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1343 |
if (MPI_Pack(&ad->sqfrom, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1344 |
if (MPI_Pack(&ad->sqto, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1345 |
if (MPI_Pack(&ad->L, 1, MPI_INT64_T, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1346 |
if (MPI_Pack(&ad->memsize, 1, MPI_INT, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1347 |
if (MPI_Pack( ad->mem, ad->memsize, MPI_CHAR, buf, n, pos, comm) != 0) ESL_XEXCEPTION(eslESYS, "pack failed"); |
| 1348 |
|
| 1349 |
if (*pos > n) ESL_EXCEPTION(eslEMEM, "buffer overflow"); |
| 1350 |
return eslOK; |
| 1351 |
|
| 1352 |
ERROR: |
| 1353 |
return status; |
| 1354 |
} |
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
int |
| 1359 |
p7_dcl_MPIUnpack(char *buf, int n, int *pos, MPI_Comm comm, P7_DOMAIN *dcl) |
| 1360 |
{ |
| 1361 |
int status; |
| 1362 |
int rfline, mmline, csline, model, mline, aseq, ntseq, ppline; |
| 1363 |
int hmmname, hmmacc, hmmdesc; |
| 1364 |
int sqname, sqacc, sqdesc; |
| 1365 |
|
| 1366 |
P7_ALIDISPLAY *ad; |
| 1367 |
|
| 1368 |
ESL_ALLOC(ad, sizeof(P7_ALIDISPLAY)); |
| 1369 |
|
| 1370 |
if (MPI_Unpack(buf, n, pos, &dcl->ienv, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1371 |
if (MPI_Unpack(buf, n, pos, &dcl->jenv, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1372 |
if (MPI_Unpack(buf, n, pos, &dcl->iali, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1373 |
if (MPI_Unpack(buf, n, pos, &dcl->jali, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1374 |
if (MPI_Unpack(buf, n, pos, &dcl->iorf, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1375 |
if (MPI_Unpack(buf, n, pos, &dcl->jorf, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1376 |
if (MPI_Unpack(buf, n, pos, &dcl->envsc, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1377 |
if (MPI_Unpack(buf, n, pos, &dcl->domcorrection, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1378 |
if (MPI_Unpack(buf, n, pos, &dcl->dombias, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1379 |
if (MPI_Unpack(buf, n, pos, &dcl->oasc, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1380 |
if (MPI_Unpack(buf, n, pos, &dcl->bitscore, 1, MPI_FLOAT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1381 |
if (MPI_Unpack(buf, n, pos, &dcl->lnP, 1, MPI_DOUBLE, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1382 |
if (MPI_Unpack(buf, n, pos, &dcl->is_reported, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1383 |
if (MPI_Unpack(buf, n, pos, &dcl->is_included, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1384 |
dcl->scores_per_pos =NULL; |
| 1385 |
|
| 1386 |
if (MPI_Unpack(buf, n, pos, &rfline, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1387 |
if (MPI_Unpack(buf, n, pos, &mmline, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1388 |
if (MPI_Unpack(buf, n, pos, &csline, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1389 |
if (MPI_Unpack(buf, n, pos, &model, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1390 |
if (MPI_Unpack(buf, n, pos, &mline, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1391 |
if (MPI_Unpack(buf, n, pos, &aseq, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1392 |
if (MPI_Unpack(buf, n, pos, &ntseq, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1393 |
if (MPI_Unpack(buf, n, pos, &ppline, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1394 |
if (MPI_Unpack(buf, n, pos, &ad->N, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1395 |
if (MPI_Unpack(buf, n, pos, &hmmname, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1396 |
if (MPI_Unpack(buf, n, pos, &hmmacc, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1397 |
if (MPI_Unpack(buf, n, pos, &hmmdesc, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1398 |
if (MPI_Unpack(buf, n, pos, &ad->hmmfrom, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1399 |
if (MPI_Unpack(buf, n, pos, &ad->hmmto, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1400 |
if (MPI_Unpack(buf, n, pos, &ad->M, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1401 |
if (MPI_Unpack(buf, n, pos, &sqname, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1402 |
if (MPI_Unpack(buf, n, pos, &sqacc, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1403 |
if (MPI_Unpack(buf, n, pos, &sqdesc, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1404 |
if (MPI_Unpack(buf, n, pos, &ad->sqfrom, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1405 |
if (MPI_Unpack(buf, n, pos, &ad->sqto, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1406 |
if (MPI_Unpack(buf, n, pos, &ad->L, 1, MPI_INT64_T, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1407 |
if (MPI_Unpack(buf, n, pos, &ad->memsize, 1, MPI_INT, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1408 |
|
| 1409 |
dcl->scores_per_pos = NULL; |
| 1410 |
|
| 1411 |
|
| 1412 |
ESL_ALLOC(ad->mem, ad->memsize); |
| 1413 |
if (MPI_Unpack(buf, n, pos, ad->mem, ad->memsize, MPI_CHAR, comm) != 0) ESL_XEXCEPTION(eslESYS, "mpi unpack failed"); |
| 1414 |
|
| 1415 |
ad->rfline = (rfline == -1) ? NULL : ad->mem + rfline; |
| 1416 |
ad->mmline = (mmline == -1) ? NULL : ad->mem + mmline; |
| 1417 |
ad->csline = (csline == -1) ? NULL : ad->mem + csline; |
| 1418 |
ad->model = (model == -1) ? NULL : ad->mem + model; |
| 1419 |
ad->mline = (mline == -1) ? NULL : ad->mem + mline; |
| 1420 |
ad->aseq = (aseq == -1) ? NULL : ad->mem + aseq; |
| 1421 |
ad->ntseq = (ntseq == -1) ? NULL : ad->mem + ntseq; |
| 1422 |
ad->ppline = (ppline == -1) ? NULL : ad->mem + ppline; |
| 1423 |
|
| 1424 |
ad->hmmname = (hmmname == -1) ? NULL : ad->mem + hmmname; |
| 1425 |
ad->hmmacc = (hmmacc == -1) ? NULL : ad->mem + hmmacc; |
| 1426 |
ad->hmmdesc = (hmmdesc == -1) ? NULL : ad->mem + hmmdesc; |
| 1427 |
|
| 1428 |
ad->sqname = (sqname == -1) ? NULL : ad->mem + sqname; |
| 1429 |
ad->sqacc = (sqacc == -1) ? NULL : ad->mem + sqacc; |
| 1430 |
ad->sqdesc = (sqdesc == -1) ? NULL : ad->mem + sqdesc; |
| 1431 |
|
| 1432 |
dcl->ad = ad; |
| 1433 |
|
| 1434 |
return eslOK; |
| 1435 |
|
| 1436 |
ERROR: |
| 1437 |
if (ad != NULL) { |
| 1438 |
if (ad->mem != NULL) free(ad->mem); |
| 1439 |
free(ad); |
| 1440 |
} |
| 1441 |
return status; |
| 1442 |
} |
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
int |
| 1447 |
p7_dcl_MPIRecv(int source, int tag, MPI_Comm comm, char **buf, int *nalloc, P7_DOMAIN *dcl) |
| 1448 |
{ |
| 1449 |
int status; |
| 1450 |
int n; |
| 1451 |
int pos; |
| 1452 |
MPI_Status mpistatus; |
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
MPI_Probe(source, tag, comm, &mpistatus); |
| 1457 |
MPI_Get_count(&mpistatus, MPI_PACKED, &n); |
| 1458 |
|
| 1459 |
|
| 1460 |
if (tag != MPI_ANY_TAG && mpistatus.MPI_TAG != tag) { |
| 1461 |
status = eslFAIL; |
| 1462 |
goto ERROR; |
| 1463 |
} |
| 1464 |
if (source != MPI_ANY_SOURCE && mpistatus.MPI_SOURCE != source) { |
| 1465 |
status = eslFAIL; |
| 1466 |
goto ERROR; |
| 1467 |
} |
| 1468 |
|
| 1469 |
|
| 1470 |
tag = mpistatus.MPI_TAG; |
| 1471 |
source = mpistatus.MPI_SOURCE; |
| 1472 |
|
| 1473 |
|
| 1474 |
if (*buf == NULL || n > *nalloc) { |
| 1475 |
void *tmp; |
| 1476 |
ESL_RALLOC(*buf, tmp, sizeof(char) * n); |
| 1477 |
*nalloc = n; |
| 1478 |
} |
| 1479 |
|
| 1480 |
|
| 1481 |
MPI_Recv(*buf, n, MPI_PACKED, source, tag, comm, &mpistatus); |
| 1482 |
|
| 1483 |
|
| 1484 |
pos = 0; |
| 1485 |
return p7_dcl_MPIUnpack(*buf, *nalloc, &pos, comm, dcl); |
| 1486 |
|
| 1487 |
ERROR: |
| 1488 |
return status; |
| 1489 |
} |
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
#ifdef p7MPISUPPORT_BENCHMARK |
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
#include <p7_config.h> |
| 1505 |
|
| 1506 |
#include <string.h> |
| 1507 |
#include <math.h> |
| 1508 |
|
| 1509 |
#include "easel.h" |
| 1510 |
#include "esl_getopts.h" |
| 1511 |
#include "esl_alphabet.h" |
| 1512 |
#include "esl_random.h" |
| 1513 |
#include "esl_stopwatch.h" |
| 1514 |
|
| 1515 |
#include "hmmer.h" |
| 1516 |
|
| 1517 |
static ESL_OPTIONS options[] = { |
| 1518 |
|
| 1519 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 1520 |
{ "-b", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "baseline timing: don't send any HMMs", 0 }, |
| 1521 |
{ "--stall", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "arrest after start: for debugging MPI under gdb", 0 }, |
| 1522 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1523 |
}; |
| 1524 |
static char usage[] = "[-options] <hmmfile>"; |
| 1525 |
static char banner[] = "benchmark driver for MPI communication"; |
| 1526 |
|
| 1527 |
int |
| 1528 |
main(int argc, char **argv) |
| 1529 |
{ |
| 1530 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 1, argc, argv, banner, usage); |
| 1531 |
char *hmmfile = esl_opt_GetArg(go, 1); |
| 1532 |
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO); |
| 1533 |
P7_BG *bg = p7_bg_Create(abc); |
| 1534 |
int my_rank; |
| 1535 |
int nproc; |
| 1536 |
char *buf = NULL; |
| 1537 |
int nbuf = 0; |
| 1538 |
int subtotalM = 0; |
| 1539 |
int allM = 0; |
| 1540 |
int stalling = esl_opt_GetBoolean(go, "--stall"); |
| 1541 |
|
| 1542 |
MPI_Init(&argc, &argv); |
| 1543 |
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); |
| 1544 |
MPI_Comm_size(MPI_COMM_WORLD, &nproc); |
| 1545 |
|
| 1546 |
while (stalling); |
| 1547 |
|
| 1548 |
|
| 1549 |
if (my_rank == 0) |
| 1550 |
{ |
| 1551 |
ESL_STOPWATCH *w = esl_stopwatch_Create(); |
| 1552 |
P7_HMMFILE *hfp = NULL; |
| 1553 |
P7_PROFILE *gm = NULL; |
| 1554 |
P7_HMM *hmm = NULL; |
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
if (p7_hmmfile_Open(hmmfile, NULL, &hfp, NULL) != eslOK) p7_Fail("Failed to open HMM file %s", hmmfile); |
| 1559 |
|
| 1560 |
esl_stopwatch_Start(w); |
| 1561 |
while (p7_hmmfile_Read(hfp, &abc, &hmm) == eslOK) |
| 1562 |
{ |
| 1563 |
gm = p7_profile_Create(hmm->M, abc); |
| 1564 |
p7_ProfileConfig(hmm, bg, gm, 400, p7_LOCAL); |
| 1565 |
if (!esl_opt_GetBoolean(go, "-b")) |
| 1566 |
p7_profile_MPISend(gm, 1, 0, MPI_COMM_WORLD, &buf, &nbuf); |
| 1567 |
|
| 1568 |
p7_hmm_Destroy(hmm); |
| 1569 |
p7_profile_Destroy(gm); |
| 1570 |
} |
| 1571 |
p7_profile_MPISend(NULL, 1, 0, MPI_COMM_WORLD, &buf, &nbuf); |
| 1572 |
MPI_Reduce(&subtotalM, &allM, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); |
| 1573 |
|
| 1574 |
printf("total: %d\n", allM); |
| 1575 |
esl_stopwatch_Stop(w); |
| 1576 |
esl_stopwatch_Display(stdout, w, "CPU Time: "); |
| 1577 |
esl_stopwatch_Destroy(w); |
| 1578 |
} |
| 1579 |
|
| 1580 |
else |
| 1581 |
{ |
| 1582 |
P7_PROFILE *gm_recd = NULL; |
| 1583 |
|
| 1584 |
while (p7_profile_MPIRecv(0, 0, MPI_COMM_WORLD, abc, bg, &buf, &nbuf, &gm_recd) == eslOK) |
| 1585 |
{ |
| 1586 |
subtotalM += gm_recd->M; |
| 1587 |
p7_profile_Destroy(gm_recd); |
| 1588 |
} |
| 1589 |
MPI_Reduce(&subtotalM, &allM, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); |
| 1590 |
} |
| 1591 |
|
| 1592 |
free(buf); |
| 1593 |
p7_bg_Destroy(bg); |
| 1594 |
esl_alphabet_Destroy(abc); |
| 1595 |
esl_getopts_Destroy(go); |
| 1596 |
MPI_Finalize(); |
| 1597 |
exit(0); |
| 1598 |
} |
| 1599 |
|
| 1600 |
#endif |
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
#ifdef p7MPISUPPORT_TESTDRIVE |
| 1608 |
|
| 1609 |
static void |
| 1610 |
utest_HMMSendRecv(int my_rank, int nproc) |
| 1611 |
{ |
| 1612 |
ESL_RANDOMNESS *r = esl_randomness_CreateFast(42); |
| 1613 |
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO); |
| 1614 |
P7_HMM *hmm = NULL; |
| 1615 |
P7_HMM *xhmm = NULL; |
| 1616 |
int M = 200; |
| 1617 |
char *wbuf = NULL; |
| 1618 |
int wn = 0; |
| 1619 |
int i; |
| 1620 |
char errmsg[eslERRBUFSIZE]; |
| 1621 |
|
| 1622 |
p7_hmm_Sample(r, M, abc, &hmm); |
| 1623 |
|
| 1624 |
if (my_rank == 0) |
| 1625 |
{ |
| 1626 |
for (i = 1; i < nproc; i++) |
| 1627 |
{ |
| 1628 |
ESL_DPRINTF1(("Master: receiving test HMM\n")); |
| 1629 |
p7_hmm_MPIRecv(MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &wbuf, &wn, &abc, &xhmm); |
| 1630 |
ESL_DPRINTF1(("Master: test HMM received\n")); |
| 1631 |
|
| 1632 |
if (p7_hmm_Validate(xhmm, errmsg, 0.001) != eslOK) p7_Die("hmm validation failed: %s", errmsg); |
| 1633 |
if (p7_hmm_Compare(hmm, xhmm, 0.001) != eslOK) p7_Die("Received HMM not identical to what was sent"); |
| 1634 |
|
| 1635 |
p7_hmm_Destroy(xhmm); |
| 1636 |
} |
| 1637 |
} |
| 1638 |
else |
| 1639 |
{ |
| 1640 |
ESL_DPRINTF1(("Worker %d: sending test HMM\n", my_rank)); |
| 1641 |
p7_hmm_MPISend(hmm, 0, 0, MPI_COMM_WORLD, &wbuf, &wn); |
| 1642 |
ESL_DPRINTF1(("Worker %d: test HMM sent\n", my_rank)); |
| 1643 |
} |
| 1644 |
|
| 1645 |
p7_hmm_Destroy(hmm); |
| 1646 |
esl_alphabet_Destroy(abc); |
| 1647 |
esl_randomness_Destroy(r); |
| 1648 |
free(wbuf); |
| 1649 |
return; |
| 1650 |
} |
| 1651 |
|
| 1652 |
static void |
| 1653 |
utest_ProfileSendRecv(int my_rank, int nproc) |
| 1654 |
{ |
| 1655 |
ESL_RANDOMNESS *r = esl_randomness_CreateFast(42); |
| 1656 |
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO); |
| 1657 |
P7_HMM *hmm = NULL; |
| 1658 |
P7_BG *bg = NULL; |
| 1659 |
P7_PROFILE *gm = NULL; |
| 1660 |
P7_PROFILE *gm2 = NULL; |
| 1661 |
int M = 200; |
| 1662 |
int L = 400; |
| 1663 |
char *wbuf = NULL; |
| 1664 |
int wn = 0; |
| 1665 |
int i; |
| 1666 |
char errbuf[eslERRBUFSIZE]; |
| 1667 |
|
| 1668 |
p7_hmm_Sample(r, M, abc, &hmm); |
| 1669 |
bg = p7_bg_Create(abc); |
| 1670 |
gm = p7_profile_Create(hmm->M, abc); |
| 1671 |
p7_ProfileConfig(hmm, bg, gm, L, p7_LOCAL); |
| 1672 |
p7_bg_SetLength (bg, L); |
| 1673 |
|
| 1674 |
if (my_rank == 0) |
| 1675 |
{ |
| 1676 |
for (i = 1; i < nproc; i++) |
| 1677 |
{ |
| 1678 |
ESL_DPRINTF1(("Master: receiving test profile\n")); |
| 1679 |
p7_profile_MPIRecv(MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, abc, bg, &wbuf, &wn, &gm2); |
| 1680 |
ESL_DPRINTF1(("Master: test profile received\n")); |
| 1681 |
|
| 1682 |
if (p7_profile_Validate(gm2, errbuf, 0.001) != eslOK) p7_Die("profile validation failed: %s", errbuf); |
| 1683 |
if (p7_profile_Compare(gm, gm2, 0.001) != eslOK) p7_Die("Received profile not identical to what was sent"); |
| 1684 |
|
| 1685 |
p7_profile_Destroy(gm2); |
| 1686 |
} |
| 1687 |
} |
| 1688 |
else |
| 1689 |
{ |
| 1690 |
ESL_DPRINTF1(("Worker %d: sending test profile\n", my_rank)); |
| 1691 |
p7_profile_MPISend(gm, 0, 0, MPI_COMM_WORLD, &wbuf, &wn); |
| 1692 |
ESL_DPRINTF1(("Worker %d: test profile sent\n", my_rank)); |
| 1693 |
} |
| 1694 |
|
| 1695 |
free(wbuf); |
| 1696 |
p7_profile_Destroy(gm); |
| 1697 |
p7_bg_Destroy(bg); |
| 1698 |
p7_hmm_Destroy(hmm); |
| 1699 |
esl_alphabet_Destroy(abc); |
| 1700 |
esl_randomness_Destroy(r); |
| 1701 |
return; |
| 1702 |
} |
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
#endif |
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
#ifdef p7MPISUPPORT_TESTDRIVE |
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
#include "esl_getopts.h" |
| 1720 |
|
| 1721 |
static ESL_OPTIONS options[] = { |
| 1722 |
|
| 1723 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 1724 |
{ "--stall", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "arrest after start: for debugging MPI under gdb", 0 }, |
| 1725 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 1726 |
}; |
| 1727 |
static char usage[] = "[-options]"; |
| 1728 |
static char banner[] = "test driver for mpisupport.c"; |
| 1729 |
|
| 1730 |
int |
| 1731 |
main(int argc, char **argv) |
| 1732 |
{ |
| 1733 |
ESL_GETOPTS *go = p7_CreateDefaultApp(options, 0, argc, argv, banner, usage); |
| 1734 |
int stalling = FALSE; |
| 1735 |
int my_rank; |
| 1736 |
int nproc; |
| 1737 |
|
| 1738 |
|
| 1739 |
if (esl_opt_GetBoolean(go, "--stall")) stalling = TRUE; |
| 1740 |
while (stalling); |
| 1741 |
|
| 1742 |
MPI_Init(&argc, &argv); |
| 1743 |
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); |
| 1744 |
MPI_Comm_size(MPI_COMM_WORLD, &nproc); |
| 1745 |
|
| 1746 |
utest_HMMSendRecv(my_rank, nproc); |
| 1747 |
utest_ProfileSendRecv(my_rank, nproc); |
| 1748 |
|
| 1749 |
MPI_Finalize(); |
| 1750 |
return 0; |
| 1751 |
} |
| 1752 |
|
| 1753 |
#endif |
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
#else |
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
void p7_mpisupport_DoAbsolutelyNothing(void) { return; } |
| 1765 |
#if defined p7MPISUPPORT_TESTDRIVE || p7MPISUPPORT_EXAMPLE || p7MPISUPPORT_BENCHMARK |
| 1766 |
int main(void) { return 0; } |
| 1767 |
#endif |
| 1768 |
#endif |
| 1769 |
|
| 1770 |
|
| 1771 |
|