From: Thomas Schwinge <thomas@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>, <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: Re: Fix Intel MIC 'mkoffload' for OpenMP 'requires' (was: [Patch] OpenMP: Move omp requires checks to libgomp)
Date: Thu, 7 Jul 2022 12:46:25 +0200 [thread overview]
Message-ID: <87tu7t5hfi.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <1116448f-eb76-76b3-8aaf-a0e44330c161@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 1361 bytes --]
Hi Tobias!
On 2022-07-06T15:30:57+0200, Tobias Burnus <tobias@codesourcery.com> wrote:
> On 06.07.22 14:38, Thomas Schwinge wrote:
>> :-) Haha, that's actually *exactly* what I had implemented first! But
>> then I realized that 'target offloading_enabled' is doing exactly that:
>> check that offloading compilation is configured -- not that "there is an
>> offloading device available or not" as you seem to understand? Or am I
>> confused there?
>
> I think as you mentioned below – there is a difference.
Eh, thanks for un-confusing me on that aspect! There's a reason after
all that 'offloading_enabled' lives in 'gcc/testsuite/lib/'...
> And that difference,
> I explicitly maked use of: [...]
> Granted, as the other files do not use -foffload=..., it should not
> make a difference - but, still, replacing it unconditionally
> with 'target offloading_enabled' feels wrong.
ACK!
I've pushed to master branch
commit 9ef714539cb7cc1cd746312fd5dcc987bf167471
"Fix Intel MIC 'mkoffload' for OpenMP 'requires'", see attached.
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-Intel-MIC-mkoffload-for-OpenMP-requires.patch --]
[-- Type: text/x-diff, Size: 9958 bytes --]
From 9ef714539cb7cc1cd746312fd5dcc987bf167471 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 5 Jul 2022 12:21:33 +0200
Subject: [PATCH] Fix Intel MIC 'mkoffload' for OpenMP 'requires'
Similar to how the other 'mkoffload's got changed in
recent commit 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
"OpenMP: Move omp requires checks to libgomp".
This also means finally switching Intel MIC 'mkoffload' to
'GOMP_offload_register_ver', 'GOMP_offload_unregister_ver',
making 'GOMP_offload_register', 'GOMP_offload_unregister'
legacy entry points.
gcc/
* config/i386/intelmic-mkoffload.cc (generate_host_descr_file)
(prepare_target_image, main): Handle OpenMP 'requires'.
(generate_host_descr_file): Switch to 'GOMP_offload_register_ver',
'GOMP_offload_unregister_ver'.
libgomp/
* target.c (GOMP_offload_register, GOMP_offload_unregister):
Denote as legacy entry points.
* testsuite/lib/libgomp.exp
(check_effective_target_offload_target_any): New proc.
* testsuite/libgomp.c-c++-common/requires-1.c: Enable for
'offload_target_any'.
* testsuite/libgomp.c-c++-common/requires-3.c: Likewise.
* testsuite/libgomp.c-c++-common/requires-7.c: Likewise.
* testsuite/libgomp.fortran/requires-1.f90: Likewise.
---
gcc/config/i386/intelmic-mkoffload.cc | 56 +++++++++++++++----
libgomp/target.c | 4 ++
libgomp/testsuite/lib/libgomp.exp | 5 ++
.../libgomp.c-c++-common/requires-1.c | 2 +-
.../libgomp.c-c++-common/requires-3.c | 2 +-
.../libgomp.c-c++-common/requires-7.c | 2 +-
.../testsuite/libgomp.fortran/requires-1.f90 | 2 +-
7 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/gcc/config/i386/intelmic-mkoffload.cc b/gcc/config/i386/intelmic-mkoffload.cc
index c683d6f473e..596f6f107b8 100644
--- a/gcc/config/i386/intelmic-mkoffload.cc
+++ b/gcc/config/i386/intelmic-mkoffload.cc
@@ -370,7 +370,7 @@ generate_target_offloadend_file (const char *target_compiler)
/* Generates object file with the host side descriptor. */
static const char *
-generate_host_descr_file (const char *host_compiler)
+generate_host_descr_file (const char *host_compiler, uint32_t omp_requires)
{
char *dump_filename = concat (dumppfx, "_host_descr.c", NULL);
const char *src_filename = save_temps
@@ -386,39 +386,50 @@ generate_host_descr_file (const char *host_compiler)
if (!src_file)
fatal_error (input_location, "cannot open '%s'", src_filename);
+ fprintf (src_file, "#include <stdint.h>\n\n");
+
fprintf (src_file,
"extern const void *const __OFFLOAD_TABLE__;\n"
"extern const void *const __offload_image_intelmic_start;\n"
"extern const void *const __offload_image_intelmic_end;\n\n"
- "static const void *const __offload_target_data[] = {\n"
+ "static const struct intelmic_data {\n"
+ " uintptr_t omp_requires_mask;\n"
+ " const void *const image_start;\n"
+ " const void *const image_end;\n"
+ "} intelmic_data = {\n"
+ " %d,\n"
" &__offload_image_intelmic_start, &__offload_image_intelmic_end\n"
- "};\n\n");
+ "};\n\n", omp_requires);
fprintf (src_file,
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
- "void GOMP_offload_register (const void *, int, const void *);\n"
+ "void GOMP_offload_register_ver (unsigned, const void *, int, const void *);\n"
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
- "void GOMP_offload_unregister (const void *, int, const void *);\n\n"
+ "void GOMP_offload_unregister_ver (unsigned, const void *, int, const void *);\n\n"
"__attribute__((constructor))\n"
"static void\n"
"init (void)\n"
"{\n"
- " GOMP_offload_register (&__OFFLOAD_TABLE__, %d, __offload_target_data);\n"
- "}\n\n", GOMP_DEVICE_INTEL_MIC);
+ " GOMP_offload_register_ver (%#x, &__OFFLOAD_TABLE__, %d, &intelmic_data);\n"
+ "}\n\n",
+ GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_INTEL_MIC),
+ GOMP_DEVICE_INTEL_MIC);
fprintf (src_file,
"__attribute__((destructor))\n"
"static void\n"
"fini (void)\n"
"{\n"
- " GOMP_offload_unregister (&__OFFLOAD_TABLE__, %d, __offload_target_data);\n"
- "}\n", GOMP_DEVICE_INTEL_MIC);
+ " GOMP_offload_unregister_ver (%#x, &__OFFLOAD_TABLE__, %d, &intelmic_data);\n"
+ "}\n",
+ GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_INTEL_MIC),
+ GOMP_DEVICE_INTEL_MIC);
fclose (src_file);
@@ -462,7 +473,7 @@ generate_host_descr_file (const char *host_compiler)
}
static const char *
-prepare_target_image (const char *target_compiler, int argc, char **argv)
+prepare_target_image (const char *target_compiler, int argc, char **argv, uint32_t *omp_requires)
{
const char *target_descr_filename
= generate_target_descr_file (target_compiler);
@@ -509,8 +520,26 @@ prepare_target_image (const char *target_compiler, int argc, char **argv)
obstack_ptr_grow (&argv_obstack, "");
obstack_ptr_grow (&argv_obstack, "-o");
obstack_ptr_grow (&argv_obstack, target_so_filename);
+
+ 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));
+
compile_for_target (&argv_obstack);
+ unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
+ FILE *in = fopen (omp_requires_file, "rb");
+ if (!in)
+ fatal_error (input_location, "cannot open omp_requires file %qs",
+ omp_requires_file);
+ 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);
+
/* Run objcopy. */
char *rename_section_opt
= XALLOCAVEC (char, sizeof (".data=") + strlen (image_section_name));
@@ -643,10 +672,13 @@ main (int argc, char **argv)
if (!dumppfx)
dumppfx = out_obj_filename;
+ uint32_t omp_requires;
+
const char *target_so_filename
- = prepare_target_image (target_compiler, argc, argv);
+ = prepare_target_image (target_compiler, argc, argv, &omp_requires);
- const char *host_descr_filename = generate_host_descr_file (host_compiler);
+ const char *host_descr_filename
+ = generate_host_descr_file (host_compiler, omp_requires);
/* Perform partial linking for the target image and host side descriptor.
As a result we'll get a finalized object file with all offload data. */
diff --git a/libgomp/target.c b/libgomp/target.c
index c66c61b0621..86f9d3050d9 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -2410,6 +2410,8 @@ GOMP_offload_register_ver (unsigned version, const void *host_table,
gomp_mutex_unlock (®ister_lock);
}
+/* Legacy entry point. */
+
void
GOMP_offload_register (const void *host_table, int target_type,
const void *target_data)
@@ -2462,6 +2464,8 @@ GOMP_offload_unregister_ver (unsigned version, const void *host_table,
gomp_mutex_unlock (®ister_lock);
}
+/* Legacy entry point. */
+
void
GOMP_offload_unregister (const void *host_table, int target_type,
const void *target_data)
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 891f90929d2..107a3c2ac9d 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -348,6 +348,11 @@ proc libgomp_check_effective_target_offload_target { target_name } {
return 0
}
+# Return 1 if compiling for any offload target.
+proc check_effective_target_offload_target_any { } {
+ return [libgomp_check_effective_target_offload_target ""]
+}
+
# Return 1 if compiling for offload target nvptx.
proc check_effective_target_offload_target_nvptx { } {
return [libgomp_check_effective_target_offload_target "nvptx"]
diff --git a/libgomp/testsuite/libgomp.c-c++-common/requires-1.c b/libgomp/testsuite/libgomp.c-c++-common/requires-1.c
index fedf9779769..ab9a8ddfcde 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/requires-1.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/requires-1.c
@@ -1,4 +1,4 @@
-/* { dg-do link { target { offload_target_nvptx || offload_target_amdgcn } } } */
+/* { dg-do link { target offload_target_any } } */
/* { dg-additional-sources requires-1-aux.c } */
/* Check diagnostic by device-compiler's lto1.
diff --git a/libgomp/testsuite/libgomp.c-c++-common/requires-3.c b/libgomp/testsuite/libgomp.c-c++-common/requires-3.c
index 7091f400ef0..1c204c8a21e 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/requires-3.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/requires-3.c
@@ -1,4 +1,4 @@
-/* { dg-do link { target { offload_target_nvptx || offload_target_amdgcn } } } */
+/* { dg-do link { target offload_target_any } } */
/* { dg-additional-sources requires-3-aux.c } */
/* Check diagnostic by device-compiler's lto1.
diff --git a/libgomp/testsuite/libgomp.c-c++-common/requires-7.c b/libgomp/testsuite/libgomp.c-c++-common/requires-7.c
index c94a4c10846..7473aa62e08 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/requires-7.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/requires-7.c
@@ -1,4 +1,4 @@
-/* { dg-do link { target { offload_target_nvptx || offload_target_amdgcn } } } */
+/* { dg-do link { target offload_target_any } } */
/* { dg-additional-sources requires-7-aux.c } */
/* Check diagnostic by device-compiler's lto1.
diff --git a/libgomp/testsuite/libgomp.fortran/requires-1.f90 b/libgomp/testsuite/libgomp.fortran/requires-1.f90
index 33741af15f1..e957b1b5918 100644
--- a/libgomp/testsuite/libgomp.fortran/requires-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/requires-1.f90
@@ -1,4 +1,4 @@
-! { dg-do link { target { offload_target_nvptx || offload_target_amdgcn } } }
+! { dg-do link { target offload_target_any } }
! { dg-additional-sources requires-1-aux.f90 }
! Check diagnostic by device-compiler's lto1.
--
2.35.1
next prev parent reply other threads:[~2022-07-07 10:51 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 ` [Patch][v5] OpenMP: Move omp requires checks to libgomp Thomas Schwinge
2022-07-07 8:37 ` Adjust 'libgomp.c-c++-common/requires-3.c' (was: [Patch][v4] OpenMP: Move omp requires checks to libgomp) 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 [this message]
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=87tu7t5hfi.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).