Hi Andrew,
Andrew Stubbs wrote:
On 07/10/2025 11:31, Tobias Burnus wrote:
This patch adds the currently unused static function 'is_integrated_apu'
to libgomp/plugin/plugin-{gcn,nvptx}.c.
While currently not in use ('#if 0'), I'd like to add it already now
as prep work. The idea is to use it to enable self mapping automatically
be default if mapping it pointless (copying data despite sharing the
same memory controller). [See below for more.]
Any comments?
If going this far, why not make it live? I already posted the libgomp
parts a year ago, and there's not much:
https://patchwork.sourceware.org/project/gcc/patch/[email protected]/
I think that patch moves into the right direction, but there are two issues:
(A) It enables self mapping unconditionally for APUs. While that's in
principle fine, we need to fix the mapping issue for static variables
before enabling it automatically. — That's the reason we currently
cannot enable USM by default as it will break too many programs.
(B) For 'requires USM', it is currently still disables all devices if a
single device doesn't support the feature. OK that's not a real problem
but ideally it would keep the USM GPUs and just exclude the non-USM
ones. I think for that we want to pass on the 'requires' attribute again
and have to deal with numbering differences (i.e. the n-th AMD GPU might
be the (n-2)-th AMD OpenMP device). — On the other hand, eventually for
OpenMP 6.0's OMP_AVAILABLE_DEVICES, we have to handle renumbering. Maybe
we should defer implementing the skip-some GPUs feature for 'requires
USM' for now and come back to it a bit later.
For the latter, we have to support excluding some GPUs (both in
num_devices + handling the device number).
Additionally, as mentioned, I think it would be useful to have an
environment variable to tune this.
Tobias
PS: Looks as if this mapping issue should be fixed soon – first to
unbreak some real USM programs and to enable automatic APU support.
Refinements (cf. above) can then still be done as follow up.