public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Using crlibm as the default math library in GCC sources
@ 2007-11-06 19:54 Uros Bizjak
  2007-11-11 15:06 ` Richard Sandiford
  2007-11-12 18:16 ` Michael Matz
  0 siblings, 2 replies; 15+ messages in thread
From: Uros Bizjak @ 2007-11-06 19:54 UTC (permalink / raw)
  To: GCC; +Cc: Florent de Dinechin, christoph.lauter

Hello!

A little background:

Some time ago, Richard Guenther proposed that GCC imports libm math 
library from libc sources, but this proposal went nowhere, mostly due to 
non-technical reasons. At the time, the idea was that having a local 
math library, we could implement high-performance math library that will 
use SSE instructions with x86_64-like register passing convention also 
on i686-class 32bit targets. Since then, x86_64 gained soft-float 128bit 
support, but there was no 128bit libm available to fully exploit the 
potential of this high-precision infrastructure.

The proposal:

Forwarded is a short discussion with Mr. de Dinechin (forwarded with 
permission), where the possibility to import crlibm as the default gcc 
math library is discussed. I would like to ask members of the GCC SC for 
the opinion on the idea of adopting crlibm as the default math library. 
This way, the library can be compiled using all knowledge that gcc has 
about the target processor. As hinted in the attached message - 
autovectorization and perhaps recently introduced fixed-point 
infrastructure can be used effectively in the implementation of this 
library, as well as new AMD's FMA instructions.

The conclusion:

I think that including active maintained high-accuracy math library in 
GCC would be an important step to use GCC as a high-performance compiler 
in FP intensive applications.

Uros.

---forwarded message---

Hello,

We are very interested. Actually we are more and more working on 
automatic generation of libm functions, as opposed to writing the 
functions themselves. See
http://perso.ens-lyon.fr/christoph.lauter/intelportland.pdf
for a recent overview of what we have.
So our research direction is clearly towards compilers, not libraries.

However the development workforce is now reduced to one third-year PhD 
student (Christoph) and one lecturer (myself), both of whom work 
part-time on crlibm-related research. It is a small workforce for such a 
wide project. Do you think there could be some way to involve more 
people, or fund a post-doc or an engineer?

This was the political answer. More technical comments and issues below.

Uros Bizjak a écrit :
> Hello!
>
> GCC (GNU Compiler Collection) community is looking to include a libm 
> library as a part of gcc support library in future releases of gcc. 
> This way, we plan to introduce certain optimizations and enhancement 
> in FP intensive code, that can be achieved only by tightly coupling 
> the compiler and high-performance libm implementation.

We totally agree. For the kind of optimizations related to scheduling, 
such as loop pipelining etc, we have little competence, however we are 
very interested in more arithmetic optimizations, such as expression 
fusing, compile-time generation of optimized polynomial approximations,
sharing argument reduction for sin and cos of the same value, etc. 
Actually we would like to know what static information gcc would 
currently be able to provide to a floating-point optimizer.

>
> Some time ago, there was an offer from your side [1] to gradually 
> include crlibm in glibc [1]. We think, that more appropriate place for 
> this library could be directly in the compiler infrastructure, so all 
> supported targets can automatically inherit the capabilities of crlibm 
> (newlib and uClinux targets, for example).

Yes.

>
> In addition to target-dependant optimizations that can be achieved by 
> coupling crlibm and the compiler, such as:
>
> a) usage of target processor specific instructions (cmove, FMA) and 
> instruction sets (SSEn)
> b) optimal scheduling of the instructions for certain processor
> c) various target microoptimizations
>
Yes to all.

On one hand, CRLibm can be retargetted relatively easily. It already 
uses macros for the FMA which accelerate it on PowerPC and IA64 for 
instance, and it was written with sufficient dataparallelism to enable 
SSE usage, although current gcc doesn't seem to be able to exploit it 
(hint).
However it will never be efficient on targets without an FPU, for instance.

On the other hand, we are prototyping the automatic implementation of 
libm functions. It is based on the Sollya tool
http://sollya.gforge.inria.fr/
Although Sollya was never intended to be included in a compiler, it can 
be used to generate target-specific code. It still needs quite a lot of 
development, though.

> gcc currently provides the full infrastructure for soft-FP 128bit long 
> double values on a mainstream processor (x86_64). Current libm 
> implementation doesn't use this infrastructure, and there are no plans 
> to do so. Unfortunately, this locks out important segment of users 
> (fluid dynamics) that would benefit greatly from increased precision; 
> both from correct libm implementation and from increased bit widths.
>
There are two issues here. The first is using 128-bit FP to provide 
64-bit FP correctly rounded elementary functions. This is possible, but 
probably less efficient than the current approach in CRLibm (using 
double-double and triple-double).

The second is developping a 128-bit libm, either using soft 128 bit FP, 
or in an ad-hoc way (using combinations of double, double-double, 
triple-double, etc, or going fixed-point, whichever proves more 
efficient). Again, we favor the ad-hoc way, and Sollya can be used for 
that, too. Again at the cost of some development, but this is something 
that interests us.

> I would like to establish "first contact" to kindly ask you what is 
> your opinion about including your library as a default math library 
> into gcc sources, before posting formal proposal to gcc@ mailing list. 
> I think that both, gcc and crlibm could benefit from using your 
> library as a default math library in gcc compiler.
>

We totally agree. Note that there should be no problem with copyright 
transfers.

Incidentally, would there be a possibility of physically  meeting 
somewhere in Europe?

    Florent and Christoph

> [1] http://sources.redhat.com/ml/libc-alpha/2007-02/msg00007.html
>
> Looking forward to hearing from you,
> Uros.
>

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Using crlibm as the default math library in GCC sources
@ 2007-11-12 16:24 François-Xavier Coudert
  0 siblings, 0 replies; 15+ messages in thread
From: François-Xavier Coudert @ 2007-11-12 16:24 UTC (permalink / raw)
  To: fortran; +Cc: GCC Development, Uros Bizjak

Hi Uros,

It sounds like a great idea! I'm forwarding this to the Fortran list,
because I think it might raise quite some interest there also :
http://gcc.gnu.org/ml/gcc/2007-11/msg00164.html

FX

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

end of thread, other threads:[~2007-11-18  2:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-06 19:54 Using crlibm as the default math library in GCC sources Uros Bizjak
2007-11-11 15:06 ` Richard Sandiford
2007-11-12  2:34   ` Uros Bizjak
2007-11-12 10:28     ` Joe Buck
2007-11-12 18:16 ` Michael Matz
2007-11-13  8:59   ` Geert Bosch
2007-11-13 14:49     ` Michael Matz
2007-11-13 18:55       ` Geert Bosch
2007-11-15 21:31         ` Christoph Quirin Lauter
2007-11-14 14:59     ` Vincent Lefevre
2007-11-14 16:45       ` Joseph S. Myers
2007-11-17 13:41       ` Geert Bosch
2007-11-17 14:39         ` Tim Prince
2007-11-18 17:09         ` Vincent Lefevre
2007-11-12 16:24 François-Xavier Coudert

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).