Skip to content

[Comgr] Port get_data_isa_name_test from CTest to LIT #2711

@lamb-j

Description

@lamb-j

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:

  1. ISA enumerationamd_comgr_get_isa_count + amd_comgr_get_isa_name
  2. Code-object ISA extractionamd_comgr_get_data_isa_name (the API the test is named for)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    comgrRelated to Code Object Manager

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions