public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Michael Cree <mcree@orcon.net.nz>, jit@gcc.gnu.org
Subject: Re: does libgccjit support vector types?
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <1502116137.2723.7.camel@redhat.com> (raw)
In-Reply-To: <20170807081235.oujwzxfp6vujlg7f@tower>

On Mon, 2017-08-07 at 20:12 +1200, Michael Cree wrote:

Hi Michael

> I am wondering if libgccjit supports vector types, i.e., can one
> attach attribute __vector_size__ to the base types?  There does not
> seem to be any indication of this in the manual.

Currently this isn't supported.

[notes to self e.g.:

   typedef int v4si __attribute__ ((vector_size (16)));

is normally handled by C/C++ here:

c-family/c-attribs.c:260:
  { "vector_size",	      1, 1, false, true, false,
			      handle_vector_size_attribute, true },

which ultimately calls:

    new_type = build_vector_type (type, nunits);

    /* Build back pointers if needed.  */
    *node = lang_hooks.types.reconstruct_complex_type (*node, new_type);

(the latter does some support stuff for C++ templates).

Hence the "vector_size" attribute itself isn't supported by libgccjit,
and the underlying build_vector_type call within gcc's internal API
isn't exposed yet via libgccjit.

end of notes to self]

Is this a blocker for you using libgccjit?  What would the ideal API
look like? 

Maybe something like:

  extern gcc_jit_type *
  gcc_jit_type_get_vector (gcc_jit_type *type, unsigned nunits);
 
with various requirements (type must be integral/floating point; nunits
must be a power of two).

> I presume using gcc_jit_context_add_command_line_option() one can
> turn
> on code generation for sse/avx/neon/altivec, etc.

That ought to work, though currently the only usage examples in the
testsuite for this entrypoint are platform-independent (e.g. "-ffast-
math").

> And is there a way to access built-in functions such as the machine
> specific simd intrinsics?

gcc_jit_context_get_builtin_function ought to work, though I don't
think I've tested this particular use-case (as above, the usage
examples in the testsuite are currently all platform-independent).


Hope this is helpful
Dave

  reply	other threads:[~2017-08-07 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 Michael Cree
2017-01-01  0:00 ` David Malcolm [this message]
2017-01-01  0:00   ` Michael Cree
2017-01-01  0:00     ` [committed] jit: add gcc_jit_type_get_vector David Malcolm
2017-01-01  0:00       ` Michael Cree
2017-01-01  0:00         ` David Malcolm
2017-01-01  0:00           ` Michael Cree
2017-01-01  0:00             ` David Malcolm
2017-01-01  0:00               ` [committed] jit: fix segfault with autovectorization (PR tree-optimization/46805) David Malcolm

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=1502116137.2723.7.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=jit@gcc.gnu.org \
    --cc=mcree@orcon.net.nz \
    /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).