Пример #1
0
static void handle_align(char *s)
{
  taddr a = parse_constexpr(&s);

  if (a > 63)
    syntax_error(21);  /* bad alignment */
  do_alignment(1LL<<a,number_expr(0));
  eol(s);
}
Пример #2
0
static void handle_even(char *s)
{
  do_alignment(2,number_expr(0));
  eol(s);
}
Пример #3
0
static void handle_qphrase(char *s)
{
  do_alignment(32,number_expr(0),1,NULL);
  eol(s);
}
Пример #4
0
static void handle_long(char *s)
{
  do_alignment(4,number_expr(0),1,NULL);
  eol(s);
}
Пример #5
0
int main (int argc, const char * argv[]) {
    
    // get start time
    double t = gettime();
    
    // Display each command-line argument.
    // show_args(argc, argv);
    if (argc <= 1) {
        fprintf(stderr, "sw <seqfile> [threads]\n");
        exit(1);
    }

    // get number of threads (default is 1)
    // and set that number for OpenMP
    int num_threads = 1;
    if (argc == 3) {
        num_threads = atoi(argv[2]);
    }
    omp_set_num_threads(num_threads);
    fprintf(stderr, "running with %d threads\n", omp_get_max_threads() );

    
    // open file and initialize vars
    FILE *file;
    char lineAs[num_threads][MAXLINELEN];
    char lineBs[num_threads][MAXLINELEN];
    file = fopen(argv[1], "r");
    if (file == NULL) {
        perror ("Error reading file");
        exit(1);
    }

    int c = 0;
    while (!feof(file)) {

        // grab two lines and store them in our line arrays A & B
        char lineA [MAXLINELEN];
        char lineB [MAXLINELEN];
        fgets(lineA, MAXLINELEN, file);
        fgets(lineB, MAXLINELEN, file);
        chomp(lineA);
        chomp(lineB);
        strcpy(lineAs[c], lineA);
        strcpy(lineBs[c], lineB);                

        // fprintf(stderr, "c = %d\n", c);

        // fire off a batch
        if (c != 0 && c % (num_threads-1) == 0) {
            int job_num;

            // each loop is one alignment (2 lines)
            #pragma omp parallel for
            for (job_num = 0; job_num < num_threads; job_num++) {
                char line1 [MAXLINELEN];
                char line2 [MAXLINELEN];
                strcpy(line1, lineAs[job_num]);
                strcpy(line2, lineBs[job_num]);                
                
                // fprintf(stderr, "thread %d got job %d\n", omp_get_thread_num(), job_num);
                // fprintf(stderr, "thread %d got job %d and seq %s\n", omp_get_thread_num(), job_num, line1);
                do_alignment(line1, line2);
            }

            c=0;
        }
        else {
            c++;
        }
    }
    fclose(file);


    // get and print elapsed time
    t = gettime() - t;  
    printf("elapsed time: %f secs\n", t);

    return 0;
}
Пример #6
0
int 
main(int argc, char **argv) {

  char line[MAX_STR];
  char pgm_desc[MAX_STR];
  char s_name0[MAX_STR], s_name1[MAX_STR];
  char s_desc0[MAX_STR], s_desc1[MAX_STR];
  int p0_beg, p1_beg, p0_end, p1_end;
  int open_plt = 0;
  int copt;

  /* check options */
  while ((copt = getopt(argc, argv, "BZ:")) != -1) {
    switch (copt) {
    case 'B':
      have_bits = 1;
      break;
    case 'Z':
      sscanf(optarg, "%ld", &zdb_size);
      have_zdb = 1;
      break;
    case '?':
    default:
      fprintf(stderr," usage -  ps_lav -B -Z db_size\n");
    }
  }

  while (fgets(line,sizeof(line), stdin)!=NULL) {
    if (line[0] == '#' || line[0] == '\n') continue;
    else {
      switch(line[0]) {
      case 'd':
	get_str(stdin, pgm_desc, sizeof(pgm_desc));
	break;
      case 'h':
	get_str2(stdin, 
		 s_desc0, sizeof(s_desc0),
		 s_desc1, sizeof(s_desc1));
	break;
      case 's':
	get_seq_info(stdin, 
		     s_name0, sizeof(s_name0), &p0_beg, &p0_end,
		     s_name1, sizeof(s_name1), &p1_beg, &p1_end);
	g_n0 = p0_end - p0_beg + 1;
	g_n1 = p1_end - p1_beg + 1;
	break;
      case 'a':
	if (!open_plt) {
	  openplt(g_n0, g_n1, p0_beg, p1_beg,  s_desc0, s_desc1);
	  if ((g_n0 == g_n1) && (p0_beg == p1_beg) && (p0_end == p0_end) &&
	      strcmp(s_name0, s_name1) == 0) {
	    drawdiag(p0_end-p0_beg + 1, p1_end - p1_beg + 1);
	  }
	  open_plt = 1;
	}

	do_alignment(stdin, p0_beg, p1_beg);
	break;
      }
    }
  }
  if (!open_plt) {
    openplt(g_n0, g_n1, p0_beg, p1_beg,  s_desc0, s_desc1);
    if ((g_n0 == g_n1) && (p0_beg == p1_beg) && (p0_end == p0_end) &&
	strcmp(s_name0, s_name1) == 0) {
      drawdiag(p0_end-p0_beg + 1, p1_end - p1_beg + 1);
    }
    open_plt = 1;
  }
  closeplt();
  exit(0);
}