Hi Andrew,

Andrew Stubbs wrote:
On 21/10/2024 20:49, Tobias Burnus wrote:
     GCN_DEVICE field descriptions:
-      0  "name"  (text, external)
+      0 Generic flag/version (0 = non-generic, 1 to 255 = generic version,
+        external)

I think this should mention EF_AMDGPU_GENERIC_VERSION_V, otherwise it's just a magic number.

You mean like:

- external)

+ external, used with EF_AMDGPU_GENERIC_VERSION_V)

?

Otherwise, it is not magic but a version number and because no compatibility issues have been found, it is '1' for all gfx*-generic.

Actually, where are the numbers defined? Is it just that the linker demands that they match, so we can define them ourselves?

Well, given that llvm-mc sets it, our use in mkoffload.cc must match llvm-mc. And I guess that ROCm also might care about the value. But in terms of the linker, indeed, it is just required that all generic-version numbers are identical.

As mentioned above, the idea is to have some possibility to handle incompatibilities that way by moving to a new version. Currently, all gfx*-generic in LLVM's assembler use version 1, which is unsurprising as the feature is new and there is usually only rarely the need to bump the version.

Besides versioning, that flag also permits to quickly detect whether the ELF header is for a generic arch as elf_flag & 0xff000000 != 0 [alias (elf_flag & EF_AMDGPU_GENERIC_VERSION_V) != 0)] is enough without having to know that/which 0x05x are generic cards. (Namely, currently: 0x05{1,2,3,4,9} for gfx{9,10-1,10-3,11,12}-generic.)

* * *

Also, why does this have to be arg0? The whole point of using ellipsis everywhere is so we can add new fields without touching every instance that doesn't care.

As it seems to be a flag which is very generic – 0 actual arch, 1 (or later other number) generic.

That seems to be much easier to follow than having it buried in the later arguments, because it makes sense hierarchically, doing it differently feels a bit convoluted when writing the .def file.

You can add:
  GCN_DEVICE(gfx900, ...blah...
     /* Generic Arch Version */ 0 /* Not generic. */
  )

  GCN_DEVICE(gfx11-generic, ...blah...
     /* Generic Arch Version */ 1 /* Up to gfx1103 ? */
  )

It does not work that way — 0x053 is all gfx11… including gfx115{0,1,2} and the known gfx110{0,1,2,3}

The version is not bumped if a new gfx1188 is added but only with some incompatibility forces this change. Otherwise, it will always be '1'.

* * *

awk file:

I understand that you needed to use the name variant that has underscores, but $4 should not be called "elf"; call it "GFX" or "NAME". The elf_flag is $5 here, so this confused me.
I concur NAME or GFX is clearer.

Tobias

Reply via email to