public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Sandra Loosemore <sandra.loosemore@siemens.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v4] OpenMP: Generate SIMD clones for functions with "declare target"
Date: Fri, 25 Nov 2022 12:35:00 +0100	[thread overview]
Message-ID: <Y4CoZDilNcR11dh8@tucnak> (raw)
In-Reply-To: <927ad110-065e-9414-1312-bff5a0644e97@siemens.com>

On Mon, Nov 14, 2022 at 09:46:15PM -0700, Sandra Loosemore wrote:
> --- a/gcc/omp-simd-clone.cc
> +++ b/gcc/omp-simd-clone.cc
> @@ -51,6 +51,210 @@ along with GCC; see the file COPYING3.  If not see
>  #include "stringpool.h"
>  #include "attribs.h"
>  #include "omp-simd-clone.h"
> +#include "omp-low.h"
> +#include "omp-general.h"
> +
> +/* Print debug info for ok_for_auto_simd_clone to the dump file, logging
> +   failure reason EXCUSE for function DECL.  Always returns false.  */
> +static bool
> +auto_simd_fail (tree decl, const char *excuse)
> +{
> +  if (dump_file && (dump_flags & TDF_DETAILS))
> +    fprintf (dump_file, "\nNot auto-cloning %s because %s\n",
> +	     IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
> +	     excuse);
> +  return false;
> +}
> +
> +/* Helper function for ok_for_auto_simd_clone; return false if the statement
> +   violates restrictions for an "omp declare simd" function.  Specifically,
> +   the function must not
> +   - throw or call setjmp/longjmp
> +   - write memory that could alias parallel calls
> +   - read volatile memory
> +   - include openmp directives or calls
> +   - call functions that might do those things */
> +
> +static bool
> +auto_simd_check_stmt (gimple *stmt, tree outer)
> +{
> +  tree decl;
> +
> +  switch (gimple_code (stmt))
> +    {
> +    case GIMPLE_CALL:
> +
> +      /* Calls to functions that are CONST or PURE are ok, even if they
> +	 are internal functions without a decl.  Reject other internal
> +	 functions.  */
> +      if (gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE))
> +	break;
> +      if (gimple_call_internal_p (stmt))
> +	return auto_simd_fail (outer,
> +			       "body contains internal function call");

Just a note, this kind of building sentences from separate parts is
not ok for translations, but in the fprintf case the string isn't translated
anyway, so it is ok in this case.  But if we wanted to emit a
warning/inform, it wouldn't be.

The patch LGTM, thanks.

	Jakub


  reply	other threads:[~2022-11-25 11:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15  4:46 Sandra Loosemore
2022-11-25 11:35 ` Jakub Jelinek [this message]
2023-11-29 14:15 ` In 'libgomp.c/target-simd-clone-{1,2,3}.c', restrict 'scan-offload-ipa-dump's to 'only_for_offload_target amdgcn-amdhsa' (was: [PATCH v4] OpenMP: Generate SIMD clones for functions with "declare target") Thomas Schwinge

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=Y4CoZDilNcR11dh8@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sandra.loosemore@siemens.com \
    /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).