当前位置: 首页>>代码示例>>C++>>正文


C++ wtime函数代码示例

本文整理汇总了C++中wtime函数的典型用法代码示例。如果您正苦于以下问题:C++ wtime函数的具体用法?C++ wtime怎么用?C++ wtime使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wtime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    if (argc < 2) {
        printf("Missing size of array!\n");
        return EXIT_FAILURE;
    }

    int size_array = atoi(argv[1]);
    int *array = (int *) malloc(size_array * sizeof(uint32_t));

    for (int i = 0; i < size_array; i++) {
        array[i] = getrand(0, 100000);
//      printf ("array[%d]= %d ",i,array[i]);
    }

    double time = wtime();

    for (int i = 0; i < size_array - 1; i++) {
        for (int j = 0; j < size_array - i - 1; j++) {
            if (array[j] > array[j + 1]) {
                int tmp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = tmp;
            }
        }
    }

/*    for (int i = 0; i < size_array; i++) {
      printf ("array[%d]= %d ",i,array[i]);
    }*/

    time = wtime() - time;

    FILE *tb;
    tb = fopen("bubblesort.dat", "a");
    fprintf(tb, "%d %.6f\n", size_array, time);

    free(array);
    return EXIT_SUCCESS;
}
开发者ID:evg-kazartseff,项目名称:DSA,代码行数:40,代码来源:main.c

示例2: main

int main(int argc, char **argv){
  int i, me, target;
  unsigned int size;
  double t;
  MPI_Status status;

  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &me);
  target = 1 - me;

  init_buf(send_buf, me);
  init_buf(recv_buf, target);

  if(me==0) print_items();

  for(size=1;size<MAX_SIZE+1;size*=2){
    MPI_Barrier(MPI_COMM_WORLD);
    for(i=0;i<LOOP+WARMUP;i++){
      if(WARMUP == i)
	t = wtime();

      if(me == 0){
	MPI_Send(send_buf, size, MPI_CHAR, target, 9, MPI_COMM_WORLD);
	MPI_Recv(recv_buf, size, MPI_CHAR, target, 5, MPI_COMM_WORLD, &status);
      } 
      else {
	MPI_Recv(recv_buf, size, MPI_CHAR, target, 9, MPI_COMM_WORLD, &status);
	MPI_Send(send_buf, size, MPI_CHAR, target, 5, MPI_COMM_WORLD);
      } 
    }

    MPI_Barrier(MPI_COMM_WORLD);
    t = wtime() - t;
    if(me == 0)
      print_results(size, t);
  }

  MPI_Finalize();
  return 0;
}
开发者ID:mnakao,项目名称:pingpong,代码行数:40,代码来源:send_recv.c

示例3: startrun

//  startrun: startup hierarchical N-body code.
//  ___________________________________________
// This runs once. 
local void startrun(void) {
  printf("startrun\n");
  startrun_time_0 = wtime();
  bodyptr p1, p2, p;
  stream gravstr;

  define_body(sizeof(body), Precision, NDIM);	// setup phat body struct
  define_body_offset(PosTag,  BodyOffset(Pos));
  define_body_offset(VelTag,  BodyOffset(Vel));
  define_body_offset(MassTag, BodyOffset(Mass));
  define_body_offset(PhiTag,  BodyOffset(Phi));
  define_body_offset(AccTag,  BodyOffset(Acc));
  infile = getparam("in");			// set I/O file names
  outfile = getparam("out");
  savefile = getparam("save");
  if (strnull(getparam("restore")))		// starting a new run?
    newrun();
  else						// else resume old run
    oldrun();
  if (ABS(nstatic) > nbody)			// check nstatic is OK
    error("%s: absurd value for nstatic\n", getargv0());
  p1 = bodytab + MAX(nstatic, 0);		// set dynamic body range
  p2 = bodytab + nbody + MIN(nstatic, 0);
  testcalc = TRUE;				// determine type of calc:
  for (p = p1; p < p2; p++)
    testcalc = testcalc && (Mass(p) == 0);	// look for dynamic masses
  strfile = getparam("stream");
  logfile = getparam("log");
#if defined(EXTGRAV)
  if (! strnull(getparam("gravgsp"))) {		// was GSP file given?
    gravstr = stropen(getparam("gravgsp"), "r");
    get_history(gravstr);
    gravgsp = get_gsprof(gravstr);		// read external field GSP
    strclose(gravstr);
  }
#endif

  startrun_time_1 = wtime();
}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:42,代码来源:treecode.c

示例4: main

int main(int argc, char **argv)
{
   int n;
   int repeat;
   double dot;
   long start_time, end_time;

   if ((argc != 3)) {
      printf("Uso: %s <tamanho dos vetores> <repeticoes>\n", argv[0]);
      exit(EXIT_FAILURE);
   }

   n = atoi(argv[1]);       // tamanho dos vetores
   repeat = atoi(argv[2]);  // numero de repeticoes (variar carga)


   // Cria vetores
   double *a = (double *) malloc(sizeof(double) * n);
   double *b = (double *) malloc(sizeof(double) * n);

   if (a == NULL || b == NULL) {
      printf("Erro de alocacao de memoria\n");
      exit(EXIT_FAILURE);      
   }

   init_vectors(a, b, n);

   start_time = wtime();
   dot = dot_product(a, b, n, repeat);
   end_time = wtime();

   printf("Produto escalar = %f\n", dot);
   printf("Tempo de calculo = %ld usec\n", (long) (end_time - start_time));

   free((void *) a);
   free((void *) b);

   return EXIT_SUCCESS;
}
开发者ID:AndreaInfUFSM,项目名称:elc139-2016a,代码行数:39,代码来源:dotprod_seq.c

示例5: main

int main(int argc, char **argv)	
{
    pthread_t thread1;
    int ret = -1;
    int i = 0;
    double time1, time2;

    ret = pthread_create(&thread1, NULL, thread1_fn, NULL);
    assert(ret == 0);

    time1 = wtime();
    for(i=0; i<ITERATIONS; i++)
    {
	wakeywakey();
    }
    time2 = wtime();

    printf("time for %d iterations: %f seconds.\n", ITERATIONS, (time2-time1));
    printf("per iteration: %f\n", (time2-time1)/(double)ITERATIONS);

    return(0);
}
开发者ID:Goon83,项目名称:SALB,代码行数:22,代码来源:thread-bench2.c

示例6: init_synchronization

void init_synchronization(void)
{
  current_synchronization = form_of_synchronization;
  max_counter = First_max_counter;
  interval = First_interval;
  first_measurement_run = True;

  logging(DBG_SYNC, "starting with max_counter = %d interval = %9.1f\n", 
	 max_counter, interval*1.0e6);

  if( current_synchronization == SYNC_REAL) {
    if( ! mpi_wtime_is_global ) determine_time_differences();
    if( lrootproc() ) start_batch = wtime();
    logging(DBG_SYNC, "---- new start_batch ----------------\n");
    MPI_Bcast(&start_batch, 1, MPI_DOUBLE, 0, get_measurement_comm());
  }
}
开发者ID:jonarbo,项目名称:KUBE,代码行数:17,代码来源:measurement.c

示例7: while

depth_t bc::bfs_sssp(
	index_t root
)
{
	sa[root] = 0;
	sp_count[root] = 1;
	depth_t level = 0;
	dist[root]=0;
	while(true)
	{
		double ltm= wtime();
		index_t front_count = 0;
		for(vertex_t vert_id = 0; vert_id<g->vert_count; vert_id++)
		{
			if(sa[vert_id] == level)
			{
				index_t my_beg = g->beg_pos[vert_id];
				index_t my_end = g->beg_pos[vert_id + 1];

				for(; my_beg<my_end; my_beg++)
				{
					vertex_t nebr=g->csr[my_beg];
					path_t weit=g->weight[my_beg];

					if(dist[nebr]>dist[vert_id]+weit)
					{
						dist[nebr]=dist[vert_id]+weit;
						sp_count[nebr]=0; //prior parent is wrong
						sa[nebr]=level+1;
						front_count++;
					}

					if(dist[nebr]==dist[vert_id]+weit)
						sp_count[nebr]+=sp_count[vert_id];
				}
			}
		}
//		std::cout<<"Level "<<(int) level<<": "<<front_count<<" "
//							<<wtime() - ltm<<"\n";
		if(front_count == 0) break;
		level ++;
	}
	
	return level+1;

}
开发者ID:ChickenRunjyd,项目名称:cpu_bc,代码行数:46,代码来源:bc.cpp

示例8: stop_synchronization

double stop_synchronization(void)
{
  stop_batch = stop_sync = wtime();

  if( current_synchronization == SYNC_REAL ) {

    if( stop_sync - start_sync > interval )
      invalid[counter] = INVALID_TOOK_TOO_LONG;
  
    logging(DBG_SYNC, "stop_sync = %9.1f ", normalize_time(stop_sync));
    switch( invalid[counter] ) {
    case INVALID_TOOK_TOO_LONG: logging(DBG_SYNC, "invalid_too_long\n"); break;
    case INVALID_STARTED_LATE:  logging(DBG_SYNC, "invalid_started_late\n"); break;
    default:                    logging(DBG_SYNC, "\n"); 
    }
  }

  return stop_sync;
}
开发者ID:jonarbo,项目名称:KUBE,代码行数:19,代码来源:measurement.c

示例9: main

int main(){
  double t;
  int i, me, target;
  unsigned int size;

  me = xmp_node_num();
  target = 3 - me;

  init_buf(local_buf, me);
  init_buf(target_buf, me);

  if(me==1) print_items();

  for(size=4;size<MAX_SIZE+1;size*=2){ // size must be more than 4 when using Fujitsu RDMA
    xmp_sync_all(NULL);
    for(i=0;i<LOOP+WARMUP;i++){
      if(WARMUP == i)
        t = wtime();

      if(me == 1){
        local_buf[0:size] = target_buf[0:size]:[target];
	xmp_sync_memory(NULL);
#ifdef DEBUG
	if(local_buf[0] != '2' && local_buf[size-1] != '2') fprintf(stderr, "Error !\n");
	local_buf[0] = '1'; local_buf[size-1] = '1';
#endif
	xmp_sync_all(NULL);
      }
      else{
	xmp_sync_all(NULL);
	local_buf[0:size] = target_buf[0:size]:[target];

#ifdef DEBUG
        if(local_buf[0] != '1' && local_buf[size-1] != '1') fprintf(stderr, "Error !\n");
	local_buf[0] = '2'; local_buf[size-1] = '2';
#endif
      }
      xmp_sync_all(NULL);
    }
开发者ID:mnakao,项目名称:pingpong,代码行数:39,代码来源:xmp_get.c

示例10: main

int main()
{
  Init();
  double start = wtime();
  double start_linked_list = wtime();
  RunThoughLinkedList();
  double end_linked_list = wtime();
  double start_explicit = wtime();
  RunExplicit();
  double end_explicit = wtime();
  double end = wtime();

  printf("Time through Linked List %7.2f\n"
    "Time through explicit %7.2f\n"
    "Total Time taken %7.2f\n",
    end_linked_list-start_linked_list,
    end_explicit-start_explicit,
    end-start
  );
}
开发者ID:hjmjohnson,项目名称:XEParallelProg,代码行数:20,代码来源:main.cpp

示例11: main


//.........这里部分代码省略.........
            goto ENDOFTESTS;
        }
        else length = total_length/Num_procs;

        offset       = atol(*++argv);
        if (offset < 0) {
            printf("ERROR: Invalid array offset: %ld\n", offset);
            error = 1;
            goto ENDOFTESTS;
        }
#ifdef STATIC_ALLOCATION
        if ((3*length + 2*offset) > N) {
            printf("ERROR: vector length/offset %ld/%ld too ", total_length, offset);
            printf("large; increase MAXLENGTH in Makefile or decrease vector length\n");
            error = 1;
            goto ENDOFTESTS;
        }
#endif
ENDOFTESTS:
        ;
    }
    bail_out(error);

    /* broadcast initialization data */
    MPI_Bcast(&length,1, MPI_LONG, root, MPI_COMM_WORLD);
    MPI_Bcast(&offset,1, MPI_LONG, root, MPI_COMM_WORLD);
    MPI_Bcast(&iterations,1, MPI_INT, root, MPI_COMM_WORLD);

#ifndef STATIC_ALLOCATION
    space = (3*length + 2*offset)*sizeof(double);
    a = (double *) malloc(space);
    if (!a && my_ID == root) {
        printf("ERROR: Could not allocate %ld bytes for vectors\n", (long int)space);
        error = 1;
    }
    bail_out(error);
#endif
    b = a + length + offset;
    c = b + length + offset;

    bytes   = 3.0 * sizeof(double) * length * Num_procs;

    if (my_ID == root) {
        printf("Number of processes  = %d\n", Num_procs);
        printf("Vector length        = %ld\n", total_length);
        printf("Offset               = %ld\n", offset);
        printf("Number of iterations = %d\n", iterations);
    }

#pragma vector always
    for (j=0; j<length; j++) {
        a[j] = 0.0;
        b[j] = 2.0;
        c[j] = 2.0;
    }

    /* --- MAIN LOOP --- repeat Triad iterations times --- */

    scalar = SCALAR;

    for (iter=0; iter<iterations; iter++) {

        MPI_Barrier(MPI_COMM_WORLD);
        if (my_ID == root) {
            nstream_time = wtime();
        }

#pragma vector always
        for (j=0; j<length; j++) a[j] = b[j]+scalar*c[j];

        if (my_ID == root) {
            if (iter>0 || iterations==1) { /* skip the first iteration */
                nstream_time = wtime() - nstream_time;
                avgtime = avgtime + nstream_time;
                mintime = MIN(mintime, nstream_time);
                maxtime = MAX(maxtime, nstream_time);
            }
        }

        /* insert a dependency between iterations to avoid dead-code elimination */
#pragma vector always
        for (j=0; j<length; j++) b[j] = a[j];
    }

    /*********************************************************************
    ** Analyze and output results.
    *********************************************************************/

    if (my_ID == root) {
        if (checkTRIADresults(iterations, length)) {
            avgtime = avgtime/(double)(MAX(iterations-1,1));
            printf("Rate (MB/s): %lf, Avg time (s): %lf, Min time (s): %lf",
                   1.0E-06 * bytes/mintime, avgtime, mintime);
            printf(", Max time (s): %lf\n", maxtime);
        }
        else error = 1;
    }
    bail_out(error);
    MPI_Finalize();
}
开发者ID:molguin-qc,项目名称:ParResKernels,代码行数:101,代码来源:nstream.c

示例12: main

int main( int argc, char *argv[] )
{
    unsigned iter;
    FILE *infile, *resfile;
    char *resfilename;

    // algorithmic parameters
    algoparam_t param;
    int np;

    double runtime, flop;
    double residual=0.0;

    // check arguments
    if( argc < 2 )
    {
	usage( argv[0] );
	return 1;
    }

    // check input file
    if( !(infile=fopen(argv[1], "r"))  ) 
    {
	fprintf(stderr, 
		"\nError: Cannot open \"%s\" for reading.\n\n", argv[1]);
      
	usage(argv[0]);
	return 1;
    }

    // check result file
    resfilename= (argc>=3) ? argv[2]:"heat.ppm";

    if( !(resfile=fopen(resfilename, "w")) )
    {
	fprintf(stderr, 
		"\nError: Cannot open \"%s\" for writing.\n\n", 
		resfilename);
	usage(argv[0]);
	return 1;
    }

    // check input
    if( !read_input(infile, &param) )
    {
	fprintf(stderr, "\nError: Error parsing input file.\n\n");
	usage(argv[0]);
	return 1;
    }
    print_params(&param);

    if( !initialize(&param) )
	{
	    fprintf(stderr, "Error in Solver initialization.\n\n");
	    usage(argv[0]);
            return 1;
	}

    // full size (param.resolution are only the inner points)
    np = param.resolution + 2;
    
#if _EXTRAE_
    Extrae_init();
#endif

    // starting time
    runtime = wtime();

    iter = 0;
    while(1) {
	switch( param.algorithm ) {
	    case 0: // JACOBI
	            residual = relax_jacobi(param.u, param.uhelp, np, np);
		    // Copy uhelp into u
		    copy_mat(param.uhelp, param.u, np, np);
		    break;
	    case 1: // GAUSS
		    residual = relax_gauss(param.u, np, np);
		    break;
	    }

        iter++;

        // solution good enough ?
        if (residual < 0.00005) break;

        // max. iteration reached ? (no limit with maxiter=0)
        if (param.maxiter>0 && iter>=param.maxiter) break;
    }

    // Flop count after iter iterations
    flop = iter * 11.0 * param.resolution * param.resolution;
    // stopping time
    runtime = wtime() - runtime;

#if _EXTRAE_
    Extrae_fini();
#endif

    fprintf(stdout, "Time: %04.3f \n", runtime);
//.........这里部分代码省略.........
开发者ID:AlbertSuarez,项目名称:PAR-Labs,代码行数:101,代码来源:heat-omp.c

示例13: main

int main(int argc, char* argv[])
{
    double t1, t2, t3, t4, t5;
    double sum1, sum2, sum3, sum4;
    int arg = 1, len = 0, iters = 0, verb = 0, run = 1;
    int do_vcopy = 1, do_vadd = 1, do_vjacobi = 1;
    while(argc>arg) {
        if      (strcmp(argv[arg],"-v")==0)  verb++;
        else if (strcmp(argv[arg],"-vv")==0) verb+=2;
        else if (strcmp(argv[arg],"-n")==0)  run = 0;
        else if (strcmp(argv[arg],"-c")==0)  do_vadd = 0,  do_vjacobi = 0;
        else if (strcmp(argv[arg],"-a")==0)  do_vcopy = 0, do_vjacobi = 0;
        else if (strcmp(argv[arg],"-j")==0)  do_vcopy = 0, do_vadd = 0;
        else
            break;
        arg++;
    }
    if (argc>arg) { len   = atoi(argv[arg]); arg++; }
    if (argc>arg) { iters = atoi(argv[arg]); arg++; }
    if (len == 0) len = 10000;
    if (iters == 0) iters = 20;
    len = len * 1000;

    printf("Alloc/init 3 double arrays of length %d ...\n", len);
    double* a = (double*) malloc(len * sizeof(double));
    double* b = (double*) malloc(len * sizeof(double));
    double* c = (double*) malloc(len * sizeof(double));
    for(int i = 0; i<len; i++) {
        a[i] = 1.0;
        b[i] = (double) (i % 20);
        c[i] = 3.0;
    }

    // Generate vectorized variants & run against naive/original

#if __AVX__
    bool do32 = true;
#else
    bool do32 = false;
#endif

    // vcopy

    if (do_vcopy) {
        vcopy_t vcopy16, vcopy32;

        Rewriter* rc16 = dbrew_new();
        if (verb>1) dbrew_verbose(rc16, true, true, true);
        dbrew_set_function(rc16, (uint64_t) vcopy);
        dbrew_config_parcount(rc16, 3);
        dbrew_config_force_unknown(rc16, 0);
        dbrew_set_vectorsize(rc16, 16);
        vcopy16 = (vcopy_t) dbrew_rewrite(rc16, a, b, len);
        if (verb) decode_func(rc16, "vcopy16");

        if (do32) {
            Rewriter* rc32 = dbrew_new();
            if (verb>1) dbrew_verbose(rc32, true, true, true);
            dbrew_set_function(rc32, (uint64_t) vcopy);
            dbrew_config_parcount(rc32, 3);
            dbrew_config_force_unknown(rc32, 0);
            dbrew_set_vectorsize(rc32, 32);
            vcopy32 = (vcopy_t) dbrew_rewrite(rc32, a, b, len);
            if (verb) decode_func(rc32, "vcopy32");
        }

        printf("Running %d iterations of vcopy ...\n", iters);
        t1 = wtime();
        for(int iter = 0; iter < iters; iter++)
            naive_vcopy(a, b, len);
        t2 = wtime();
        for(int iter = 0; iter < iters; iter++)
            vcopy(a, b, len);
        t3 = wtime();
        if (run)
            for(int iter = 0; iter < iters; iter++)
                vcopy16(a, b, len);
        t4 = wtime();
        if (do32 && run)
            for(int iter = 0; iter < iters; iter++)
                vcopy32(a, b, len);
        t5 = wtime();
        printf("  naive: %.3f s, un-rewritten: %.3f s, rewritten-16: %.3f s",
               t2-t1, t3-t2, t4-t3);
        if (do32)
            printf(", rewritten-32: %.3f s", t5-t4);
        printf("\n");
    }


    // vadd

    if (do_vadd) {
        vadd_t vadd16, vadd32;

        Rewriter* ra16 = dbrew_new();
        if (verb>1) dbrew_verbose(ra16, true, true, true);
        dbrew_set_function(ra16, (uint64_t) vadd);
        dbrew_config_parcount(ra16, 4);
        dbrew_config_force_unknown(ra16, 0);
//.........这里部分代码省略.........
开发者ID:lrr-tum,项目名称:dbrew,代码行数:101,代码来源:vector.c

示例14: main


//.........这里部分代码省略.........
    bail_out(error);
  }

  /* Fill the original column matrix                                             */
  istart = 0;  
  int chunk_size = Block_order/group_size;
  if (tiling) {
      for (j=shm_ID*chunk_size;j<(shm_ID+1)*chunk_size;j+=Tile_order) {
      for (i=0;i<order; i+=Tile_order) 
        for (jt=j; jt<MIN((shm_ID+1)*chunk_size,j+Tile_order); jt++)
          for (it=i; it<MIN(order,i+Tile_order); it++) {
            A(it,jt) = (double) ((double)order*(jt+colstart) + it);
            B(it,jt) = -1.0;
          }
    }
  }
  else {
    for (j=shm_ID*chunk_size;j<(shm_ID+1)*chunk_size;j++) 
      for (i=0;i<order; i++) {
        A(i,j) = (double)((double)order*(j+colstart) + i);
        B(i,j) = -1.0;
      }
  }
  /* NEED A STORE FENCE HERE                                                     */
  MPI_Win_sync(shm_win_A);
  MPI_Win_sync(shm_win_B);
  MPI_Barrier(shm_comm);

  for (iter=0; iter<=iterations; iter++) {

    /* start timer after a warmup iteration */
    if (iter == 1) { 
      MPI_Barrier(MPI_COMM_WORLD);
      local_trans_time = wtime();
    }

    /* do the local transpose                                                    */
    istart = colstart; 
    if (!tiling) {
      for (i=shm_ID*chunk_size; i<(shm_ID+1)*chunk_size; i++) {
        for (j=0; j<Block_order; j++) 
              B(j,i) = A(i,j);
	}
    }
    else {
      for (i=shm_ID*chunk_size; i<(shm_ID+1)*chunk_size; i+=Tile_order) {
        for (j=0; j<Block_order; j+=Tile_order) 
          for (it=i; it<MIN(Block_order,i+Tile_order); it++)
            for (jt=j; jt<MIN(Block_order,j+Tile_order);jt++) {
              B(jt,it) = A(it,jt); 
	    }
      }
    }

    for (phase=1; phase<Num_groups; phase++){
      recv_from = ((group_ID + phase             )%Num_groups);
      send_to   = ((group_ID - phase + Num_groups)%Num_groups);

      istart = send_to*Block_order; 
      if (!tiling) {
        for (i=shm_ID*chunk_size; i<(shm_ID+1)*chunk_size; i++) 
          for (j=0; j<Block_order; j++){
	    Work_out(j,i) = A(i,j);
	  }
      }
      else {
开发者ID:nchaimov,项目名称:ParResKernels,代码行数:67,代码来源:transpose.c

示例15: multiply_by_blas

/*---------------------------------------------------------------------------
 *
 * Compute matrix product using BLAS routine DGEMM.
 *
 * Input
 *   int argc        - length of argv[] array
 *   char* argv[]    - pointer to command line parameter array
 *   int verbosity   - program verification: verbosity > 0 gives more output
 *
 * Output
 *   double          - elapsed time for product computation
 */
double multiply_by_blas( int argc, char* argv[], int verbosity )
{
    int rows, cols, mids;
    double **a, **b, **c;
    double t1, t2;
    double sec;
    double gflop_count;

    /*
     * process command line arguments
     */
    rows = atoi( argv[0] );
    mids = atoi( argv[1] );
    cols = atoi( argv[2] );
    gflop_count = 2.0 * rows * mids * cols / 1.0e9;

    if ( verbosity > 0 )
    {
        printf( "BLAS: rows = %d, mids = %d, columns = %d\n",
                rows, mids, cols );
    }

    /*
     * allocate and initialize matrices
     */
    a = (double**) allocateMatrix( rows, mids );
    b = (double**) allocateMatrix( mids, cols );
    c = (double**) allocateMatrix( rows, cols );
    initialize_matrices( a, b, c, rows, cols, mids, verbosity );

    /*
     * compute product: There is an implicit matrix transpose when
     * passing from Fortran to C and vice-versa.  To compute C :=
     * alpha * A * B + beta * C we use dgemm() to compute C' := alpha
     * * B' * A' + beta * C'.  The first two arguments to dgemm() are
     * 'N' indicating we don't want a transpose in addition to the
     * implicit one.  The matrices A and B are passed in reverse order
     * so dgemm() receives (after the implicit transpose) B' and A'.
     * Arguments 3 and 4 are the dimensions of C' and argument 5 is
     * the column dimension of B' (and the row dimension of A').
     */
    t1 = wtime();
    dgemm( 'N', 'N', cols, rows, mids, 1.0, &b[0][0], cols, &a[0][0], mids, 
           0.0, &c[0][0], cols );
    t2 = wtime();
    sec = t2 - t1;

    if ( verbosity > 1 )
        printf( "checksum = %f\n", checksum( c, rows, cols ) );

    printf( "BLAS:        %6.3f secs %6.3f gflops ( %5d x %5d x %5d )\n",
            sec, gflop_count / sec, rows, mids, cols );

    /*
     * clean up
     */
    deallocateMatrix( a );
    deallocateMatrix( b );
    deallocateMatrix( c );

    return t2 - t1;
}
开发者ID:gordon-cs,项目名称:cps343-hoe,代码行数:74,代码来源:matrix_prod.c


注:本文中的wtime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。