Hi Thomas,
Short answer: both are about devices, but otherwise
completely separate.
And: Thanks for testing and the report, which shows that
having at least one system with multiple GPUs makes sense!
* * *
Attached patch fixes the here reported issue by setting
the device number - which feature wise got lost when
implementing the feature.
Committed asr15-8870-g4d5d1a7326c850
* * *
Longer version:
Thomas Schwinge wrote:
Earlier today, I happened to be testing current OG14 branch. On a
multi-Nvidia GPU system, I saw:
...
Running on the nvptx device (0)
interop-fr-1.exe: [...]/libgomp.c/interop-fr-1.c:287: check_nvptx:
Assertion `dev_num == dev' failed.
...
282 int dev_num = (int) omp_get_interop_int (obj, omp_ipr_device_num,
&ret_code);
Somehow, setting 'obj->device_num = devicep->target_id;' got lost
between writing the WIP patch and the real patch ...
(Albeit I think there was never actual written code that did set it.)
As the memory is calloc'ed, it will work for device == 0,
which is the first non-host device (= the one GPU). And as
the host is unsupported, it will return NULL (→ omp_interop_none)
such that the issue cannot occur for the host.
* * *
Regarding the other patch, committed earlier today:
libgomp/plugin/plugin-nvptx.c: Fix device used for stream creation
... "just" ensures that the pointer (cuStream) for the right device is
returned.
This is only detectable when actually using the stream (i.e. calling
CUDA API functions) and the default / specified device has not the
OpenMP device number 0.
So far, we do not have such a test case: The OpenMP one uses the default
device and relies on being the same on CUDA and on the host.
This makes only a difference when the testcase actually uses the
returned CUDA context or device stream. The context was already handled,
the stream creation hasn't.
Something to check in a future testcase.
Tobias
commit 4d5d1a7326c8509a4a6fc94eedc3ba22d68f806f
Author: Tobias Burnus <tbur...@baylibre.com>
Date: Mon Mar 24 19:52:10 2025 +0100
libgomp: Save OpenMP device number when initializing the interop object
The interop object (opaque object to the user, used internally in libgomp)
already had a 'device_num' member, but it was missed to actually set it.
libgomp/ChangeLog:
* target.c (gomp_interop_internal): Set the 'device_num' member
when initializing an interop object.
---
libgomp/target.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libgomp/target.c b/libgomp/target.c
index 36ed797b0a9..a64ee96af2a 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -5324,6 +5324,7 @@ gomp_interop_internal (void *data)
}
*obj =
(struct interop_obj_t *) calloc (1, sizeof (struct interop_obj_t));
+ (*obj)->device_num = devicep->target_id;
devicep->interop_func (*obj, devicep->target_id,
gomp_interop_flag_init, targetsync,
prefer_type);