⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comm_seq.c

📁 fastDNAml is an attempt to solve the same problem as DNAML, but to do so faster and using less memo
💻 C
字号:
#include  <stdlib.h>#include  <stdio.h>#include  <string.h>#include  <sys/types.h>#include  <sys/times.h>#include  <time.h>#include  "fastDNAml_types.h"#include  "fastDNAml_funcs.h"#include  "fastDNAml_globals.h"extern int  monitor_id;extern int  foreman_id;extern int  master_id;extern int  first_worker_id;extern FILE  *outfp;int         seq_err;int         source;int         tag;int         myrank;stat_data   stats;FILE        *logfp;int         nextsp;int         dnaml_cur, dnaml_ln;double      step_time;double      twc;char        buf[2048];char        filename[2048] = "";/******************************************************************************* *//* Initialize the sequential fastDNAml. */void process_init(int argc, char **argv, proc_data *pp){ /* process_init */  int  *prog;  pp->stats.tstart = pp->stats.t0 = dwalltime00();  gethostname(pp->hostname,HOST_NAME_LEN);  pp->progtype = myprogtype;  pp->tid = 0;  if(!get_args(argc,argv,(boolean)1))   bail(argv[0],99);  nworkers = 1;  monitor_id = master_id = 0;/* Resolve working directory path. Quit if there is an error. */  if( realpath(workdir,buf) == NULL ) {    fprintf(stderr,"%s: Bad path name: %s\n",argv[0],workdir);    bail(argv[0],99);  }  strcpy(workdir,buf);  strcat(workdir,"/");/* Open a monitor log file. */  make_filename(filename,workdir,run_id,".log",0);  if((logfp = fopen(filename,"w")) == NULL) {    bail(argv[0],ERR_LOGFILE);  }  fprintf(logfp, "Number of workers = %d\n", nworkers);  dnaml_ln = dnaml_cur = 1;  return;} /* process_init *//* Finialize and exit. */void bail(char *source, int err_code){ /* bail */  switch(err_code) {    case 0:      break;    case ERR_SEQDATA:       fprintf(stderr,"%s: cannot get sequence data\n",source);      break;    case ERR_OUTFILE:      fprintf(stderr, "%s: cannot open output file\n",source);      break;    case ERR_LOGFILE:      fprintf(stderr,"%s: cannot open log file\n",source);      break;    case ERR_DEBUGFILE:      fprintf(stderr,"%s: cannot open debug file\n",source);      break;    default:      fprintf(stderr,"%s: error code %d\n",source,err_code);  }  exit(err_code);} /* bail */void iprobe_msg(int *from, int *type) {  *type = DNAML_WORKER_READY;  /* needed to satisfy master on startup */  return;}void send_msg(void *buf, int size, int dest, int type){ /* send_msg */  char        c;  stat_data   *sd;  double      ustime;  stat_data   *xstat;  static int  dnaml_cur=1;  static int  dnaml_ln=1;  switch(type) {    case DNAML_DONE:      sd = (stat_data*)buf;      fprintf(stderr,"\n");      ustime = sd->utime + sd->stime;      twc = sd->t1 - sd->tstart;      fprintf(stderr,"-%8.8x:  u=%10.2f  s=%10.2f  u+s=%10.2f  wallclock=%10.2f\n",          dest, sd->utime, sd->stime, ustime, twc);      fprintf(logfp, "-%8.8x:  u=%10.2f  s=%10.2f  u+s=%10.2f  wallclock=%10.2f\n",          dest, sd->utime, sd->stime, ustime, twc);      fclose(logfp);      break;    case DNAML_ADD_SPECS:      dnaml_ln = dnaml_cur = 1;      fprintf(stderr, "\n%4d (%5d) ", nextsp++, DNAML_CHAR_COUNT*(dnaml_ln-1));      break;    case DNAML_SEND_TREE:      if(infol>3) {        fputc('+',stderr);        dnaml_cur++;      }      break;    case DNAML_RECV_TREE:      if(infol>3) {        fputc('-',stderr);        dnaml_cur++;      }      break;    case DNAML_QUIT:      break;    case DNAML_INPUT_TIME:      sd = buf;      sd->t1 = sd->tinput = dwalltime00();      step_time  = sd->tinput - sd->t0;      twc = sd->t1 - sd->tstart;      sd->t0 = sd->t1;      fprintf(logfp,  "file input : %8.3f  %11.3f sec\n", step_time, twc);      fflush(logfp);      fprintf(stderr, "file input : %8.3f  %11.3f sec\n", step_time, twc);      if(infol>2) {        fprintf(stderr, "   1\n   2\n   3 (%5d) ", DNAML_CHAR_COUNT*(dnaml_ln-1));      }      nextsp = 4;      break;    case DNAML_STEP_TIME:      sd = buf;      sd->t1 = dwalltime00();      step_time  = sd->t1 - sd->t0;      twc = sd->t1 - sd->tstart;      sd->t0 = sd->t1;      fprintf(logfp, "~%4d Specs: %8.3f  %11.3f sec\n", nextsp-1,step_time,twc);      fflush(logfp);      fprintf(stderr, "\n%4d Step time = %8.3f ", nextsp-1,step_time);      fprintf(stderr, "#### Total time = %11.3f seconds", twc);      break;    case DNAML_TID_LIST:    default:      break;  }    if (dnaml_cur % (DNAML_CHAR_COUNT + 1) == 0) {    dnaml_ln++;    dnaml_cur = 1;    fprintf(stderr, "\n     (%5d) ", DNAML_CHAR_COUNT*(dnaml_ln-1));  }} /* send_msg */void recv_msg(void *buf, int size, int from, int type){ /* recv_msg */} /* recv_msg */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -