Esempio n. 1
0
int main(int argc, char **argv) {

        if (argc != 4) {
                fprintf(stderr, "Usage: %s <vector size in K> <sort size in K> <merge size in K>\n", argv[0]);
                return 1;
        }

	N = atol(argv[1]) * BLOCK_SIZE;
	MIN_SORT_SIZE = atol(argv[2]) * BLOCK_SIZE;
        MIN_MERGE_SIZE = atol(argv[3]) * BLOCK_SIZE;
	
	T *data = malloc(N*sizeof(T));
	T *tmp = malloc(N*sizeof(T));
	
	initialize(N, data);
	clear(N, tmp);

	tareador_ON();
   	multisort(N, data, tmp);
	tareador_OFF();

   	check_sorted (N, data);

    	fprintf(stdout, "Multisort program finished\n");
	return 0;
}
Esempio n. 2
0
int main(int argc, char **argv) {
    struct timeval start;
    struct timeval stop;
    unsigned long elapsed;
    double result;

    double *B = malloc(size*sizeof(double));

    tareador_ON ();

    int i;

    tareador_start_task("init_A");
    for (i=0; i< size; i++) A[i]=i;
    tareador_end_task();

    tareador_start_task("init_B");
    for (i=0; i< size; i++) B[i]=2*i;
    tareador_end_task();

    gettimeofday(&start,NULL);

    dot_product (size, A, B, &result);

    tareador_OFF ();

    gettimeofday(&stop,NULL);
    elapsed = 1000000 * (stop.tv_sec - start.tv_sec);
    elapsed += stop.tv_usec - start.tv_usec;
    printf("Result of Dot product i= %le\n", result);
    printf("Execution time (us): %lu \n", elapsed);

    return 0;
}
Esempio n. 3
0
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;
    
    tareador_ON();
    // 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
                        int j;
                        char msg[256];
                        sprintf(msg, "Copyto[i=%d]", 0);
	 	        tareador_start_task(msg);
		    for (int i=0; i<np; i++) {
                        //tareador_disable_object(&j);
    		        for (j=0; j<np; j++)
	    		    param.u[ i*np+j ] = param.uhelp[ i*np+j ];
                        //tareador_enable_object(&j);
                    }
		        tareador_end_task();
		    break;
	    case 1: // RED-BLACK
		    residual = relax_redblack(param.u, np, np);
		    break;
	    case 2: // 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;
    tareador_OFF();

    fprintf(stdout, "Time: %04.3f ", runtime);
    fprintf(stdout, "(%3.3f GFlop => %6.2f MFlop/s)\n", 
	    flop/1000000000.0,
	    flop/runtime/1000000);
    fprintf(stdout, "Convergence to residual=%f: %d iterations\n", residual, iter);

    // for plot...
    coarsen( param.u, np, np,
	     param.uvis, param.visres+2, param.visres+2 );
  
    write_image( resfile, param.uvis,  
		 param.visres+2, 
		 param.visres+2 );

    finalize( &param );

    return 0;
}
Esempio n. 4
0
int main(int argc, char **argv) {

        if (argc != 4) {
                fprintf(stderr, "Usage: %s <vector size in K> <sort size in K> <merge size in K>\n", argv[0]);
                return 1;
        }

#if _EXTRAE_
	Extrae_init();
#endif
	N = atol(argv[1]) * 1024L;
	MIN_SORT_SIZE = atol(argv[2]) * 1024L;
        MIN_MERGE_SIZE = atol(argv[3]) * 1024L;

	T *data = malloc(N*sizeof(T));
	T *tmp = malloc(N*sizeof(T));

#if _TAREADOR_
	tareador_ON();
#endif

#if _EXTRAE_
	Extrae_event(PROGRAM, INITIALIZE);
#else
	double init_time = omp_get_wtime();
#endif
	initialize(N, data);
	clear(N, tmp);
#if _EXTRAE_
	Extrae_event(PROGRAM, END);
#else
	init_time = omp_get_wtime() - init_time;
    	fprintf(stdout, "Initialization time in seconds = %g\n", init_time);
#endif

    	fprintf(stdout, "Multisort execution time using randomly generated data = ");
   	do_sort(N, data, tmp); //sort randomly generated data

#if _TAREADOR_
	tareador_OFF();
#endif

#if _EXTRAE_
	Extrae_event(PROGRAM, INITIALIZE);
	Extrae_event(PROGRAM, END);
#endif
    	fprintf(stdout, "Multisort execution time using already sorted data = ");
   	do_sort(N, data, tmp); // sort already sorted

#if _EXTRAE_
	Extrae_event(PROGRAM, INITIALIZE);
#endif
   	for (int i=0; i<N/2; i++) { // Reverse order
      		double tmp =data[N-1-i];
      		data[N-1-i] = data[i];
      		data[i]=tmp;
   	}
#if _EXTRAE_
	Extrae_event(PROGRAM, END);
#endif
    	fprintf(stdout, "Multisort execution time using reverse order data = ");
   	do_sort(N, data, tmp); //sort data in inverted order

#if _EXTRAE_
	Extrae_fini();
#endif
    	fprintf(stdout, "Multisort program finished\n");
	return 0;
}