On Mon, May 16, 2022 at 12:28:45PM +0200, Tobias Burnus wrote:
> While 'vendor' and 'kind' is well defined, 'arch' and 'isa' isn't.
> 
> When looking at an 'metadirective' testcase (which oddly uses 'arch(amd)'),
> I noticed that LLVM uses 'arch(amdgcn)' while we use 'gcn', cf. e.g.
> 'clang/lib/Headers/openmp_wrappers/math.h'.
> (Side note: we use the target triplet amdgcn-amdhsa and LLVM uses 
> amdgcn-amd-amdhsa.)
> 
> Given the target triplet, the LLVM choice seems to make more sense; 'gcn'
> only shows up as directory name (under gcc/config + libgomp/).
> 
> Thus, I think we have two options:
> * Either also change to (only) 'amdgcn' - given that the supported arch()
>   values are neither documented not yet widely used.
> * Or add 'amdgcn' alongside 'gcn' - which is what the attached patch does.
> 
> Which option do you prefer? Other thoughts?

I prefer gcn and amdgcn as aliases of each other.

> PS: I think during the GCC 13 development, we should start adding more
> offload-target documentation, including documenting the used/permitted
> vendor/arch/isa context selectors.
> -----------------
> 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

> gcn/t-omp-device: Add 'amdgcn' as 'arch' [PR105602]
> 
> Improve cross-compiler handling.
> 
> gcc/ChangeLog:
> 
>       PR target/105602
>       * config/gcn/t-omp-device (arch): Add 'amdgcn' besides existing 'gcn'.
> 
> diff --git a/gcc/config/gcn/t-omp-device b/gcc/config/gcn/t-omp-device
> index cd56e2f8a68..e1d9e0d2a1e 100644
> --- a/gcc/config/gcn/t-omp-device
> +++ b/gcc/config/gcn/t-omp-device
> @@ -1,4 +1,4 @@
>  omp-device-properties-gcn: $(srcdir)/config/gcn/gcn.cc
>       echo kind: gpu > $@
> -     echo arch: gcn >> $@
> +     echo arch: amdgcn gcn >> $@
>       echo isa: fiji gfx900 gfx906 gfx908 >> $@

But the above patch only implements it partially.
What is in omp-device-properties-* is for the sake of the host compiler,
so that it knows possible support by each offloading target.
If arch or isa or kind isn't supported by either host or by any of the
possible configured offloading target, it can be considered not matching
right away (well, right now that is around gimplification time).
Similarly if it doesn't match host and can't be in offloaded code.
Otherwise, the decision is postponed until after IPA, where we are sure if
it is offloaded or host code and for which exact arch/isa/kind it is.

Without your patch, we'll say arch(amdgcn) doesn't match right away.
With your patch, we'll defer it and reject after IPA.

You need to also change gcc/config/gcn/gcn.cc (gcn_omp_device_kind_arch_isa)
case omp_device_arch: handling so that it accepts both "gcn" and "amdgcn"
equally.

        Jakub

Reply via email to