This is an archive of the discontinued LLVM Phabricator instance.

[mlir][SparseTensor][ArmSVE] Conditionally disable SVE RUN line
ClosedPublic

Authored by awarzynski on Jul 16 2023, 7:08 AM.

Details

Summary

This patch updates one SparseTensor integration test so that the VLA
vectorisation is run conditionally based on the value of the
MLIR_RUN_ARM_SME_TESTS CMake variable.

This change opens the path to reduce the duplication of RUN lines in
"mlir/test/Integration/Dialect/SparseTensor/CPU/". ATM, there are
usually 2 RUN lines to test vectorization in SparseTensor integration
tests:

  • one for VLS vectorisation,
  • one for VLA vectorisation whenever that's available and which reduces to VLS vectorisation when VLA is not supported.

When VLA is not available, VLS vectorisation is verified twice. This
duplication should be avoided - integration test are relatively
expansive to run.

This patch makes sure that the 2nd vectorisation RUN line becomes:

if (SVE integration tests are enabled)
  run VLA vectorisation
else
  return

This logic is implemented using LIT's (relatively new) conditional
substitution [1]. It enables us to guarantee that all RUN lines are
unique and that the VLA vectorisation is only enabled when supported.

This patch updates only 1 test to set-up and to demonstrate the logic.
Subsequent patches will update the remaining tests.

[1] https://www.llvm.org/docs/TestingGuide.html

Diff Detail

Event Timeline

awarzynski created this revision.Jul 16 2023, 7:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2023, 7:08 AM
awarzynski requested review of this revision.Jul 16 2023, 7:08 AM
Matt added a subscriber: Matt.Jul 16 2023, 10:40 AM

Thanks Andrzej, this is nice improvement

mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
20

the vl has changed for the VLA test, does this matter?

mlir/test/lit.site.cfg.py.in
42

Just curious, is the idea here to support %if %ENABLE_VLA ...?

Thanks for reviewing!

mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
20

Not really. The intention was always for both vectorisations to be identical (*), but things got out of sync during one of many copy & paste exercises :)

(*) The only intended difference is VLA vs VLS.

mlir/test/lit.site.cfg.py.in
42

Not quite.

The goal is to remove %ENABLE_VLA altogether (once all tests have been ported) and to use LIT's conditional substitution altogether. This brings us to:

%if <feature>

I wouldn't use ENABLE_VLA for feature, because that's not a ... feature. But there's also an option to update LIT's TestRunner to allow other things (i.e. not only "features") in <feature>. Also, perhaps quoting the docs will help:

%if feature %{<if branch>%} %else %{<else branch>%}

    Conditional substitution: if feature is available it expands to <if branch>, otherwise it expands to <else branch>. %else %{<else branch>%} is optional and treated like %else %{%} if not present.

Does this answer your question?

c-rhodes accepted this revision.Jul 17 2023, 5:12 AM

LGTM cheers

mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_index.mlir
20

Not really. The intention was always for both vectorisations to be identical (*), but things got out of sync during one of many copy & paste exercises :)

(*) The only intended difference is VLA vs VLS.

No worries, cheers!

mlir/test/lit.site.cfg.py.in
42

Not quite.

The goal is to remove %ENABLE_VLA altogether (once all tests have been ported) and to use LIT's conditional substitution altogether. This brings us to:

%if <feature>

I wouldn't use ENABLE_VLA for feature, because that's not a ... feature. But there's also an option to update LIT's TestRunner to allow other things (i.e. not only "features") in <feature>.

I see, so it could query config rather than config.available_features, where it could find mlir_run_arm_sve_tests, which could then be used as the <cond>.

Does this answer your question?

It does, thanks.

This revision is now accepted and ready to land.Jul 17 2023, 5:12 AM
awarzynski added inline comments.Jul 17 2023, 5:19 AM
mlir/test/lit.site.cfg.py.in
42

I see, so it could query config rather than config.available_features, where it could find mlir_run_arm_sve_tests, which could then be used as the <cond>.

Indeed. Just not sure whether that would be the right design 🤔 .