Exemplo n.º 1
0
/*
 * Compare two matrices.  Print an error message if they differ by
 * more than EPSILON.
 */
int compare_matrix(int n, REAL *A, int an, REAL *B, int bn)
{
     int i, j;
     REAL c;
     int num_zero = 0;

     for (i = 0; i < n; ++i)
	  for (j = 0; j < n; ++j) {
	       /* compute the relative error c */
          if(ELEM(A, an, i, j) == 0 && ELEM(B, bn, i, j) == 0)
              num_zero++;
	       c = ELEM(A, an, i, j) - ELEM(B, bn, i, j);
	       if (c < 0.0) 
		    c = -c;

	       c = c / ELEM(A, an, i, j);
	       if (c > EPSILON) {
		    bots_message("Strassen: Wrong answer!\n");
		    return BOTS_RESULT_UNSUCCESSFUL;
	       }
	  }
     if(num_zero == n * n) {
         bots_message("Strassen: All zero!\n");
         return BOTS_RESULT_UNSUCCESSFUL;
     }
     return BOTS_RESULT_SUCCESSFUL;
}
Exemplo n.º 2
0
void uts_read_file ( char *filename )
{
   FILE *fin;

   if ((fin = fopen(filename, "r")) == NULL) {
      bots_message("Could not open input file (%s)\n", filename);
      exit (-1);
   }
   fscanf(fin,"%lf %lf %d %d %d %llu %d %llu",
             &b_0,
             &nonLeafProb,
             &nonLeafBF,
             &rootId,
             &computeGranularity,
             &exp_tree_size,
             &exp_tree_depth,
             &exp_num_leaves
   );
   fclose(fin);

   computeGranularity = max(1,computeGranularity);

   // Printing input data
   bots_message("\n");
   bots_message("Root branching factor                = %f\n", b_0);
   bots_message("Root seed (0 <= 2^31)                = %d\n", rootId);
   bots_message("Probability of non-leaf node         = %f\n", nonLeafProb);
   bots_message("Number of children for non-leaf node = %d\n", nonLeafBF);
   bots_message("E(n)                                 = %f\n", (double) ( nonLeafProb * nonLeafBF ) );
   bots_message("E(s)                                 = %f\n", (double) ( 1.0 / (1.0 - nonLeafProb * nonLeafBF) ) );
   bots_message("Compute granularity                  = %d\n", computeGranularity);
   bots_message("Random number generator              = "); rng_showtype();
}
Exemplo n.º 3
0
int readseqs(char *filename)
{
   int  i, l1, no_seqs;
   FILE *fin = fopen(filename, "r");
   char *seq1, chartab[128];
	
   if (!fin) {
      bots_message("Could not open sequence file (%s)\n", filename);
      exit (-1);
   }

   if ( fscanf(fin,"Number of sequences is %d", &no_seqs) == EOF ) {
           bots_message("Sequence file is bogus (%s)\n", filename);
      exit(-1);
        };
   
   fill_chartab(chartab);
   bots_message("Sequence format is Pearson\n");

   alloc_aln(no_seqs);

   for (i = 1; i <= no_seqs; i++) {
      seq1 = get_seq(names[i], &l1, chartab, fin);

      seqlen_array[i] = l1;
      seq_array[i]    = (char *) malloc((l1 + 2) * sizeof (char));

      encode(seq1, seq_array[i], l1);

      free(seq1);
   }

   return no_seqs;
}
Exemplo n.º 4
0
Arquivo: uts.c Projeto: kempj/hpxMP
counter_t serial_uts ( Node *root )
{
   counter_t num_nodes;
   bots_message("Computing Unbalance Tree Search algorithm ");
   num_nodes = serTreeSearch( 0, root, uts_numChildren(root) );
   bots_message(" completed!\n");
   return num_nodes;
}
Exemplo n.º 5
0
void strassen_main_par(REAL *A, REAL *B, REAL *C, int n)
{
	bots_message("Computing parallel Strassen algorithm (n=%d) ", n);
	#pragma omp parallel
	#pragma omp single
	#pragma omp task untied     
		OptimizedStrassenMultiply_par(C, A, B, n, n, n, n, 1);
	bots_message(" completed!\n");
}
Exemplo n.º 6
0
void find_queens (int size)
{
	char *a;

	total_count=0;
	a = alloca(size * sizeof(char));
	bots_message("Computing N-Queens algorithm (n=%d) ", size);
	nqueens(size, 0, a, &total_count);
        bots_message(" completed!\n");
}
Exemplo n.º 7
0
Arquivo: uts.c Projeto: kempj/hpxMP
counter_t parallel_uts ( Node *root )
{
    counter_t num_nodes;

    bots_message("Computing Unbalance Tree Search algorithm ");
    #pragma omp parallel
    #pragma omp single nowait
    #pragma omp task untied
    num_nodes = parTreeSearch( 0, root, getNumRootChildren(root) );
    bots_message(" completed!");

    return num_nodes;
}
Exemplo n.º 8
0
static void write_outputs() {
	int i, j;

	bots_message("Minimum area = %d\n\n", MIN_AREA);

	for (i = 0; i < MIN_FOOTPRINT[0]; i++) {
		for (j = 0; j < MIN_FOOTPRINT[1]; j++) {
			if (BEST_BOARD[i][j] == 0) {bots_message(" ");}
			else                       bots_message("%c", (((int)BEST_BOARD[i][j]) - 1 + ((int)'A')));
		} 
		bots_message("\n");
	}  
}
Exemplo n.º 9
0
static void write_outputs() {
  int i, j;

    bots_message("Minimum area = %d\n\n", MIN_AREA);

    for (i = 0; i < MIN_FOOTPRINT[0]; i++) {
      for (j = 0; j < MIN_FOOTPRINT[1]; j++) {
          if (BEST_BOARD[i * COLS + j] == 0) {bots_message(" ");}
          else                       bots_message("%c", 'A' + BEST_BOARD[i * COLS + j] - 1);
      } 
      bots_message("\n");
    }  
}
Exemplo n.º 10
0
/***********************************************************************
 * print_structure: 
 **********************************************************************/
void print_structure(char *name, float *M[])
{
   int ii, jj;
   bots_message("Structure for matrix %s @ 0x%p\n",name, M);
   for (ii = 0; ii < bots_arg_size; ii++) {
     for (jj = 0; jj < bots_arg_size; jj++) {
        if (M[ii*bots_arg_size+jj]!=NULL) {bots_message("x");}
        else bots_message(" ");
     }
     bots_message("\n");
   }
   bots_message("\n");
}
Exemplo n.º 11
0
static void main_entrypoint(void *____arg) {
    main_entrypoint_ctx *ctx = (main_entrypoint_ctx *)____arg;
    int size; size = ctx->size;
{
	total_count=0;

        bots_message("Computing N-Queens algorithm (n=%d) ", size);
hclib_start_finish(); {
			char *a;

			a = (char *)malloc(size * sizeof(char));
			nqueens(size, 0, a, &total_count,0);
		} ; hclib_end_finish(); 
	bots_message(" completed!\n");
    } ;     free(____arg);
}
Exemplo n.º 12
0
Arquivo: uts.c Projeto: steleman/bots
unsigned long long parallel_uts ( Node *root )
{
   unsigned long long num_nodes = 0 ;
   root->numChildren = uts_numChildren(root);

   bots_message("Computing Unbalance Tree Search algorithm ");

   #pragma omp parallel  
      #pragma omp single nowait
      #pragma omp task untied
        num_nodes = parTreeSearch( 0, root, root->numChildren );

   bots_message(" completed!");

   return num_nodes;
}
Exemplo n.º 13
0
void pairalign_init (char *filename)
{
   int i;

   if (!filename || !filename[0]) {
      bots_error(0, "Please specify an input file with the -f option\n");
   }

   init_matrix();


   nseqs = readseqs(1,filename);

        bots_message("Multiple Pairwise Alignment (%d sequences)\n",nseqs);

   for (i = 1; i <= nseqs; i++)
      bots_debug("Sequence %d: %s %6.d aa\n", i, names[i], seqlen_array[i]);

   ktup          =  1;
   window        =  5;
   signif        =  5;
   gap_open      = 10.0;
   gap_extend    =  0.2;
   pw_go_penalty = 10.0;
   pw_ge_penalty =  0.1;
}
Exemplo n.º 14
0
void uts_initRoot(Node * root)
{
   root->height = 0;
   root->numChildren = -1;      // means not yet determined
   rng_init(root->state.state, rootId);

   bots_message("Root node at %p\n", root);
}
Exemplo n.º 15
0
void find_queens (int size)
{
{
	total_count=0;

        bots_message("Computing N-Queens algorithm (n=%d) ", size);
{
{
			char *a;

			a = (char *)malloc(size * sizeof(char));
			nqueens(size, 0, a, &total_count,0);
		}
	}
	bots_message(" completed!\n");
    }
}
Exemplo n.º 16
0
void compute_floorplan (void)
{
#pragma omp_to_hclib
    {
        coor footprint;
        /* footprint of initial board is zero */
        footprint[0] = 0;
        footprint[1] = 0;
        bots_message("Computing floorplan ");
#pragma omp parallel
        {
#pragma omp single
            bots_number_of_tasks = add_cell(1, footprint, board, gcells, 0);
        }
        bots_message(" completed!\n");
    }
}
Exemplo n.º 17
0
Arquivo: fib.c Projeto: alcides/bots
void fib0 (int n)
{
#if defined(MANUAL_CUTOFF) || defined(IF_CUTOFF) || defined(FINAL_CUTOFF)
	par_res = fib(n,0);
#else
	par_res = fib(n);
#endif
	bots_message("Fibonacci result for %d is %lld\n",n,par_res);
}
Exemplo n.º 18
0
void fib0 (int n)
{
main_entrypoint_ctx *new_ctx = (main_entrypoint_ctx *)malloc(sizeof(main_entrypoint_ctx));
new_ctx->n = n;
const char *deps[] = { "system" };
hclib_launch(main_entrypoint, new_ctx, deps, 1);

    bots_message("Fibonacci result for %d is %lld\n",n,par_res);
} 
Exemplo n.º 19
0
void uts_show_stats( void )
{
   int nPes = atoi(bots_resources);
   int chunkSize = 0;

   bots_message("\n");
   bots_message("Tree size                            = %llu\n", (unsigned long long)  bots_number_of_tasks );
   bots_message("Maximum tree depth                   = %d\n", maxTreeDepth );
   bots_message("Chunk size                           = %d\n", chunkSize );
   bots_message("Number of leaves                     = %llu (%.2f%%)\n", nLeaves, nLeaves/(float)bots_number_of_tasks*100.0 ); 
   bots_message("Number of PE's                       = %.4d threads\n", nPes );
   bots_message("Wallclock time                       = %.3f sec\n", bots_time_program );
   bots_message("Overall performance                  = %.0f nodes/sec\n", (bots_number_of_tasks / bots_time_program) );
   bots_message("Performance per PE                   = %.0f nodes/sec\n", (bots_number_of_tasks / bots_time_program / nPes) );
}
Exemplo n.º 20
0
void sparselu_par_call(float **BENCH)
{
   int ii, jj, kk;
   
   bots_message("Computing SparseLU Factorization (%dx%d matrix with %dx%d blocks) ",
           bots_arg_size,bots_arg_size,bots_arg_size_1,bots_arg_size_1);
#pragma omp parallel private(kk)
   {
   for (kk=0; kk<bots_arg_size; kk++) 
   {
#pragma omp single
      lu0(BENCH[kk*bots_arg_size+kk]);

#pragma omp for nowait
      for (jj=kk+1; jj<bots_arg_size; jj++)
         if (BENCH[kk*bots_arg_size+jj] != NULL)
            #pragma omp task untied firstprivate(kk, jj) shared(BENCH)
         {
            fwd(BENCH[kk*bots_arg_size+kk], BENCH[kk*bots_arg_size+jj]);
         }
#pragma omp for
      for (ii=kk+1; ii<bots_arg_size; ii++) 
         if (BENCH[ii*bots_arg_size+kk] != NULL)
            #pragma omp task untied firstprivate(kk, ii) shared(BENCH)
         {
            bdiv (BENCH[kk*bots_arg_size+kk], BENCH[ii*bots_arg_size+kk]);
         }

#pragma omp for private(jj)
      for (ii=kk+1; ii<bots_arg_size; ii++)
         if (BENCH[ii*bots_arg_size+kk] != NULL)
            for (jj=kk+1; jj<bots_arg_size; jj++)
               if (BENCH[kk*bots_arg_size+jj] != NULL)
               #pragma omp task untied firstprivate(kk, jj, ii) shared(BENCH)
               {
                     if (BENCH[ii*bots_arg_size+jj]==NULL) BENCH[ii*bots_arg_size+jj] = allocate_clean_block();
                     bmod(BENCH[ii*bots_arg_size+kk], BENCH[kk*bots_arg_size+jj], BENCH[ii*bots_arg_size+jj]);
               }

   }
   }
   bots_message(" completed!\n");
}
Exemplo n.º 21
0
void compute_floorplan (void)
{
	coor footprint;
	/* footprint of initial board is zero */
	footprint[0] = 0;
	footprint[1] = 0;
	bots_message("Computing floorplan ");
#pragma omp parallel
	{
#pragma omp single
#if defined(MANUAL_CUTOFF) || defined(IF_CUTOFF) || defined(FINAL_CUTOFF)
		bots_number_of_tasks = add_cell(1, footprint, board, gcells,0);
#else
		bots_number_of_tasks = add_cell(1, footprint, board, gcells);
#endif
	}
	bots_message(" completed!\n");

}
Exemplo n.º 22
0
void find_queens (int size)
{
#pragma omp_to_hclib
    {
	total_count=0;

        bots_message("Computing N-Queens algorithm (n=%d) ", size);
	#pragma omp parallel
	{
		#pragma omp single
		{
			char *a;

			a = (char *)malloc(size * sizeof(char));
			nqueens(size, 0, a, &total_count,0);
		}
	}
	bots_message(" completed!\n");
    }
}
Exemplo n.º 23
0
Arquivo: uts.c Projeto: kempj/hpxMP
int uts_check_result ( void )
{
   int answer = BOTS_RESULT_SUCCESSFUL;

   if ( bots_number_of_tasks != exp_tree_size ) {
      answer = BOTS_RESULT_UNSUCCESSFUL;
      bots_message("Tree size value is non valid.\n");
   }

   return answer;
}
Exemplo n.º 24
0
int uts_check_result ( void )
{
   int answer = BOTS_RESULT_SUCCESSFUL;

   if ( bots_number_of_tasks != exp_tree_size ) {
      answer = BOTS_RESULT_UNSUCCESSFUL;
      bots_message("Incorrect tree size result (%llu instead of %llu).\n", bots_number_of_tasks, exp_tree_size);
   }

   return answer;
}
Exemplo n.º 25
0
/***********************************************************************
 * genmat: 
 **********************************************************************/
void genmat (float *M[])
{
   int null_entry, init_val, i, j, ii, jj;
   float *p;
   int a=0,b=0;

   init_val = 1325;

   /* generating the structure */
   for (ii=0; ii < bots_arg_size; ii++)
   {
      for (jj=0; jj < bots_arg_size; jj++)
      {
         /* computing null entries */
         null_entry=FALSE;
         if ((ii<jj) && (ii%3 !=0)) null_entry = TRUE;
         if ((ii>jj) && (jj%3 !=0)) null_entry = TRUE;
	 if (ii%2==1) null_entry = TRUE;
	 if (jj%2==1) null_entry = TRUE;
	 if (ii==jj) null_entry = FALSE;
	 if (ii==jj-1) null_entry = FALSE;
         if (ii-1 == jj) null_entry = FALSE; 
         /* allocating matrix */
         if (null_entry == FALSE){
            a++;
            M[ii*bots_arg_size+jj] = (float *) malloc(bots_arg_size_1*bots_arg_size_1*sizeof(float));
	    if ((M[ii*bots_arg_size+jj] == NULL))
            {
               bots_message("Error: Out of memory\n");
               exit(101);
            }
            /* initializing matrix */
            p = M[ii*bots_arg_size+jj];
            for (i = 0; i < bots_arg_size_1; i++) 
            {
               for (j = 0; j < bots_arg_size_1; j++)
               {
	            init_val = (3125 * init_val) % 65536;
      	            (*p) = (float)((init_val - 32768.0) / 16384.0);
                    p++;
               }
            }
         }
         else
         {
            b++;
            M[ii*bots_arg_size+jj] = NULL;
         }
      }
   }
   bots_debug("allo = %d, no = %d, total = %d, factor = %f\n",a,b,a+b,(float)((float)a/(float)(a+b)));
}
Exemplo n.º 26
0
void fib0 (int n)
{
hclib_pragma_marker("omp_to_hclib", "", "pragma61_omp_to_hclib");
    {
hclib_pragma_marker("omp", "parallel", "pragma63_omp_parallel");
        {
hclib_pragma_marker("omp", "single", "pragma65_omp_single");
            {
                par_res = fib(n);
            }
        }
    }
    bots_message("Fibonacci result for %d is %lld\n",n,par_res);
}
Exemplo n.º 27
0
unsigned long long parallel_uts ( Node *root )
{
   unsigned long long num_nodes = 0 ;
   root->numChildren = uts_numChildren(root);

   bots_message("Computing Unbalance Tree Search algorithm ");

hclib_pragma_marker("omp_to_hclib", "", "pragma183_omp_to_hclib");
   {
hclib_pragma_marker("omp", "parallel", "pragma185_omp_parallel");
       {
hclib_pragma_marker("omp", "single nowait", "pragma187_omp_single");
           {
hclib_pragma_marker("omp", "task untied", "pragma189_omp_task");
        num_nodes = parTreeSearch( 0, root, root->numChildren );
           }
       }
   }

   bots_message(" completed!");

   return num_nodes;
}
Exemplo n.º 28
0
/***********************************************************************
 * allocate_clean_block: 
 **********************************************************************/
float * allocate_clean_block()
{
  int i,j;
  float *p, *q;

  p = (float *) malloc(bots_arg_size_1*bots_arg_size_1*sizeof(float));
  q=p;
  if (p!=NULL){
     for (i = 0; i < bots_arg_size_1; i++) 
        for (j = 0; j < bots_arg_size_1; j++){(*p)=0.0; p++;}
	
  }
  else
  {
      bots_message("Error: Out of memory\n");
      exit (101);
  }
  return (q);
}
Exemplo n.º 29
0
void floorplan_init (char *filename)
{
	int i,j;

	inputFile = fopen(filename, "r");

	if(NULL == inputFile) {
		bots_message("Couldn't open %s file for reading\n", filename);
		exit(1);
	}

	/* read input file and initialize global minimum area */
	read_inputs();
	MIN_AREA = ROWS * COLS;

	/* initialize board is empty */
	for (i = 0; i < ROWS; i++)
		for (j = 0; j < COLS; j++) board[i][j] = 0;

}
Exemplo n.º 30
0
int align_verify ()
{
   int i,j;
   int result = BOTS_RESULT_SUCCESSFUL;
   
   for(i = 0; i<nseqs; i++)
   {
      for(j = 0; j<nseqs; j++)
      {
         if (bench_output[i*nseqs+j] != seq_output[i*nseqs+j])
         {
                                bots_message("Error: Optimized prot. (%3d:%3d)=%5d Sequential prot. (%3d:%3d)=%5d\n",
                                        i+1, j+1, (int) bench_output[i*nseqs+j],
                                        i+1, j+1, (int) seq_output[i*nseqs+j]);
            result = BOTS_RESULT_UNSUCCESSFUL;
         }
      }
   }
   return result;
}