public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* libmvec in gcc to have vector math in fortran
@ 2018-04-10 10:14 Szabolcs Nagy
  2018-04-10 10:22 ` Janne Blomqvist
  0 siblings, 1 reply; 22+ messages in thread
From: Szabolcs Nagy @ 2018-04-10 10:14 UTC (permalink / raw)
  To: GCC Development, fortran, Steve Ellcey; +Cc: nd

i had a query earlier about libmvec vector functions in fortran:
https://gcc.gnu.org/ml/gcc/2017-11/msg00007.html

but there were no simple solutions to make math functions vectorizable
in fortran, because it's hard to make libc headers with simd attributes
visible to the fortran front end.

i think a possible workaround is to have a dummy libmvec implementation
in libgcc.a (or more likely as a separate libgccmvec.a) that just calls
scalar functions from libm like

vdouble _ZGVbN2v_sin(vdouble x)
{
   return (vdouble){sin(x[0]), sin(x[1])};
}

and similarly for all relevant single and double precision functions
for all vector lengths and other supported variants.

then gcc knows that there is an implementation for these functions
available and with the right link order a better implementation from
libmvec can override these dummy implementations. (the cost model
cannot assume a faster vector algorithm than the scalar one though)

- this allows vectorizing loops with math functions even in fortran,
- and on targets without a libmvec implementation (but with a vector abi),
- and allows users to provide their own vector math implementation
more easily without hacking around glibc math.h (which may not support
vector math or only enable it for a small subset of math functions).

gcc needs a new cflag and ldflag to enable this.
(maybe -mveclibabi= already present in x86 and ppc can be used for this)

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-06-18 16:02 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10 10:14 libmvec in gcc to have vector math in fortran Szabolcs Nagy
2018-04-10 10:22 ` Janne Blomqvist
2018-04-10 11:35   ` Szabolcs Nagy
2018-04-10 12:55     ` Jakub Jelinek
2018-04-10 13:26       ` Richard Biener
2018-04-10 13:42         ` Jakub Jelinek
2018-04-10 13:27           ` Richard Biener
2018-04-10 13:35           ` Richard Biener
2018-04-18  8:41             ` Szabolcs Nagy
2018-04-18  8:57               ` Richard Biener
2018-06-14 22:41           ` Richard Biener
2018-06-15  8:39             ` Florian Weimer
2018-06-15  8:40               ` Szabolcs Nagy
2018-06-15  9:08                 ` Richard Biener
2018-06-15  8:41               ` Richard Biener
2018-06-15  9:33                 ` Florian Weimer
2018-06-15 11:39                   ` Richard Biener
2018-06-15 20:59                     ` Thomas Koenig
2018-06-15 22:41                       ` Joseph Myers
2018-06-18 11:10                         ` Richard Biener
2018-06-18 16:02                           ` Joseph Myers
2018-06-18 16:22                             ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).