-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] reorder member variables and functions for better organization #85812
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
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-libc Author: None (caIicate) ChangesFull diff: https://github.com/llvm/llvm-project/pull/85812.diff 1 Files Affected:
diff --git a/libc/benchmarks/LibcMemoryBenchmark.cpp b/libc/benchmarks/LibcMemoryBenchmark.cpp
index 3ced306584d151..455680990eeebe 100644
--- a/libc/benchmarks/LibcMemoryBenchmark.cpp
+++ b/libc/benchmarks/LibcMemoryBenchmark.cpp
@@ -40,6 +40,16 @@ getOffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
return std::uniform_int_distribution<uint32_t>(0, MaxOffset);
}
+class OffsetDistribution {
+public:
+ OffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
+ MaybeAlign AccessAlignment);
+
+private:
+ std::uniform_int_distribution<uint32_t> Distribution;
+ size_t Factor;
+};
+
OffsetDistribution::OffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
MaybeAlign AccessAlignment)
: Distribution(
@@ -47,6 +57,16 @@ OffsetDistribution::OffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
Factor(AccessAlignment.valueOrOne().value()) {}
// Precomputes offset where to insert mismatches between the two buffers.
+class MismatchOffsetDistribution {
+public:
+ MismatchOffsetDistribution(size_t BufferSize, size_t MaxSizeValue, size_t MismatchAt);
+
+private:
+ size_t MismatchAt;
+ std::vector<size_t> MismatchIndices;
+ std::uniform_int_distribution<size_t> MismatchIndexSelector;
+};
+
MismatchOffsetDistribution::MismatchOffsetDistribution(size_t BufferSize,
size_t MaxSizeValue,
size_t MismatchAt)
@@ -80,6 +100,18 @@ static size_t getAvailableBufferSize() {
return getL1DataCacheSize() - L1LeftAsideBytes - ParameterStorageBytes;
}
+class ParameterBatch {
+public:
+ ParameterBatch(size_t BufferCount);
+ size_t getBatchBytes() const;
+ void checkValid(const ParameterType &P) const;
+
+private:
+ size_t BufferSize;
+ size_t BatchSize;
+ std::vector<ParameterType> Parameters;
+};
+
ParameterBatch::ParameterBatch(size_t BufferCount)
: BufferSize(getAvailableBufferSize() / BufferCount),
BatchSize(ParameterStorageBytes / sizeof(ParameterType)),
@@ -113,13 +145,42 @@ void ParameterBatch::checkValid(const ParameterType &P) const {
.concat(llvm::Twine(BufferSize)));
}
+class CopySetup {
+public:
+ CopySetup();
+
+private:
+ ParameterBatch ParameterBatch;
+ AlignedBuffer SrcBuffer;
+ AlignedBuffer DstBuffer;
+};
+
CopySetup::CopySetup()
: ParameterBatch(2), SrcBuffer(ParameterBatch::BufferSize),
DstBuffer(ParameterBatch::BufferSize) {}
+class MoveSetup {
+public:
+ MoveSetup();
+
+private:
+ ParameterBatch ParameterBatch;
+ AlignedBuffer Buffer;
+};
+
MoveSetup::MoveSetup()
: ParameterBatch(3), Buffer(ParameterBatch::BufferSize * 3) {}
+class ComparisonSetup {
+public:
+ ComparisonSetup();
+
+private:
+ ParameterBatch ParameterBatch;
+ AlignedBuffer LhsBuffer;
+ AlignedBuffer RhsBuffer;
+};
+
ComparisonSetup::ComparisonSetup()
: ParameterBatch(2), LhsBuffer(ParameterBatch::BufferSize),
RhsBuffer(ParameterBatch::BufferSize) {
@@ -128,6 +189,15 @@ ComparisonSetup::ComparisonSetup()
memset(RhsBuffer.begin(), 0xF, BufferSize);
}
+class SetSetup {
+public:
+ SetSetup();
+
+private:
+ ParameterBatch ParameterBatch;
+ AlignedBuffer DstBuffer;
+};
+
SetSetup::SetSetup()
: ParameterBatch(1), DstBuffer(ParameterBatch::BufferSize) {}
|
You can test this locally with the following command:git-clang-format --diff 252e2551eab9b59f7dcbf8bb79a1432884d546e4 f7999cda9853944bbb77dd380bf24c575c885537 -- libc/benchmarks/LibcMemoryBenchmark.cpp View the diff from clang-format here.diff --git a/libc/benchmarks/LibcMemoryBenchmark.cpp b/libc/benchmarks/LibcMemoryBenchmark.cpp
index 455680990e..fcfc427f68 100644
--- a/libc/benchmarks/LibcMemoryBenchmark.cpp
+++ b/libc/benchmarks/LibcMemoryBenchmark.cpp
@@ -59,7 +59,8 @@ OffsetDistribution::OffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
// Precomputes offset where to insert mismatches between the two buffers.
class MismatchOffsetDistribution {
public:
- MismatchOffsetDistribution(size_t BufferSize, size_t MaxSizeValue, size_t MismatchAt);
+ MismatchOffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
+ size_t MismatchAt);
private:
size_t MismatchAt;
|
Thanks for the patch! Please run |
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.
These are declared in libc/benchmarks/LibcMemoryBenchmark.h. There's no point redeclaring them.
Closing for now since this patch seems to be abandoned. Feel free to reopen it or open a new one |
No description provided.