Пример #1
0
int main(void)
{
  double arr1[SIZE1][SIZE2];
  double arr2[SIZE1];
  double average;
  double max;

  get_input(arr1,SIZE1);

  for(int i = 0;i < SIZE1;i++)
  {
    arr2[i] = cal_average(arr1[i], SIZE2);
  }

  average = average_all(arr1,SIZE1);
  max = max_all(arr1,SIZE1);

  show_result(arr2,SIZE1,average,max);

  return 0;
}
Пример #2
0
double inf_norm(DATA_TYPE *seg, int seg_num)
{
  int i;
  int my_cols_this;
  DATA_TYPE *ptr1;
  double *ptr2;
  double local_max;
  int indmax, stride;
  int one = 1 ;                  /* Constant for BLAS operation  */
  
  my_cols_this = my_cols;

  stride = my_rows;
  ptr1 = seg;
  ptr2 = (double *) col1;
  for (i=0; i<my_rows; i++) {
#ifdef CBLAS
	*ptr2 = XASUM(my_cols_last, ptr1, stride);
#else
    	*ptr2 = XASUM(my_cols_last, ptr1, stride);
#endif
    ptr1++;
    ptr2++;
  }

  MPI_Allreduce(col1,col2,my_rows,MPI_DATA_TYPE,MPI_SUM,row_comm);
  indmax = IXAMAX(my_rows, col2, one);
#ifdef CBLAS
   /* do nothing index is ok    */

#else
   /*  Fortran to C adjust array index  */

   indmax = indmax -1;
#endif
  ptr2 = (double *) col2;
  local_max = *(ptr2+indmax);
  return max_all(local_max, INITTYPE6);
}
Пример #3
0
double one_norm(DATA_TYPE *seg, int seg_num)
{
  int i;
  int my_cols_this;
  DATA_TYPE *ptr1;
  double *ptr2;
  double local_max;
  int indmax, stride;
  int one=1;               /* constant for BLAS routine  */
 
  my_cols_this = my_cols;

  stride = my_rows;
  ptr1 = seg;
  ptr2 = (double *) row1;
  for (i=0; i<my_cols_this; i++) {
#ifdef CBLAS
	*ptr2 = XASUM(my_rows, ptr1, one);
#else
    	*ptr2 = XASUM(my_rows, ptr1, one);
#endif
    ptr1 += (my_rows);
    ptr2++;
  }

  MPI_Allreduce((double *) row1, (double *) row2,my_cols_this,MPI_DATA_TYPE,MPI_SUM,col_comm);
   indmax = IXAMAX(my_cols_this, row2, one);
#ifdef CBLAS
   /* do nothing index is ok    */

#else
   /*  Fortran to C adjust array index  */

   indmax = indmax -1;
#endif
  ptr2 = (double *) row2;
  local_max = *(ptr2+indmax);
  return max_all(local_max, INITTYPE3);
}