This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Set default version of architecture to SM_30, PTX to 6.0.
ClosedPublic

Authored by pavelkopyl on Jan 5 2023, 7:04 AM.

Details

Summary

Support of variadic functions triggers an assertion on several tests from
llvm/test/CodeGen/Generic/ if nvptx64-* is specified as a default triplet:

Support for variadic functions (unsized array parameter) introduced in
PTX ISA version 6.0 and requires target sm_30.

That happens because those tests contain variadic function calls and default
versions of both PTX ISA (3.2) and architecture (sm_20) are below the minimally required.

There were no observable problems with these tests before adding support of variadic
functions, because nvptx backend just didn't handle them properly generating invalid PTX code.

Diff Detail

Event Timeline

pavelkopyl created this revision.Jan 5 2023, 7:04 AM
pavelkopyl requested review of this revision.Jan 5 2023, 7:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 7:04 AM
pavelkopyl edited the summary of this revision. (Show Details)Jan 5 2023, 7:06 AM
pavelkopyl added a reviewer: tra.
pavelkopyl updated this revision to Diff 486588.Jan 5 2023, 8:08 AM
  • Update to correct patch version.
tra accepted this revision.Jan 5 2023, 11:59 AM

LGTM with few nits.

llvm/test/CodeGen/NVPTX/sm-version.ll
35–37

Please add the checks for SM21 and SM30, too.

llvm/test/CodeGen/NVPTX/surf-tex.py
2–3

We may as well change it to sm_30, too. sm_20 is gone for all practical purposes. Even sm_30 is on the way out.

This revision is now accepted and ready to land.Jan 5 2023, 11:59 AM
pavelkopyl added inline comments.Jan 5 2023, 2:04 PM
llvm/test/CodeGen/NVPTX/sm-version.ll
35–37

Sure, thank you.

llvm/test/CodeGen/NVPTX/surf-tex.py
2–3

Changing version to sm_30 also changes the generated code. The reason is that sm_20 (Fermi) has no support of image handles, as a result nvptx backed runs special pass NVPTXReplaceImageHandles to workaround this.
Textually such a code diff looks following:

.global .surfref gsurf;

sm_20:

suld.b.1d.b8.trap {%rs1}, [gsurf, {%r1}];

sm_30:

mov.u64 %rd3, gsurf;
suld.b.1d.b8.trap {%rs1}, [%rd3, {%r1}];

We can change this test to support sm_30. But I think it's better to do this in another review. Is that OK?

pavelkopyl updated this revision to Diff 486686.Jan 5 2023, 2:43 PM
  • Rebase
  • Fixes according to a review notes
tra added inline comments.Jan 5 2023, 3:15 PM
llvm/test/CodeGen/NVPTX/surf-tex.py
2–3

OK. We can keep sm_20 test around for now.

asavonic added inline comments.Jan 6 2023, 2:24 PM
llvm/test/CodeGen/NVPTX/surf-tex.py
2–3

The reason is that sm_20 (Fermi) has no support of image handles, as a result nvptx backed runs special pass NVPTXReplaceImageHandles to workaround this.

Can we run NVPTXReplaceImageHandles for other targets as well? These extra mov instructions are unnecessary, and the pass can eliminate them.

tra added inline comments.Jan 6 2023, 2:39 PM
llvm/test/CodeGen/NVPTX/surf-tex.py
2–3

The moves do not matter all that much. ptxas is an optimizing assembler, which can deal with them. If we really want to get rid of them, a better way would be not to generate them which should be done during lowering, not by running an additional pass.