Skip to content

Commit 3c61d59

Browse files
committed
Added sm_101 exception logic
1 parent 4dab4c3 commit 3c61d59

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ class AnyPred<list<Predicate> Preds>
109109
")">;
110110

111111
// Checks PTX version and family-specific and architecture-specific SM versions.
112-
// For example, sm_100{f/a} and any future variants in the same family will match.
112+
// For example, sm_100{f/a} and any future variants in the same family will match
113+
// for any PTX version greater than or equal to `PTXVersion`.
113114
class PTXWithFamilySMs<int PTXVersion, list<int> SMVersions> :
114115
Predicate<"Subtarget->hasPTXWithFamilySMs(" # PTXVersion # ", {" #
115116
!interleave(SMVersions, ", ") # "})">;
116117

117118
// Checks PTX version and architecture-specific SM versions.
118-
// For example, sm_100{a} will match.
119+
// For example, sm_100{a} will match for any PTX version
120+
// greater than or equal to `PTXVersion`.
119121
class PTXWithAccelSMs<int PTXVersion, list<int> SMVersions> :
120122
Predicate<"Subtarget->hasPTXWithAccelSMs(" # PTXVersion # ", {" #
121123
!interleave(SMVersions, ", ") # "})">;

llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,36 @@ const SelectionDAGTargetInfo *NVPTXSubtarget::getSelectionDAGInfo() const {
7474

7575
bool NVPTXSubtarget::hasPTXWithFamilySMs(unsigned PTXVersion,
7676
ArrayRef<unsigned> SMVersions) const {
77-
if (!hasFamilySpecificFeatures() || getPTXVersion() < PTXVersion)
77+
unsigned PTXVer = getPTXVersion();
78+
if (!hasFamilySpecificFeatures() || PTXVer < PTXVersion)
7879
return false;
7980

81+
unsigned SMVer = getSmVersion();
8082
return llvm::any_of(SMVersions, [&](unsigned SM) {
81-
return getSmFamilyVersion() == SM / 10 && getSmVersion() >= SM;
83+
// sm_101 is a different family, never group it with sm_10x.
84+
if (SMVer == 101 || SM == 101)
85+
return SMVer == SM &&
86+
// PTX 9.0 and later renamed sm_101 to sm_110, so sm_101 is not
87+
// supported.
88+
!(PTXVer >= 90 && SMVer == 101);
89+
90+
return getSmFamilyVersion() == SM / 10 && SMVer >= SM;
8291
});
8392
}
8493

8594
bool NVPTXSubtarget::hasPTXWithAccelSMs(unsigned PTXVersion,
8695
ArrayRef<unsigned> SMVersions) const {
87-
if (!hasArchAccelFeatures() || getPTXVersion() < PTXVersion)
96+
unsigned PTXVer = getPTXVersion();
97+
if (!hasArchAccelFeatures() || PTXVer < PTXVersion)
8898
return false;
8999

90-
return llvm::any_of(SMVersions,
91-
[&](unsigned SM) { return getSmVersion() == SM; });
100+
unsigned SMVer = getSmVersion();
101+
return llvm::any_of(SMVersions, [&](unsigned SM) {
102+
return SMVer == SM &&
103+
// PTX 9.0 and later renamed sm_101 to sm_110, so sm_101 is not
104+
// supported.
105+
!(PTXVer >= 90 && SMVer == 101);
106+
});
92107
}
93108

94109
bool NVPTXSubtarget::allowFP16Math() const {

llvm/lib/Target/NVPTX/NVPTXSubtarget.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
7575

7676
// Checks PTX version and family-specific and architecture-specific SM
7777
// versions. For example, sm_100{f/a} and any future variants in the same
78-
// family will match.
78+
// family will match for any PTX version greater than or equal to
79+
// `PTXVersion`.
7980
bool hasPTXWithFamilySMs(unsigned PTXVersion,
8081
ArrayRef<unsigned> SMVersions) const;
8182
// Checks PTX version and architecture-specific SM versions.
82-
// For example, sm_100{a} will match.
83+
// For example, sm_100{a} will match for any PTX version greater than or equal
84+
// to `PTXVersion`.
8385
bool hasPTXWithAccelSMs(unsigned PTXVersion,
8486
ArrayRef<unsigned> SMVersions) const;
8587

0 commit comments

Comments
 (0)