void display (int rows, int columns, long *outputArray, double *startTime, long *countIn, long *countOut)
{
	int 				i, j, k = 0;
	Types_Timestamp64	endTime64;
	Types_FreqHz		freq;
	unsigned long long	endClockCycles;
	double				endTime, timeTaken;

	unsigned long		required = 1000000;

	Timestamp_get64(&endTime64);
	Timestamp_getFreq(&freq);
	endClockCycles = ((endTime64.hi*4294967296) + endTime64.lo);
	endTime = ((endClockCycles/(double)freq.lo));
	timeTaken = endTime - *startTime;

	if (*countIn == required - 1)
	{
/*		printf ("\nResulting Array: \n");
		for (i = 0; i < rows; i++)
		{
			for (j = 0; j < columns; j++)
			{
				printf("%ld\t", *((outputArray+i*columns) + j));
			}
			printf("\n");
		}
*/
		printf("\n%ld loop(s) accumulating square matrices of size %d took %fs\n", required, rows , timeTaken);
		exit(0);
	}

	*countOut = *countIn + 1;

}
void display (int rowsA, int columnsB, long *arrayC, double *startTime)
{
	int 				i, j = 0;
	Types_Timestamp64	endTime64;
	Types_FreqHz		freq;
	unsigned long long	endClockCycles;
	double				endTime, timeTaken;

	Timestamp_get64(&endTime64);
	Timestamp_getFreq(&freq);
	endClockCycles = ((endTime64.hi * 4294967296) + endTime64.lo);
	endTime = (endClockCycles/(double)freq.lo);
	timeTaken = endTime - *startTime;

/*
	printf ("\nResulting Array: \n");

	for (i = 0; i < rowsA; i++)
	{
		for (j = 0; j < columnsB; j++)
		{
			printf("%ld\t", *(arrayC+((i*columnsB) + j)));
		}
		printf("\n");
	}
*/

	printf("\nMultiplication of %d square matrices took %fs and %llu clock cycles\n", rowsA, timeTaken, endClockCycles);

	exit(0);
}
void generate (int rowsA, int columnsA, int rowsB, int columnsB, long *arrayA, long *arrayB, double *startTime)
{
	printf("\n\nCross Core Multiplication Beginning\n");	// Print information message

	int generationCount = 1;		// Used in generation of the arrays
	int i, j = 0;					// Used to count rows and columns of the arrays
	Types_Timestamp64	startTime64;	// 64 bit timestamp
	Types_FreqHz		freq;			// frequency of cores

	for (i = 0; i < rowsA; i++)			// Generate array A
	{
		for (j = 0; j < columnsA; j++)
		{
			*((arrayA+i*columnsA) + j) = (generationCount);		// Initialise arrayA
		}
		generationCount++;
	}

	generationCount = 1;

	for (i = 0; i < rowsB; i++)			// Generate array B
	{
		for (j = 0; j < columnsB; j++)
		{
			*((arrayB+i*columnsB) + j) = (generationCount);		// Initialise arrayB
		}
		generationCount++;
	}

	Timestamp_getFreq(&freq);		// Get the frequency of the cores
	Timestamp_get64(&startTime64);	// Get the starting timestamp
	*startTime = ((startTime64.lo/(double)freq.lo));	// Calculate a time in seconds for use in timestamping
}
示例#4
0
UInt64 Utils_prfTsGet64()
{
    Types_Timestamp64 ts64;
    UInt64 curTs;

    Timestamp_get64(&ts64);

    curTs = ((UInt64) ts64.hi << 32) | ts64.lo;

    return curTs;
}
示例#5
0
文件: wiring.c 项目: energia/emt
/*
 *  ======== micros ========
 */
unsigned long micros(void)
{
    Types_FreqHz freq;
    Types_Timestamp64 time;
    uint64_t t64;

    Timestamp_getFreq(&freq);
    Timestamp_get64(&time);
    t64 = ((uint64_t)time.hi << 32) | time.lo;
    return (t64/(freq.lo/1000000));
}
示例#6
0
/*
 *  ======== taskLoad ========
 */
Void taskLoad(Void)
{
    Bool flag;
    Types_Timestamp64 startTime;
    Types_Timestamp64 currentTime;
    Types_FreqHz freq;
    UInt32 count;
    Int loops;

    /* Have this task use ~50% of the CPU */
    Timestamp_getFreq(&freq);
    count = freq.lo / 1000 / 1000 * (Clock_tickPeriod/ 2);

    while (TRUE) {        
        Semaphore_pend(loadSem, BIOS_WAIT_FOREVER);        

        Log_write1(UIABenchmark_start, (xdc_IArg)"running");
        Timestamp_get64(&startTime);

        flag = TRUE;
        loops = 0;

        while (flag == TRUE) {
            Timestamp_get64(&currentTime);

            loops++;

            // TODO deal with wrap
            if (startTime.lo + count <= currentTime.lo) {
                flag = FALSE;
                Log_write1(UIABenchmark_stop, (xdc_IArg)"running");                
                Log_write1(UIABenchmark_stop, (xdc_IArg)"whole");
            }
        }
    }
}
void generate (int rowsA, int columnsA, int rowsB, int columnsB, long *arrayA, long *arrayB, double *startTime)
{
	// !!! TODO: add checking around the matrices size

	printf("\n\nCross core multiplication beginning of %d square matrices\n", rowsA);

	int 				generationCount = 1;
	Types_Timestamp64	startTime64;
	Types_FreqHz		freq;

	unsigned int generateEndTime;
	int i, j = 0;

	for (i = 0; i < rowsA; i++)			// Generate array A
	{
		for (j = 0; j < columnsA; j++)
		{
			*(arrayA+((i*columnsA) + j)) = (generationCount);
		}
		generationCount++;
	}

	generationCount = 1;

	for (i = 0; i < rowsB; i++)			// Generate array B
	{
		for (j = 0; j < columnsB; j++)
		{
			*(arrayB+((i*columnsB) + j)) = (generationCount);
		}
		generationCount++;
	}

	Timestamp_getFreq(&freq);
	Timestamp_get64(&startTime64);
	*startTime = ((startTime64.lo/(double)freq.lo));
}