Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-ide
Commits
83801940
Commit
83801940
authored
Jun 28, 2006
by
John van Groningen
Browse files
port to 64 bit windows
parent
48ef631f
Changes
1
Hide whitespace changes
Inline
Side-by-side
TimeProfile/cpuspeed.c
View file @
83801940
...
...
@@ -9,6 +9,7 @@
#define CPUID _asm _emit 0x0f _asm _emit 0xa2
#define RDTSC _asm _emit 0x0f _asm _emit 0x31
#ifndef _WIN64
static
int
has_time_stamp_counter
(
void
)
{
_asm
{
...
...
@@ -58,6 +59,19 @@ _asm{
pop
ecx
}
}
#else
unsigned
__int64
__rdtsc
(
void
);
#pragma intrinsic(__rdtsc)
#endif
# ifdef _WIN64
__int64
p_time
=
0
;
int
g_time_hi
=
0
,
g_time_lo
=
0
;
extern
void
compute_profile_overhead
(
LARGE_INTEGER
*
large_int_p
);
# else
int
p_time_hi
=
0
,
p_time_lo
=
0
,
g_time_hi
=
0
,
g_time_lo
=
0
;
...
...
@@ -144,6 +158,8 @@ compute_profile_overhead_lp2:
}
}
# endif
#else
extern
int
has_time_stamp_counter
(
void
);
...
...
@@ -152,6 +168,9 @@ extern void compute_profile_overhead (LARGE_INTEGER *);
#endif
#ifdef _WIN64
# define float_div(a,b) ((a)/(b))
#else
double
float_div
(
double
a
,
double
b
)
{
_asm
{
...
...
@@ -159,6 +178,7 @@ double float_div (double a,double b)
fdiv
b
}
}
#endif
#define N_TIME_SAMPLES 40
#define N_PROFILE_SAMPLES 40
...
...
@@ -262,12 +282,20 @@ static double determine_cpu_clock_speed (double frequency)
QueryPerformanceCounter
(
&
begin_time0
);
do
{
QueryPerformanceCounter
(
&
begin_time
);
#ifdef _WIN64
tsc_begin_time
.
QuadPart
=
__rdtsc
();
#else
read_time_stamp_counter
(
&
tsc_begin_time
);
#endif
}
while
(
begin_time0
.
HighPart
==
begin_time
.
HighPart
&&
begin_time0
.
LowPart
==
begin_time
.
LowPart
);
do
{
QueryPerformanceCounter
(
&
end_time
);
#ifdef _WIN64
tsc_end_time
.
QuadPart
=
__rdtsc
();
#else
read_time_stamp_counter
(
&
tsc_end_time
);
#endif
}
while
(
(
end_time
.
HighPart
==
begin_time
.
HighPart
)
?
(
end_time
.
LowPart
-
begin_time
.
LowPart
<
N_TICKS
)
:
(
end_time
.
HighPart
==
begin_time
.
HighPart
+
1
&&
end_time
.
LowPart
-
(
unsigned
)
N_TICKS
<
begin_time
.
LowPart
));
...
...
@@ -358,6 +386,7 @@ static void set_thread_priority (HANDLE thread_handle,int old_priority,int new_p
static
void
init_fpu
(
void
)
{
#ifndef _WIN64
_asm
{
finit
fldz
...
...
@@ -368,6 +397,7 @@ static void init_fpu (void)
fldz
fldz
}
#endif
}
int
measure_clock_speed_and_profile_overhead
(
double
*
clock_speed_p
,
double
*
profile_overhead_p
)
...
...
@@ -377,12 +407,14 @@ int measure_clock_speed_and_profile_overhead (double *clock_speed_p,double *prof
HANDLE
thread_handle
;
int
priority
;
#ifndef _WIN64
if
(
!
has_time_stamp_counter
()){
*
clock_speed_p
=
0
.
0
;
*
profile_overhead_p
=
0
.
0
;
init_fpu
();
/* for virtualpc */
return
1
;
}
#endif
thread_handle
=
GetCurrentThread
();
priority
=
GetThreadPriority
(
thread_handle
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment