https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97571
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #7 from kargl at gcc dot gnu.org ---
(In reply to Mark J Olah from comment #5)
>
> A quick test shows I can compute ACOS of 10^8 elements in less than a second
> on any reasonable hardware. We are talking about only 32k elements here,
> which should be trivial.
>
Without see your code for your quick test, I'll proffer that
you were doing floating point math with hardware FPU support.
gfortran's internal representation of an integer is a GMP
mpz_t type. For a real type, gfortran uses an MPFR mpfr_t type.
Your array constructor [(i, i=0, i=100000)] creates an array
of 100001 gfc_expr nodes, which contain GMP types. Each of
these are then converted to an mpfr_t type and divided by a
gfc_expr node containing an mpfr_t type for 100000.0, so that
you now have an array of 100001 gfc_expr nodes with mpfr_t entities.
Each of these mpfr_t entities is then used as an actual argument
to mpfr_acos() from the MPFR library. IOW, gfortran is doing
floating point arithmetic with a software implementation, which
guarantees correctly rounded values (in round-to-nearest mode).
Yes, it is slow. But, at least, you get the correct result.