[benchmarks] Use volatile variables in bench_sincos
In addition to fixing -Wdouble-promition issues in bench_sincos, this also ensures that the compiler can't replace the calls to sin/cos/sqrt with a compile-time constant.
This commit is contained in:
committed by
Travis Geiselbrecht
parent
99bf8f9c41
commit
00f7060ba9
@@ -201,34 +201,36 @@ __NO_INLINE static void arm_bench_multi_issue(void) {
|
||||
__NO_INLINE static void bench_sincos(void) {
|
||||
printf("touching the floating point unit\n");
|
||||
__UNUSED volatile double _hole = sin(0);
|
||||
volatile float input_f = 1234567.0f;
|
||||
volatile double input_d = 1234567.0;
|
||||
|
||||
ulong count = arch_cycle_count();
|
||||
__UNUSED double a = sin(2.0);
|
||||
__UNUSED volatile double d = sin(input_d);
|
||||
count = arch_cycle_count() - count;
|
||||
printf("took %lu cycles for sin()\n", count);
|
||||
|
||||
count = arch_cycle_count();
|
||||
a = cos(2.0);
|
||||
d = cos(input_d);
|
||||
count = arch_cycle_count() - count;
|
||||
printf("took %lu cycles for cos()\n", count);
|
||||
|
||||
count = arch_cycle_count();
|
||||
a = sinf(2.0);
|
||||
__UNUSED volatile float f = sinf(input_f);
|
||||
count = arch_cycle_count() - count;
|
||||
printf("took %lu cycles for sinf()\n", count);
|
||||
|
||||
count = arch_cycle_count();
|
||||
a = cosf(2.0);
|
||||
f = cosf(input_f);
|
||||
count = arch_cycle_count() - count;
|
||||
printf("took %lu cycles for cosf()\n", count);
|
||||
|
||||
count = arch_cycle_count();
|
||||
a = sqrt(1234567.0);
|
||||
d = sqrt(input_d);
|
||||
count = arch_cycle_count() - count;
|
||||
printf("took %lu cycles for sqrt()\n", count);
|
||||
|
||||
count = arch_cycle_count();
|
||||
a = sqrtf(1234567.0f);
|
||||
f = sqrtf(input_f);
|
||||
count = arch_cycle_count() - count;
|
||||
printf("took %lu cycles for sqrtf()\n", count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user