public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Cree <mcree@orcon.net.nz>
To: David Malcolm <dmalcolm@redhat.com>
Cc: jit@gcc.gnu.org
Subject: Re: [committed] Fix crash accessing builtins in sanitizer.def and after (PR jit/82174)
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <20171004194959.flx5vlneyrpjqr5t@tower> (raw)
In-Reply-To: <1507125375.2654.60.camel@redhat.com>

On Wed, Oct 04, 2017 at 09:56:15AM -0400, David Malcolm wrote:
> On Sun, 2017-09-17 at 22:05 +1200, Michael Cree wrote:
> > On Thu, Sep 14, 2017 at 04:09:34PM -0400, David Malcolm wrote:
> > > Calls to gcc_jit_context_get_builtin_function that accessed
> > > builtins
> > > in sanitizer.def and after (or failed to match any builtin) led to
> > > a crash accessing a NULL builtin name.
> > 
> >   [snip]
> > > This patch updates jit-builtins.c to cope with such entries, fixing
> > > the
> > > crash.
> > 
> > Thanks for fixing that.
> > 
> > I would now like to get access to the architecture specific builtins.
> > Any possibility of that being implemented into libgccjit?  My project
> > is basically dead in the water without them.
> 
> I looked at doing that, but it's a little tricky:

That's a bummer.  The gcc vector optimiser will vectorise standard
operators but unfortunately is rather limited.  It did not, for
example, understand my attempt to implement saturating arithmetic
and proceeded to vectorise every individual operation rather than
replace the sequence with one saturating arithmetic instruction.

If the compiler knew more operators than the standard arithmetic and
logical operations, i.e., if it had a means of specifying min/max
operations and saturating arithmetic operations, and the vector
optimiser then did the conversion to machine specific SIMD
instructions, that would go quite a long way to assisting me.

Doing complex, real/complex and imaginary/complex multiplication
could be really useful to implement generating specific FFTs on the
fly.  I see gcc jit does support the C99 _Complex float/double type
so I must check whether the vector optimiser can produce good SIMD
code for complex arithmetic.  If it doesn't I would probably be back
to wanting machine specific builtins again as some architectures
implement CPU instructions to assist complex multiplication.

> > Secondly, I am trying to work out how to initialise a vector rvalue
> > with specified values.  Something in the vein of
> > gcc_jit_new_rvalue_from_int() but creating a type with vector
> > attribute and where each individual element is set to some specified
> > value and it may not be the same value for each element.
> 
> I've implemented:
> 
> extern gcc_jit_rvalue *
> gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt,
>                                         gcc_jit_location *loc,
>                                         gcc_jit_type *vec_type,
>                                         size_t num_elements,
>                                         gcc_jit_rvalue **elements);
> 
> which is analogous to:
> 
>   { element0, element1, ... elementN-1}
> 
> in the C frontend.

Brilliant, that should enable one to make good use of the gcc
__builtin_shuffle() builtin which provides a very important SIMD
operation. (Here I am assuming the gcc jit already has access to
that particular builtin; I haven't tested it yet as it was no use
trying without being able to arbitrarily initialise a vector.)

> > The gcc C manual says "vectors can be subscripted as if the vector
> > were an array [...]" so I tried initialising a vector with
> > gcc_jit_context_new_array_access() but that fails with errors that
> > the vector is not a pointer or array at the time of JIT compilation.
> 
> I haven't implemented that yet; do you need it?

No, the above new implemented function provides what is needed.

Thanks,
Michael.

      reply	other threads:[~2017-10-04 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 David Malcolm
2017-01-01  0:00 ` Michael Cree
2017-01-01  0:00   ` [committed] jit: implement gcc_jit_context_new_rvalue_from_vector David Malcolm
2017-01-01  0:00   ` [committed] Fix crash accessing builtins in sanitizer.def and after (PR jit/82174) David Malcolm
2017-01-01  0:00     ` Michael Cree [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171004194959.flx5vlneyrpjqr5t@tower \
    --to=mcree@orcon.net.nz \
    --cc=dmalcolm@redhat.com \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).