Created
June 1, 2021 23:38
-
-
Save albinahlback/b4a5ffc01c2d4b1b9629cf30187a4e88 to your computer and use it in GitHub Desktop.
Profiling for xgcd in Flint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "flint/flint.h" | |
#include "flint/fmpz.h" | |
#include "flint/profiler.h" | |
int main(int argc, char* argv[]) | |
{ | |
timeit_t clock; | |
fmpz_t d, x, y, a, b; | |
slong const min = strtol(argv[1], NULL, 10); | |
slong const max = strtol(argv[2], NULL, 10); | |
fmpz_init(d); | |
fmpz_init(x); | |
fmpz_init(y); | |
fmpz_init(a); | |
fmpz_init(b); | |
timeit_start(clock); | |
for (slong ix = min; ix < max; ix++) | |
{ | |
fmpz_set_si(a, ix); | |
for (slong iy = min; iy < max; iy++) | |
{ | |
fmpz_set_si(b, iy); | |
fmpz_xgcd_canonical_bezout2(d, x, y, a, b); | |
} | |
} | |
timeit_stop(clock); | |
flint_printf("cpu: %wd\nwall: %wd\n\n", clock->cpu, clock->wall); | |
timeit_start(clock); | |
for (slong ix = min; ix < max; ix++) | |
{ | |
fmpz_set_si(a, ix); | |
for (slong iy = min; iy < max; iy++) | |
{ | |
fmpz_set_si(b, iy); | |
fmpz_xgcd_canonical_bezout(d, x, y, a, b); | |
} | |
} | |
timeit_stop(clock); | |
flint_printf("cpu: %wd\nwall: %wd\n\n", clock->cpu, clock->wall); | |
timeit_start(clock); | |
for (slong ix = min; ix < max; ix++) | |
{ | |
fmpz_set_si(a, ix); | |
for (slong iy = min; iy < max; iy++) | |
{ | |
fmpz_set_si(b, iy); | |
fmpz_xgcd(d, x, y, a, b); | |
} | |
} | |
timeit_stop(clock); | |
flint_printf("cpu: %wd\nwall: %wd\n\n", clock->cpu, clock->wall); | |
fmpz_clear(d); | |
fmpz_clear(x); | |
fmpz_clear(y); | |
fmpz_clear(a); | |
fmpz_clear(b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment