From: Thomas Schwinge <tschwinge@baylibre.com>
To: Tobias Burnus <tburnus@baylibre.com>, gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: nvptx: 'cuDeviceGetCount' failure is fatal (was: [Patch] OpenMP: Move omp requires checks to libgomp)
Date: Thu, 07 Mar 2024 13:38:16 +0100 [thread overview]
Message-ID: <87sf12dxon.fsf@euler.schwinge.ddns.net> (raw)
In-Reply-To: <07fec82a-41cf-fdc5-6307-c068dd95ef1a@mentor.com>
[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]
Hi!
On 2022-06-08T05:56:02+0200, Tobias Burnus <Tobias_Burnus@mentor.com> wrote:
> [...] On the libgomp side: The devices which do not fulfill the requirements are
> now filtered out. [...]
> --- a/libgomp/plugin/plugin-gcn.c
> +++ b/libgomp/plugin/plugin-gcn.c
> /* Return the number of GCN devices on the system. */
>
> int
> -GOMP_OFFLOAD_get_num_devices (void)
> +GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask)
> {
> if (!init_hsa_context ())
> return 0;
> + /* Return -1 if no omp_requires_mask cannot be fulfilled but
> + devices were present. */
> + if (hsa_context.agent_count > 0 && omp_requires_mask != 0)
> + return -1;
> return hsa_context.agent_count;
> }
> --- a/libgomp/plugin/plugin-nvptx.c
> +++ b/libgomp/plugin/plugin-nvptx.c
> int
> -GOMP_OFFLOAD_get_num_devices (void)
> +GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask)
> {
> - return nvptx_get_num_devices ();
> + int num_devices = nvptx_get_num_devices ();
> + /* Return -1 if no omp_requires_mask cannot be fulfilled but
> + devices were present. */
> + if (num_devices > 0 && omp_requires_mask != 0)
> + return -1;
> + return num_devices;
> }
> --- a/libgomp/target.c
> +++ b/libgomp/target.c
> @@ -4132,8 +4183,19 @@ gomp_target_init (void)
>
> if (gomp_load_plugin_for_device (¤t_device, plugin_name))
> {
> - new_num_devs = current_device.get_num_devices_func ();
> - if (new_num_devs >= 1)
> + new_num_devs = current_device.get_num_devices_func (requires_mask);
> + if (new_num_devs < 0)
> + {
> + [...]
> + }
> + else if (new_num_devs >= 1)
> {
> /* Augment DEVICES and NUM_DEVICES. */
OK to push the attached "nvptx: 'cuDeviceGetCount' failure is fatal"?
Grüße
Thomas
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-nvptx-cuDeviceGetCount-failure-is-fatal.patch --]
[-- Type: text/x-diff, Size: 1317 bytes --]
From 8090da93cb00e4aa47a8b21b6548d739b2cebc49 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Thu, 7 Mar 2024 13:18:23 +0100
Subject: [PATCH] nvptx: 'cuDeviceGetCount' failure is fatal
Per commit 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
"OpenMP: Move omp requires checks to libgomp", we're now using 'return -1'
from 'GOMP_OFFLOAD_get_num_devices' for 'omp_requires_mask' purposes. This
missed that via 'nvptx_get_num_devices', we could also 'return -1' for
'cuDeviceGetCount' failure. Before, this meant (in 'gomp_target_init') to
silently ignore the plugin/device -- which also has been doubtful behavior.
Let's instead turn 'cuDeviceGetCount' failure into a fatal error, similar to
other errors during device initialization.
libgomp/
* plugin/plugin-nvptx.c (nvptx_get_num_devices):
'cuDeviceGetCount' failure is fatal.
---
libgomp/plugin/plugin-nvptx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index ffb1db67d20..81b4a7f499a 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -630,7 +630,7 @@ nvptx_get_num_devices (void)
}
}
- CUDA_CALL_ERET (-1, cuDeviceGetCount, &n);
+ CUDA_CALL_ASSERT (cuDeviceGetCount, &n);
return n;
}
--
2.34.1
next prev parent reply other threads:[~2024-03-07 12:38 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
2022-07-06 14:19 ` Tobias Burnus
2024-03-07 12:38 ` Thomas Schwinge [this message]
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=87sf12dxon.fsf@euler.schwinge.ddns.net \
--to=tschwinge@baylibre.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=tburnus@baylibre.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).