[PTLsim-devel] why there is diference between cycles???
L.Yan
Tue Oct 23 01:28:08 EDT 2007
Dear all,
I have successfully run PTLsim in my computer. my OS is Fedora 6 and gcc
is 4.1.2 and the kernel of my computer is 32bits.
First, I set the options in the .conf file, as the following,
-stats test.stats -trigger
then, I using gcc get the binary excution code, test. all is fine,
but I got different clock cyclyes of the program running.
The first time , the result as following,
[user at EMBED ptlsim]$ ./ptlsim ./test
copy_args_env_auxv: Disabled 32-bit AT_SYSINFO auxv
copy_args_env_auxv: Disabled 32-bit AT_SYSINFO auxv
//
// PTLsim: Cycle Accurate x86 Simulator (32-bit version)
// Copyright 1999-2007 Matt T. Yourst <yourst at yourst.com>
//
// Revision 225 (2007-09-22)
// Built Oct 22 2007 11:26:32 on using gcc-4.1
// Running on EMBED.(none)
//
// Arguments: ./test
// Thread 726 is running in 32-bit x86 mode
//
Switching to simulation core 'smt'...
Stopping after 9223372036854775807 commits
Stopped after 42881 cycles, 29909 instructions and 0 seconds of sim time
(0 Hz sim rate)
The cycles is 42881, and then I run it again, the result as following:
[user at EMBED ptlsim]$ ./ptlsim ./test
copy_args_env_auxv: Disabled 32-bit AT_SYSINFO auxv
copy_args_env_auxv: Disabled 32-bit AT_SYSINFO auxv
//
// PTLsim: Cycle Accurate x86 Simulator (32-bit version)
// Copyright 1999-2007 Matt T. Yourst <yourst at yourst.com>
//
// Revision 225 (2007-09-22)
// Built Oct 22 2007 11:26:32 on using gcc-4.1
// Running on EMBED.(none)
//
// Arguments: ./test
// Thread 728 is running in 32-bit x86 mode
//
Switching to simulation core 'smt'...
Stopping after 9223372036854775807 commits
Stopped after 43157 cycles, 29909 instructions and 0 seconds of sim time
(0 Hz sim rate)
Oh, the cycles is 43157, not 42881, why?? I got the native frequencies
from the above test.stats files, both of them are 2992000000. would you
like to help clear the difference between cycles.
BTW, If I want to get the high accurate run time, I use the cycles
number 43157/2992000000 (the native frequency) = 14.424131016
mircoseconds. Is it right??
Any suggestions from you are greatly appreciated. Thanks.
Best wishes,
Peter
P.S. my test program as following:
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include "./../ptlcalls.h"
void run(int* pData,int left,int right)
{
int i,j;
int middle,iTemp;
i = left;
j = right;
middle = pData[(left+right)/2]; //求中间值
do{
while((pData[i]<middle) && (i<right))//从左扫描大于中值的数
i++;
while((pData[j]>middle) && (j>left))//从右扫描大于中值的数
j--;
if(i<=j)//找到了一对值
{
//交换
iTemp = pData[i];
pData[i] = pData[j];
pData[j] = iTemp;
i++;
j--;
}
}while(i<=j);//如果两边扫描的下标交错,就停止(完成一次)
//当左边部分有值(left<j),递归左半边
if(left<j)
run(pData,left,j);
//当右边部分有值(right>i),递归右半边
if(right>i)
run(pData,i,right);
}
void QuickSort(int* pData,int Count)
{
run(pData,0,Count-1);
}
int main(int args, char**argv)
{
int i=0;
//linStart = ((long long)(tvStart.tv_sec)) * 1000000 +
tvStart.tv_usec;
ptlcall_switch_to_sim();
for(; i<10; i++){
// ptlcall_switch_to_sim();
int data[] = {10,9,8,7,6,5,4, 12, 8, 87, 57, 49, 54, 7,6, 94,
57, 61, 31, 13, 25, 78, 69};
QuickSort(data, 23);
}
ptlcall_switch_to_native();
/* gettimeofday(&tvEnd, NULL);
linEnd = ((long long)(tvEnd.tv_sec))*1000000 + tvEnd.tv_usec;
// printf("completed\n");
printf("%10ld micro-seconds\n", (linEnd-linStart));
// }
// else
// printf("error\n");*/
return 0;
}
More information about the PTLsim-devel mailing list