public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Complex vectorization
@ 2011-03-24 11:55 Simon Chopin
  2011-03-24 12:53 ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Chopin @ 2011-03-24 11:55 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 912 bytes --]

Hi,

I'm currently working on trying to implement a way to use the SIMD
instructions of the SSEx family when computing a vector of complex
numbers.

I have to say that I have never worked on compilation techniques before,
and that I only have little understanding of the vectorization problems.

I've spent a fait amount of time reading documentation and code, and I
came to the conclusion that, at least for the multiplication and
division of complex numbers, I had to implement them as functions in the
libgcc as their scalar counterpart, __mul*c3 and __div*c3.

I face a couple of issues here : what are the C types corresponding to
the vector types, assuming they exist ?

And, also important : I understand that the processor has to be in a
certain state to use the SIMD instructions. Will it stay that way when
calling a function, thus changing partially the environment ?

Have a nice day,

Simon Chopin


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: Complex vectorization
  2011-03-24 11:55 Complex vectorization Simon Chopin
@ 2011-03-24 12:53 ` Richard Guenther
  2011-03-24 14:47   ` Simon Chopin
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2011-03-24 12:53 UTC (permalink / raw)
  To: Simon Chopin; +Cc: gcc

On Thu, Mar 24, 2011 at 12:41 PM, Simon Chopin
<chopin.simon@googlemail.com> wrote:
> Hi,
>
> I'm currently working on trying to implement a way to use the SIMD
> instructions of the SSEx family when computing a vector of complex
> numbers.
>
> I have to say that I have never worked on compilation techniques before,
> and that I only have little understanding of the vectorization problems.
>
> I've spent a fait amount of time reading documentation and code, and I
> came to the conclusion that, at least for the multiplication and
> division of complex numbers, I had to implement them as functions in the
> libgcc as their scalar counterpart, __mul*c3 and __div*c3.
>
> I face a couple of issues here : what are the C types corresponding to
> the vector types, assuming they exist ?

There are no vector of complex types and GCC internally does not handle
this case as well.  Instead GCC lowers complex operations to
piecewise scalar operations, thus vectorization would have vectors
of the complex components.  There are a number of bugs in bugzilla
for complex vectorization, like PR37021 or PR40770.

Richard.

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

* Re: Complex vectorization
  2011-03-24 12:53 ` Richard Guenther
@ 2011-03-24 14:47   ` Simon Chopin
  2011-03-24 15:46     ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Chopin @ 2011-03-24 14:47 UTC (permalink / raw)
  To: gcc

On Thu, Mar 24, 2011 at 12:55:44PM +0100, Richard Guenther wrote:
> There are no vector of complex types and GCC internally does not handle
> this case as well.  Instead GCC lowers complex operations to
Yep, sorry, my mistake. I meant array of complex.
> piecewise scalar operations, thus vectorization would have vectors
> of the complex components.  There are a number of bugs in bugzilla
> for complex vectorization, like PR37021 or PR40770.

And yet, when trying to multiply numbers, gcc says that complex isn't a
supported type. From the links you provided, part of the solution would
be to associate the complex type and the vector type of its scalar type.
While it should work for most operations, providing support for the
IMAGPART_EXPR and REALPART_EXPR, the multiplication and division
operations are implemented as separated functions of libgcc. Because of
that, they wouldn't gain from the vectorization, or I am mistaken
(again) ?

Cheers,

Simon

P.S. I am not aware of the list policy regarding the CCs, but I assumed
you were already subscribed.

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

* Re: Complex vectorization
  2011-03-24 14:47   ` Simon Chopin
@ 2011-03-24 15:46     ` Richard Guenther
  2011-03-24 21:04       ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2011-03-24 15:46 UTC (permalink / raw)
  To: gcc; +Cc: Simon Chopin

On Thu, Mar 24, 2011 at 2:50 PM, Simon Chopin
<chopin.simon@googlemail.com> wrote:
> On Thu, Mar 24, 2011 at 12:55:44PM +0100, Richard Guenther wrote:
>> There are no vector of complex types and GCC internally does not handle
>> this case as well.  Instead GCC lowers complex operations to
> Yep, sorry, my mistake. I meant array of complex.
>> piecewise scalar operations, thus vectorization would have vectors
>> of the complex components.  There are a number of bugs in bugzilla
>> for complex vectorization, like PR37021 or PR40770.
>
> And yet, when trying to multiply numbers, gcc says that complex isn't a
> supported type.

_Complex float should work.  Complex is a c99 feature and requires
you to include complex.h

> From the links you provided, part of the solution would
> be to associate the complex type and the vector type of its scalar type.
> While it should work for most operations, providing support for the
> IMAGPART_EXPR and REALPART_EXPR, the multiplication and division
> operations are implemented as separated functions of libgcc. Because of
> that, they wouldn't gain from the vectorization, or I am mistaken
> (again) ?

Multiplication is inlined for -fcx-fortran-rules for example.  Yes, division
is always out-of-line.

Richard.

> Cheers,
>
> Simon
>
> P.S. I am not aware of the list policy regarding the CCs, but I assumed
> you were already subscribed.
>

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

* Re: Complex vectorization
  2011-03-24 15:46     ` Richard Guenther
@ 2011-03-24 21:04       ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2011-03-24 21:04 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc, Simon Chopin

On 03/24/2011 07:47 AM, Richard Guenther wrote:
> Multiplication is inlined for -fcx-fortran-rules for example.  Yes, division
> is always out-of-line.

Division is inlined with -fcx-limited-range.


r~

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

end of thread, other threads:[~2011-03-24 19:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-24 11:55 Complex vectorization Simon Chopin
2011-03-24 12:53 ` Richard Guenther
2011-03-24 14:47   ` Simon Chopin
2011-03-24 15:46     ` Richard Guenther
2011-03-24 21:04       ` Richard Henderson

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