-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[AMDGPU][NFC] dump Waitcnt using an ostream operator #171251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-backend-amdgpu Author: Sameer Sahasrabuddhe (ssahasra) ChangesFull diff: https://github.com/llvm/llvm-project/pull/171251.diff 3 Files Affected:
diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h
index 2440e7678a831..abdf5337d68b2 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -541,6 +541,7 @@ class ListSeparator {
}
return Separator;
}
+ bool unused() { return First; }
};
/// A forward iterator over partitions of string over a separator.
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index c6e061f368aef..e2cec29ae3611 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -1712,6 +1712,30 @@ bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val) {
return false;
}
+raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait) {
+ ListSeparator LS;
+ if (Wait.LoadCnt != ~0u)
+ OS << LS << " LoadCnt: " << Wait.LoadCnt;
+ if (Wait.ExpCnt != ~0u)
+ OS << LS << " ExpCnt: " << Wait.ExpCnt;
+ if (Wait.DsCnt != ~0u)
+ OS << LS << " DsCnt: " << Wait.DsCnt;
+ if (Wait.StoreCnt != ~0u)
+ OS << LS << " StoreCnt: " << Wait.StoreCnt;
+ if (Wait.SampleCnt != ~0u)
+ OS << LS << " SampleCnt: " << Wait.SampleCnt;
+ if (Wait.BvhCnt != ~0u)
+ OS << LS << " BvhCnt: " << Wait.BvhCnt;
+ if (Wait.KmCnt != ~0u)
+ OS << LS << " KmCnt: " << Wait.KmCnt;
+ if (Wait.XCnt != ~0u)
+ OS << LS << " XCnt: " << Wait.XCnt;
+ if (LS.unused())
+ OS << " none";
+ OS << '\n';
+ return OS;
+}
+
unsigned getVmcntBitMask(const IsaVersion &Version) {
return (1 << (getVmcntBitWidthLo(Version.Major) +
getVmcntBitWidthHi(Version.Major))) -
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index 3a352006e006c..75db58a292c13 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -1119,6 +1119,8 @@ struct Waitcnt {
std::min(SampleCnt, Other.SampleCnt), std::min(BvhCnt, Other.BvhCnt),
std::min(KmCnt, Other.KmCnt), std::min(XCnt, Other.XCnt));
}
+
+ friend raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait);
};
// The following methods are only meaningful on targets that support
|
|
@llvm/pr-subscribers-llvm-adt Author: Sameer Sahasrabuddhe (ssahasra) ChangesFull diff: https://github.com/llvm/llvm-project/pull/171251.diff 3 Files Affected:
diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h
index 2440e7678a831..abdf5337d68b2 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -541,6 +541,7 @@ class ListSeparator {
}
return Separator;
}
+ bool unused() { return First; }
};
/// A forward iterator over partitions of string over a separator.
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index c6e061f368aef..e2cec29ae3611 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -1712,6 +1712,30 @@ bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val) {
return false;
}
+raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait) {
+ ListSeparator LS;
+ if (Wait.LoadCnt != ~0u)
+ OS << LS << " LoadCnt: " << Wait.LoadCnt;
+ if (Wait.ExpCnt != ~0u)
+ OS << LS << " ExpCnt: " << Wait.ExpCnt;
+ if (Wait.DsCnt != ~0u)
+ OS << LS << " DsCnt: " << Wait.DsCnt;
+ if (Wait.StoreCnt != ~0u)
+ OS << LS << " StoreCnt: " << Wait.StoreCnt;
+ if (Wait.SampleCnt != ~0u)
+ OS << LS << " SampleCnt: " << Wait.SampleCnt;
+ if (Wait.BvhCnt != ~0u)
+ OS << LS << " BvhCnt: " << Wait.BvhCnt;
+ if (Wait.KmCnt != ~0u)
+ OS << LS << " KmCnt: " << Wait.KmCnt;
+ if (Wait.XCnt != ~0u)
+ OS << LS << " XCnt: " << Wait.XCnt;
+ if (LS.unused())
+ OS << " none";
+ OS << '\n';
+ return OS;
+}
+
unsigned getVmcntBitMask(const IsaVersion &Version) {
return (1 << (getVmcntBitWidthLo(Version.Major) +
getVmcntBitWidthHi(Version.Major))) -
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index 3a352006e006c..75db58a292c13 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -1119,6 +1119,8 @@ struct Waitcnt {
std::min(SampleCnt, Other.SampleCnt), std::min(BvhCnt, Other.BvhCnt),
std::min(KmCnt, Other.KmCnt), std::min(XCnt, Other.XCnt));
}
+
+ friend raw_ostream &operator<<(raw_ostream &OS, const AMDGPU::Waitcnt &Wait);
};
// The following methods are only meaningful on targets that support
|
arsenm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not actually used? Should this be marked with LLVM_DUMP_METHOD?
I looked at other instance of ostream operators, but couldn't find any that are marked as LLVM_DUMP_METHOD. As far as I understood, that attribute is meant for actual functions that might be called from a debugger, and hence should not be stripped from a debug build even if they appear to be unused. That doesn't seem necessary for this operator. It's okay if it gets stripped if it is unused. Separately, I added a use for the operator anyway. More uses will show up with other changes in si-insert-waitcnts later. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/34757 Here is the relevant piece of the build log for the reference |
No description provided.