Follow-up to #2710, which ported isa_name_parsing_test to LIT. The next CTest to migrate is amd/comgr/test/get_data_isa_name_test.c.
This one is more involved than the parse-isa-name port — the existing test conflates multiple concerns and should be split, not mechanically copied.
Background
The existing test does three things bundled together:
- ISA enumeration —
amd_comgr_get_isa_count + amd_comgr_get_isa_name
- Code-object ISA extraction —
amd_comgr_get_data_isa_name (the API the test is named for)
- Pipeline correctness — full OpenCL compile (source → BC → linked BC → relocatable → executable), then reads back the ISA name from the produced code object
For every registered ISA, for every supported feature combination, it runs the full compile pipeline. This is slow and overlaps with what compile_* tests already cover.
Proposed split
Replace the single CTest with two focused LIT tests:
Test 1: ISA enumeration
A small comgr-sources/ binary that:
- Calls
amd_comgr_get_isa_count
- Iterates with
amd_comgr_get_isa_name
- Prints each name
LIT verifies via FileCheck against a stable subset (e.g. CHECK: amdgcn-amd-amdhsa--gfx900) and asserts count > 0.
Note: the static IsaFeatures[] table in the current test can be dropped entirely. It existed to predict what Comgr would report, but that's exactly what get_isa_name returns — no need to duplicate the knowledge in the test.
Test 2: get_data_isa_name
An argv-driven comgr-sources/ binary (modeled on parse-isa-name) that:
- Takes
<code-object-path> <expected-isa-name>
- Calls
amd_comgr_get_data_isa_name on the code object
- Compares against expected
The code objects are generated via clang in RUN: lines instead of the full Comgr pipeline:
// RUN: %clang -target amdgcn-amd-amdhsa -mcpu=gfx900 -nogpulib -nogpuinc \
// RUN: -c %S/Inputs/shared.cl -o %t.gfx900.o
// RUN: get-data-isa-name %t.gfx900.o "amdgcn-amd-amdhsa--gfx900"
Pick a handful of representative targets covering the matrix axes — not the full 50+ ISA sweep. Suggested coverage:
- Feature-rich (e.g. gfx908 — sramecc + xnack)
- xnack-only (e.g. gfx900)
- No features (e.g. gfx1030)
- Generic target needing COV6 (e.g. gfx9-generic with
-mcode-object-version=6)
Considerations / gotchas
- Clang folds feature defaults into the emitted ISA string (e.g.
gfx900:xnack-). Two ways to handle:
- Pin features explicitly with
-Xclang -target-feature -Xclang ... and assert exact match
- Use a
FileCheck regex like // CHECK: amdgcn-amd-amdhsa--gfx900(:xnack[+-])? to tolerate defaults
-nogpulib -nogpuinc keeps the compile independent of device-libs being present in the lit environment
- Only test relocatables, not executables — the old test ran the API on both
DataReloc and DataExec, but the Comgr codepath is the same (reads ELF notes). One is enough.
%clang substitution — check amd/comgr/test-lit/lit.cfg.py to confirm clang is wired up as a lit substitution. If not, add it (standard LLVM lit setup).
- The OpenCL source the old test used is at
amd/comgr/test/source/shared.cl. Move/copy a minimal version to amd/comgr/test-lit/Inputs/ (or wherever the convention lands).
Cleanup
Once both LIT tests are in place and passing:
- Remove
amd/comgr/test/get_data_isa_name_test.c
- Remove the
add_comgr_test(get_data_isa_name_test c) line from amd/comgr/test/CMakeLists.txt
- Add the new tests to
amd/comgr/test-lit/CMakeLists.txt via add_comgr_lit_binary(...)
References
Follow-up to #2710, which ported
isa_name_parsing_testto LIT. The next CTest to migrate isamd/comgr/test/get_data_isa_name_test.c.This one is more involved than the parse-isa-name port — the existing test conflates multiple concerns and should be split, not mechanically copied.
Background
The existing test does three things bundled together:
amd_comgr_get_isa_count+amd_comgr_get_isa_nameamd_comgr_get_data_isa_name(the API the test is named for)For every registered ISA, for every supported feature combination, it runs the full compile pipeline. This is slow and overlaps with what
compile_*tests already cover.Proposed split
Replace the single CTest with two focused LIT tests:
Test 1: ISA enumeration
A small
comgr-sources/binary that:amd_comgr_get_isa_countamd_comgr_get_isa_nameLIT verifies via
FileCheckagainst a stable subset (e.g.CHECK: amdgcn-amd-amdhsa--gfx900) and asserts count > 0.Note: the static
IsaFeatures[]table in the current test can be dropped entirely. It existed to predict what Comgr would report, but that's exactly whatget_isa_namereturns — no need to duplicate the knowledge in the test.Test 2:
get_data_isa_nameAn argv-driven
comgr-sources/binary (modeled onparse-isa-name) that:<code-object-path> <expected-isa-name>amd_comgr_get_data_isa_nameon the code objectThe code objects are generated via
clanginRUN:lines instead of the full Comgr pipeline:Pick a handful of representative targets covering the matrix axes — not the full 50+ ISA sweep. Suggested coverage:
-mcode-object-version=6)Considerations / gotchas
gfx900:xnack-). Two ways to handle:-Xclang -target-feature -Xclang ...and assert exact matchFileCheckregex like// CHECK: amdgcn-amd-amdhsa--gfx900(:xnack[+-])?to tolerate defaults-nogpulib -nogpuinckeeps the compile independent of device-libs being present in the lit environmentDataRelocandDataExec, but the Comgr codepath is the same (reads ELF notes). One is enough.%clangsubstitution — checkamd/comgr/test-lit/lit.cfg.pyto confirmclangis wired up as a lit substitution. If not, add it (standard LLVM lit setup).amd/comgr/test/source/shared.cl. Move/copy a minimal version toamd/comgr/test-lit/Inputs/(or wherever the convention lands).Cleanup
Once both LIT tests are in place and passing:
amd/comgr/test/get_data_isa_name_test.cadd_comgr_test(get_data_isa_name_test c)line fromamd/comgr/test/CMakeLists.txtamd/comgr/test-lit/CMakeLists.txtviaadd_comgr_lit_binary(...)References
isa_name_parsing_testport (good reference for the LIT binary scaffolding and CMake wiring)amd/comgr/test-lit/comgr-sources/—parse-isa-name.cis the closest pattern