public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>,
	Jakub Jelinek <jakub@redhat.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch][v5] OpenMP: Move omp requires checks to libgomp
Date: Fri, 15 Sep 2023 11:41:36 +0200	[thread overview]
Message-ID: <87h6nvydrj.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <16ca2aa4-7e73-cf9d-9482-dd59f5b0cdae@codesourcery.com>

Hi!

On 2022-07-01T15:06:05+0200, Tobias Burnus <tobias@codesourcery.com> wrote:
> OpenMP: Move omp requires checks to libgomp

This became commit r13-1458-g683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
"OpenMP: Move omp requires checks to libgomp".


As of this, when I need to debug an offloading-compilation ICE, for
example, and start with 'gcc -save-temps -v', I can no longer just re-run
the offloading-compilation's 'lto1' invocation, because:

    $ [...]/gcc/lto1 [...] -foffload-abi=lp64 -fopenmp [...]
    [...]
    lto1: fatal error: GCC_OFFLOAD_OMP_REQUIRES_FILE unset
    compilation terminated.

That's because I missed setting the environment variable:

    GCC_OFFLOAD_OMP_REQUIRES_FILE=./declare-variant-1.xnvptx-none.mkoffload.omp_requires

..., which appears a number of lines earlier in the '-v' log.  Couldn't
we easily overcome this issue by turning the environment variable
'GCC_OFFLOAD_OMP_REQUIRES_FILE' into some new internal-use command-line
flag, like '-foffload-abi'?  That is, communication mechanics via
'[...].mkoffload.omp_requires' files would stay the same, just how we
communicate the file name changes: command-line flag instead of
environment variable.

For reference:

> --- a/gcc/config/gcn/mkoffload.cc
> +++ b/gcc/config/gcn/mkoffload.cc

> @@ -1077,9 +1080,27 @@ main (int argc, char **argv)
>        unsetenv ("COMPILER_PATH");
>        unsetenv ("LIBRARY_PATH");
>
> +      char *omp_requires_file;
> +      if (save_temps)
> +     omp_requires_file = concat (dumppfx, ".mkoffload.omp_requires", NULL);
> +      else
> +     omp_requires_file = make_temp_file (".mkoffload.omp_requires");
> +
>        /* Run the compiler pass.  */
> +      xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
>        fork_execute (cc_argv[0], CONST_CAST (char **, cc_argv), true, ".gcc_args");
>        obstack_free (&cc_argv_obstack, NULL);
> +      unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
> +
> +      in = fopen (omp_requires_file, "rb");
> +      if (!in)
> +     fatal_error (input_location, "cannot open omp_requires file %qs",
> +                  omp_requires_file);
> +      uint32_t omp_requires;
> +      if (fread (&omp_requires, sizeof (omp_requires), 1, in) != 1)
> +     fatal_error (input_location, "cannot read omp_requires file %qs",
> +                  omp_requires_file);
> +      fclose (in);

> --- a/gcc/config/nvptx/mkoffload.cc
> +++ b/gcc/config/nvptx/mkoffload.cc

> @@ -583,19 +586,37 @@ main (int argc, char **argv)
>        unsetenv ("COMPILER_PATH");
>        unsetenv ("LIBRARY_PATH");
>
> +      char *omp_requires_file;
> +      if (save_temps)
> +     omp_requires_file = concat (dumppfx, ".mkoffload.omp_requires", NULL);
> +      else
> +     omp_requires_file = make_temp_file (".mkoffload.omp_requires");
> +
> +      xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
>        fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
>                   ".gcc_args");
>        obstack_free (&argv_obstack, NULL);
> +      unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
>
>        xputenv (concat ("GCC_EXEC_PREFIX=", execpath, NULL));
>        xputenv (concat ("COMPILER_PATH=", cpath, NULL));
>        xputenv (concat ("LIBRARY_PATH=", lpath, NULL));
>
> +      in = fopen (omp_requires_file, "rb");
> +      if (!in)
> +     fatal_error (input_location, "cannot open omp_requires file %qs",
> +                  omp_requires_file);
> +      uint32_t omp_requires;
> +      if (fread (&omp_requires, sizeof (omp_requires), 1, in) != 1)
> +     fatal_error (input_location, "cannot read omp_requires file %qs",
> +                  omp_requires_file);
> +      fclose (in);

> --- a/gcc/lto-cgraph.cc
> +++ b/gcc/lto-cgraph.cc

> @@ -1821,6 +1906,18 @@ input_offload_tables (bool do_force_output)
>        lto_destroy_simple_input_block (file_data, LTO_section_offload_table,
>                                     ib, data, len);
>      }
> +#ifdef ACCEL_COMPILER
> +  char *omp_requires_file = getenv ("GCC_OFFLOAD_OMP_REQUIRES_FILE");
> +  if (omp_requires_file == NULL || omp_requires_file[0] == '\0')
> +    fatal_error (input_location, "GCC_OFFLOAD_OMP_REQUIRES_FILE unset");
> +  FILE *f = fopen (omp_requires_file, "wb");
> +  if (!f)
> +    fatal_error (input_location, "Cannot open omp_requires file %qs",
> +              omp_requires_file);
> +  uint32_t req_mask = omp_requires_mask & ~OMP_REQUIRES_TARGET_USED;
> +  fwrite (&req_mask, sizeof (req_mask), 1, f);
> +  fclose (f);
> +#endif
>  }


Grüße
 Thomas
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

  parent reply	other threads:[~2023-09-15  9:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 15:07 [PATCH, OpenMP 5.0] More implementation of the requires directive Chung-Lin Tang
2021-01-13 15:27 ` Jakub Jelinek
2021-03-25 11:18 ` Thomas Schwinge
2022-03-29 13:42 ` Andrew Stubbs
2022-06-08  3:56 ` [Patch] OpenMP: Move omp requires checks to libgomp Tobias Burnus
2022-06-09 11:40   ` Jakub Jelinek
2022-06-09 12:46     ` Tobias Burnus
2022-06-09 14:19       ` Jakub Jelinek
2022-06-29 14:33         ` [Patch][v4] " Tobias Burnus
2022-06-29 17:02           ` Jakub Jelinek
2022-06-29 18:10             ` Tobias Burnus
2022-06-29 20:18               ` Jakub Jelinek
2022-07-01 13:06                 ` [Patch][v5] " Tobias Burnus
2022-07-01 14:34                   ` Jakub Jelinek
2022-07-01 16:31                     ` Tobias Burnus
2022-07-01 16:55                       ` Jakub Jelinek
2022-07-01 21:08                         ` Tobias Burnus
2022-07-04  8:31                           ` Jakub Jelinek
2022-07-07 13:26                           ` Fix one issue in OpenMP 'requires' directive diagnostics (was: [Patch][v5] OpenMP: Move omp requires checks to libgomp) Thomas Schwinge
2022-07-07 13:56                             ` Tobias Burnus
2022-07-08  6:59                               ` Thomas Schwinge
2022-07-06 10:42                   ` Restore 'GOMP_offload_unregister_ver' functionality " Thomas Schwinge
2022-07-06 13:59                     ` Tobias Burnus
2022-07-06 21:08                       ` Thomas Schwinge
2022-08-17 11:45                       ` Jakub Jelinek
2023-09-15  9:41                   ` Thomas Schwinge [this message]
2022-07-07  8:37           ` Adjust 'libgomp.c-c++-common/requires-3.c' (was: [Patch][v4] " Thomas Schwinge
2022-07-07  9:02             ` Tobias Burnus
2022-07-07  8:42           ` Enhance 'libgomp.c-c++-common/requires-4.c', 'libgomp.c-c++-common/requires-5.c' testing " Thomas Schwinge
2022-07-07  9:36             ` Tobias Burnus
2022-07-07 10:42               ` Thomas Schwinge
2022-07-06 10:30   ` Define 'OMP_REQUIRES_[...]', 'GOMP_REQUIRES_[...]' in a single place (was: [Patch] " Thomas Schwinge
2022-07-06 13:40     ` Tobias Burnus
2022-07-06 11:04   ` Fix Intel MIC 'mkoffload' for OpenMP 'requires' " Thomas Schwinge
2022-07-06 11:29     ` Tobias Burnus
2022-07-06 12:38       ` Thomas Schwinge
2022-07-06 13:30         ` Tobias Burnus
2022-07-07 10:46           ` Thomas Schwinge
2022-07-06 14:19     ` Tobias Burnus
2024-03-07 12:38   ` nvptx: 'cuDeviceGetCount' failure is fatal " Thomas Schwinge
2024-03-07 14:28     ` nvptx: 'cuDeviceGetCount' failure is fatal Tobias Burnus
2024-03-08 15:58       ` 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=87h6nvydrj.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=tobias@codesourcery.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).