diff options
author | David Monniaux <David.Monniaux@univ-grenoble-alpes.fr> | 2022-03-07 16:21:13 +0100 |
---|---|---|
committer | David Monniaux <David.Monniaux@univ-grenoble-alpes.fr> | 2022-03-07 16:21:13 +0100 |
commit | 25e82e849de35eaef24412b468d3a36c72f4fcb6 (patch) | |
tree | e6abc778dfa37ac5df55c8b0926ed681b9c04f04 /test/monniaux | |
parent | ab776cd94e000d07c4d14521a8d0c635d3b8412c (diff) | |
parent | 2d9138547d93c32c0ec5ae54b4afc022f5c434ff (diff) | |
download | compcert-kvx-25e82e849de35eaef24412b468d3a36c72f4fcb6.tar.gz compcert-kvx-25e82e849de35eaef24412b468d3a36c72f4fcb6.zip |
Merge remote-tracking branch 'origin/kvx_fp_division' into kvx-work
Diffstat (limited to 'test/monniaux')
-rw-r--r-- | test/monniaux/division/compare_timings.c | 67 | ||||
l--------- | test/monniaux/division/cycles.h | 1 |
2 files changed, 68 insertions, 0 deletions
diff --git a/test/monniaux/division/compare_timings.c b/test/monniaux/division/compare_timings.c new file mode 100644 index 00000000..15195d3e --- /dev/null +++ b/test/monniaux/division/compare_timings.c @@ -0,0 +1,67 @@ +#include <stdint.h> +#include <stdio.h> +#include <inttypes.h> +#include "cycles.h" + +#define CHECKS(mode, quotient) \ +void checks_##mode() { \ + uint64_t checksum=UINT64_C(0), \ + a=UINT64_C(0x10000000000), \ + b=UINT64_C(0x1000); \ + for(int i=0; i<10000; i++) { \ + uint64_t q = (quotient); \ + a += UINT64_C(0x36667); \ + b += UINT64_C(0x13); \ + checksum += q; \ + } \ + printf("checksum = %" PRIx64 "\n", checksum); \ +} + +#define CHECKS2(mode, quotient) \ +void checks2_##mode() { \ + uint64_t checksum=UINT64_C(0), \ + a=UINT64_C(0x10000000000), \ + b=UINT64_C(0x1000); \ + for(int i=0; i<5000; i++) { \ + uint64_t q = (quotient); \ + a += UINT64_C(0x36667); \ + b += UINT64_C(0x13); \ + checksum += q; \ + q = (quotient); \ + a += UINT64_C(0x36667); \ + b += UINT64_C(0x13); \ + checksum += q; \ + } \ + printf("checksum = %" PRIx64 "\n", checksum); \ +} + +CHECKS(normal, a/b) +CHECKS(fp, __builtin_fp_udiv64(a, b)) + +CHECKS2(normal, a/b) +CHECKS2(fp, __builtin_fp_udiv64(a, b)) + +int main() { + cycle_t start, stop; + cycle_count_config(); + + start = get_cycle(); + checks_normal(); + stop = get_cycle(); + printf("normal division: %" PRcycle " cycles\n", stop-start); + + start = get_cycle(); + checks_fp(); + stop = get_cycle(); + printf("fp division: %" PRcycle " cycles\n", stop-start); + + start = get_cycle(); + checks2_normal(); + stop = get_cycle(); + printf("normal division x2: %" PRcycle " cycles\n", stop-start); + + start = get_cycle(); + checks2_fp(); + stop = get_cycle(); + printf("fp division x2: %" PRcycle " cycles\n", stop-start); +} diff --git a/test/monniaux/division/cycles.h b/test/monniaux/division/cycles.h new file mode 120000 index 00000000..84e54d21 --- /dev/null +++ b/test/monniaux/division/cycles.h @@ -0,0 +1 @@ +../cycles.h
\ No newline at end of file |