Esempio n. 1
0
/* Steps in program: determine the number of iterations of desired
 * function required to get a measurement interval of the desired
 * length, allocate vectors of that size, initialize to appropriate
 * values for both the related and random scenarios, make the runs,
 * output the results. */
main()
{
    int i,itercount;
    unsigned ccount;
    
    /* The next two lines are just a sanity check -- particularly
       useful when trying on a new platform. Can comment out when
       doing repeated runs thereafter. */
    /* display_CPUspeed();
    printf("Cycle threshold for measurements: %.2f (millions)\n\n", 
    (double) CMIN / 1e6);  */

    itercount = measurecnt();
    printf("Measuring using %d iterations\n",itercount);

    /* allocate arrays for both scenarios */
    allocarrays(itercount);
    
    /* initialize arrays for scenario 1: valA[i] < valB[i] */
    initarrays1(itercount);
    
    /* do multiple runs for this scenario, recording each */
    clearlist();
    for (i = 0; i < MEASMAX; i++)
    {
	ccount = measure(itercount);
	addtolist(ccount);
    }

    /* test and output best */
    printf("Cycles per function call, predictable branches\n");
    testbest();

    /* initialize arrays for scenario 2: valA[i] ? valB[i] */
    initarrays2(itercount);
    
    /* do multiple runs for this scenario, recording each */
    clearlist();
    for (i = 0; i < MEASMAX; i++)
    {
	ccount = measure(itercount);
	addtolist(ccount);
    }

    /* test and output best */
    printf("Cycles per function call, unpredictable branches\n");
    testbest();
}
Esempio n. 2
0
/* driver for everything: for current vector and operation types,
 * run through entire range of vector lengths, making repeated
 * measurements of each, then determine slope of line that best
 * matches data, and finally output results as CPE. */
main()
{
    int i,j;
    unsigned ccount;
    
    /* The next two lines are just a sanity check -- particularly
       useful when trying on a new platform. Can comment out when
       doing repeated runs thereafter. */
    /* display_CPUspeed();
    printf("Cycle threshold for measurements: %.2f (millions)\n\n", 
    (double) CMIN / 1e6);  */

    clearmaster();
    initvlen();
    for (i = 2; i <= VECMAX; i = i << 1)
    {
	/* printf("Vector length: %d\n",i);  for debugging */
	setupvectors(i);
	clearlist();
	/* do multiple runs for this vector length, recording each */
	for (j = 0; j < MEASMAX; j++)
	{
	    ccount = measure();
	    addtolist(ccount);
	}
	testbest();
	addtomaster();  /* record best time in master list */
    }
    /* dumpmaster();      for debugging */
    lsfit();	       /* do linear fit */
}