[libc-commits] [libc] [libc] reorder member variables and functions for better organization (PR #85812)

via libc-commits libc-commits at lists.llvm.org
Tue Mar 19 09:23:41 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: None (caIicate)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/85812.diff


1 Files Affected:

- (modified) libc/benchmarks/LibcMemoryBenchmark.cpp (+70) 


``````````diff
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) {}
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/85812


More information about the libc-commits mailing list