public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Can I use -Ofast without libmvec
@ 2018-03-22 18:09 Steve Ellcey
  2018-03-22 18:42 ` H.J. Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Steve Ellcey @ 2018-03-22 18:09 UTC (permalink / raw)
  To: gcc

I have a question about the math vector library routines in libmvec.
If I compile a program on x86 with -Ofast, something like:

void foo(double * __restrict x, double * __restrict y, double * __restrict z)
{
	for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
}

I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine, but
is there some way to compile with -Ofast and not use the libmvec vector
routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and -fno-
openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there anyway
to stop the use of the vectorized calls (without turning off -Ofast)?

Steve Ellcey
sellcey@cavium.com

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

* Re: Can I use -Ofast without libmvec
  2018-03-22 18:09 Can I use -Ofast without libmvec Steve Ellcey
@ 2018-03-22 18:42 ` H.J. Lu
  2018-03-22 18:48   ` Steve Ellcey
  2018-03-22 19:42 ` Andrew Senkevich
  2018-03-22 21:35 ` Jakub Jelinek
  2 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2018-03-22 18:42 UTC (permalink / raw)
  To: sellcey; +Cc: gcc

On Thu, Mar 22, 2018 at 11:08 AM, Steve Ellcey <sellcey@cavium.com> wrote:
> I have a question about the math vector library routines in libmvec.
> If I compile a program on x86 with -Ofast, something like:
>
> void foo(double * __restrict x, double * __restrict y, double * __restrict z)
> {
>         for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
> }
>
> I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine, but
> is there some way to compile with -Ofast and not use the libmvec vector
> routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and -fno-
> openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there anyway
> to stop the use of the vectorized calls (without turning off -Ofast)?

Have you tried -lm?

-- 
H.J.

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

* Re: Can I use -Ofast without libmvec
  2018-03-22 18:42 ` H.J. Lu
@ 2018-03-22 18:48   ` Steve Ellcey
  2018-03-22 18:52     ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Ellcey @ 2018-03-22 18:48 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc

On Thu, 2018-03-22 at 11:42 -0700, H.J. Lu wrote:
> On Thu, Mar 22, 2018 at 11:08 AM, Steve Ellcey <sellcey@cavium.com>
> wrote:
> > 
> > I have a question about the math vector library routines in
> > libmvec.
> > If I compile a program on x86 with -Ofast, something like:
> > 
> > void foo(double * __restrict x, double * __restrict y, double *
> > __restrict z)
> > {
> >         for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
> > }
> > 
> > I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine, but
> > is there some way to compile with -Ofast and not use the libmvec vector
> > routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and -fno-
> > openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there anyway
> > to stop the use of the vectorized calls (without turning off -Ofast)?
> Have you tried -lm?

It isn't a question of not working.  Everything works and links and
runs, but I would just like to know if there is any way to compile my
program in such a way that GCC does not generate calls to the libmvect
routines.

I am doing some performance analysis and would like to know how much
(or little) having these vectorized routines help in various
benchmarks.

Steve Ellcey

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

* Re: Can I use -Ofast without libmvec
  2018-03-22 18:48   ` Steve Ellcey
@ 2018-03-22 18:52     ` Richard Biener
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2018-03-22 18:52 UTC (permalink / raw)
  To: sellcey, Steve Ellcey, H.J. Lu; +Cc: gcc

On March 22, 2018 7:48:33 PM GMT+01:00, Steve Ellcey <sellcey@cavium.com> wrote:
>On Thu, 2018-03-22 at 11:42 -0700, H.J. Lu wrote:
>> On Thu, Mar 22, 2018 at 11:08 AM, Steve Ellcey <sellcey@cavium.com>
>> wrote:
>> > 
>> > I have a question about the math vector library routines in
>> > libmvec.
>> > If I compile a program on x86 with -Ofast, something like:
>> > 
>> > void foo(double * __restrict x, double * __restrict y, double *
>> > __restrict z)
>> > {
>> >         for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
>> > }
>> > 
>> > I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine,
>but
>> > is there some way to compile with -Ofast and not use the libmvec
>vector
>> > routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and
>-fno-
>> > openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there
>anyway
>> > to stop the use of the vectorized calls (without turning off
>-Ofast)?
>> Have you tried -lm?
>
>It isn't a question of not working.  Everything works and links and
>runs, but I would just like to know if there is any way to compile my
>program in such a way that GCC does not generate calls to the libmvect
>routines.
>
>I am doing some performance analysis and would like to know how much
>(or little) having these vectorized routines help in various
>benchmarks.

Not from the GCC side I think. Maybe look into the glibc headers if there's some macro tricks you can pull off. 

Richard. 

>Steve Ellcey

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

* Re: Can I use -Ofast without libmvec
  2018-03-22 18:09 Can I use -Ofast without libmvec Steve Ellcey
  2018-03-22 18:42 ` H.J. Lu
@ 2018-03-22 19:42 ` Andrew Senkevich
  2018-03-22 21:35 ` Jakub Jelinek
  2 siblings, 0 replies; 7+ messages in thread
From: Andrew Senkevich @ 2018-03-22 19:42 UTC (permalink / raw)
  To: sellcey; +Cc: gcc

2018-03-22 19:08 GMT+01:00 Steve Ellcey <sellcey@cavium.com>:
> I have a question about the math vector library routines in libmvec.
> If I compile a program on x86 with -Ofast, something like:
>
> void foo(double * __restrict x, double * __restrict y, double * __restrict z)
> {
>         for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
> }
>
> I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine, but
> is there some way to compile with -Ofast and not use the libmvec vector
> routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and -fno-
> openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there anyway
> to stop the use of the vectorized calls (without turning off -Ofast)?

It looks you have Glibc version >= 2.23 and GCC >= 6.1?
-fno-tree-loop-vectorize may help together with -fno-openmp for GCC >= 6.1.

Or build your test agains Glibc built with disabled Libmvec.

(some description of Libmvec is here -
https://sourceware.org/glibc/wiki/libmvec)


--
WBR,
Andrew

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

* Re: Can I use -Ofast without libmvec
  2018-03-22 18:09 Can I use -Ofast without libmvec Steve Ellcey
  2018-03-22 18:42 ` H.J. Lu
  2018-03-22 19:42 ` Andrew Senkevich
@ 2018-03-22 21:35 ` Jakub Jelinek
  2018-03-23 12:40   ` Richard Biener
  2 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2018-03-22 21:35 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: gcc

On Thu, Mar 22, 2018 at 11:08:58AM -0700, Steve Ellcey wrote:
> I have a question about the math vector library routines in libmvec.
> If I compile a program on x86 with -Ofast, something like:
> 
> void foo(double * __restrict x, double * __restrict y, double * __restrict z)
> {
> 	for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
> }
> 
> I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine, but
> is there some way to compile with -Ofast and not use the libmvec vector
> routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and -fno-
> openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there anyway
> to stop the use of the vectorized calls (without turning off -Ofast)?

Why do you want to avoid that?  You could use -Ofast -U__FAST_MATH__, because then
glibc headers won't use the simd attribute, but you won't get the finite
stuff either etc.
Or you can use use
double my_sin (double) __asm ("sin");
and use my_sin instead of sin.

	Jakub

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

* Re: Can I use -Ofast without libmvec
  2018-03-22 21:35 ` Jakub Jelinek
@ 2018-03-23 12:40   ` Richard Biener
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2018-03-23 12:40 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Steve Ellcey, gcc

On Thu, Mar 22, 2018 at 7:47 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Mar 22, 2018 at 11:08:58AM -0700, Steve Ellcey wrote:
>> I have a question about the math vector library routines in libmvec.
>> If I compile a program on x86 with -Ofast, something like:
>>
>> void foo(double * __restrict x, double * __restrict y, double * __restrict z)
>> {
>>       for (int i = 0; i < 1000; i++) x[i] = sin(y[i]);
>> }
>>
>> I get a call to the vector sin routine _ZGVbN2v_sin.  That is fine, but
>> is there some way to compile with -Ofast and not use the libmvec vector
>> routines?  I have tried -fopenmp, -fopenmp-simd, -fno-openmp, and -fno-
>> openmp-simd and I always get a call to _ZGVbN2v_sin.  Is there anyway
>> to stop the use of the vectorized calls (without turning off -Ofast)?
>
> Why do you want to avoid that?  You could use -Ofast -U__FAST_MATH__, because then
> glibc headers won't use the simd attribute, but you won't get the finite
> stuff either etc.
> Or you can use use
> double my_sin (double) __asm ("sin");
> and use my_sin instead of sin.

Or you can

#define __simd__ foobaz

and deal with "unknown attribute foobaz" warnings.

Richard.

>         Jakub

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

end of thread, other threads:[~2018-03-23 12:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 18:09 Can I use -Ofast without libmvec Steve Ellcey
2018-03-22 18:42 ` H.J. Lu
2018-03-22 18:48   ` Steve Ellcey
2018-03-22 18:52     ` Richard Biener
2018-03-22 19:42 ` Andrew Senkevich
2018-03-22 21:35 ` Jakub Jelinek
2018-03-23 12:40   ` 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).