mirror of
https://github.com/anrieff/libcpuid
synced 2025-10-13 11:10:39 +00:00
A small correction to account for the non-loop instructions in busy_sse_loop()
git-svn-id: https://svn.code.sf.net/p/libcpuid/code/HEAD/libcpuid@82 3b4be424-7ac5-41d7-8526-f4ddcb85d872
This commit is contained in:
parent
4802081283
commit
b922a5b29c
1 changed files with 6 additions and 3 deletions
|
@ -243,14 +243,15 @@ int cpu_clock_by_ic(int millis, int runs)
|
||||||
int max_value = 0, cur_value, i, ri, cycles_inner, cycles_outer, c;
|
int max_value = 0, cur_value, i, ri, cycles_inner, cycles_outer, c;
|
||||||
struct cpu_id_t* id;
|
struct cpu_id_t* id;
|
||||||
uint64_t t0, t1, tl, hz;
|
uint64_t t0, t1, tl, hz;
|
||||||
int num_instructions = 256000000;
|
int num_instructions = 256;
|
||||||
|
int sse_multiplier = 1;
|
||||||
if (millis <= 0 || runs <= 0) return -2;
|
if (millis <= 0 || runs <= 0) return -2;
|
||||||
id = get_cached_cpuid();
|
id = get_cached_cpuid();
|
||||||
if (!id || !id->flags[CPU_FEATURE_SSE]) return -1;
|
if (!id || !id->flags[CPU_FEATURE_SSE]) return -1;
|
||||||
//
|
//
|
||||||
if (!sse_is_128_bit(id)) {
|
if (!sse_is_128_bit(id)) {
|
||||||
debugf(1, "SSE execution path is 64-bit\n");
|
debugf(1, "SSE execution path is 64-bit\n");
|
||||||
num_instructions *= 2;
|
sse_multiplier = 2;
|
||||||
} else {
|
} else {
|
||||||
debugf(1, "SSE execution path is 128-bit\n");
|
debugf(1, "SSE execution path is 128-bit\n");
|
||||||
}
|
}
|
||||||
|
@ -278,7 +279,9 @@ int cpu_clock_by_ic(int millis, int runs)
|
||||||
} while (t1 - t0 < tl * (uint64_t) 8);
|
} while (t1 - t0 < tl * (uint64_t) 8);
|
||||||
// cpu_Hz = cycles_inner * cycles_outer * 256 / (t1 - t0) * 1000000
|
// cpu_Hz = cycles_inner * cycles_outer * 256 / (t1 - t0) * 1000000
|
||||||
debugf(2, "c = %d, td = %llu\n", c, t1 - t0);
|
debugf(2, "c = %d, td = %llu\n", c, t1 - t0);
|
||||||
hz = (uint64_t) cycles_inner * (uint64_t) cycles_outer * (uint64_t) c * (uint64_t) num_instructions / (t1 - t0);
|
hz = ((uint64_t) cycles_inner * (uint64_t) num_instructions + 8) *
|
||||||
|
(uint64_t) cycles_outer * (uint64_t) sse_multiplier * (uint64_t) c * (uint64_t) 1000000
|
||||||
|
/ (t1 - t0);
|
||||||
cur_value = (int) (hz / 1000000);
|
cur_value = (int) (hz / 1000000);
|
||||||
if (cur_value > max_value) max_value = cur_value;
|
if (cur_value > max_value) max_value = cur_value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue