public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Antoni Boucher <bouanto@zoho.com>,
	jit@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libgccjit: Add support for the type bfloat16
Date: Fri, 01 Dec 2023 12:45:08 -0500	[thread overview]
Message-ID: <d73c50c06b83cddc01e552877a4ff9b6f747b5dc.camel@redhat.com> (raw)
In-Reply-To: <1c8d83e6f6759b82dc221667cc6545246b51ad8e.camel@zoho.com>

On Thu, 2023-11-16 at 17:20 -0500, Antoni Boucher wrote:
> I forgot to attach the patch.
> 
> On Thu, 2023-11-16 at 17:19 -0500, Antoni Boucher wrote:
> > Hi.
> > This patch adds the support for the type bfloat16 (bug 112574).
> > 
> > This was asked to be splitted from a another patch sent here:
> > https://gcc.gnu.org/pipermail/jit/2023q1/001607.html
> > 
> > Thanks for the review.
> 

Thanks for the patch.

> diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
> index 18cc4da25b8..7e1c97a4638 100644
> --- a/gcc/jit/jit-playback.cc
> +++ b/gcc/jit/jit-playback.cc
> @@ -280,6 +280,8 @@ get_tree_node_for_type (enum gcc_jit_types type_)
>  
>      case GCC_JIT_TYPE_FLOAT:
>        return float_type_node;
> +    case GCC_JIT_TYPE_BFLOAT16:
> +      return bfloat16_type_node;

The code to create bfloat16_type_node (in build_common_tree_nodes) is
guarded by #ifdef HAVE_BFmode, so we should probably have a test for
this in case GCC_JIT_TYPE_BFLOAT16 to at least add an error message
when it's NULL_TREE, rather than silently returning NULL_TREE and
crashing.

[...]

> diff --git a/gcc/testsuite/jit.dg/test-bfloat16.c b/gcc/testsuite/jit.dg/test-bfloat16.c
> new file mode 100644
> index 00000000000..6aed3920351
> --- /dev/null
> +++ b/gcc/testsuite/jit.dg/test-bfloat16.c
> @@ -0,0 +1,37 @@
> +/* { dg-do compile { target x86_64-*-* } } */
> +
> +#include <stdlib.h>
> +#include <stdio.h>
> +
> +#include "libgccjit.h"
> +
> +/* We don't want set_options() in harness.h to set -O3 so our little local
> +   is optimized away. */
> +#define TEST_ESCHEWS_SET_OPTIONS
> +static void set_options (gcc_jit_context *ctxt, const char *argv0)
> +{
> +}


Please add a comment to all-non-failing-tests.h noting the exclusion of
this test case from the array.

[...]

> diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c
> index a01944e35fa..9e7c4f3e046 100644
> --- a/gcc/testsuite/jit.dg/test-types.c
> +++ b/gcc/testsuite/jit.dg/test-types.c
> @@ -1,3 +1,4 @@
> +#include <immintrin.h>
>  #include <stdint.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -492,4 +493,5 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
>  
>    CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), sizeof (float));
>    CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), sizeof (double));
> +  CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_BFLOAT16)), sizeof (__bfloat16));


This is only going to work on targets which #ifdef HAVE_BFmode, so this
CHECK_VALUE needs to be conditionalized somehow, to avoid having this,
test-combination, and test-threads from bailing out early on targets
without BFmode.

Dave


  parent reply	other threads:[~2023-12-01 17:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 22:19 Antoni Boucher
2023-11-16 22:20 ` Antoni Boucher
2023-12-01 14:52   ` Antoni Boucher
2023-12-01 17:45   ` David Malcolm [this message]
2024-02-21 15:56     ` Antoni Boucher

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=d73c50c06b83cddc01e552877a4ff9b6f747b5dc.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=bouanto@zoho.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).