[Mlir-commits] [mlir] [mlir][NFC] Wrap TimingManager components into namespace (PR #167298)

Andrei Golubev llvmlistbot at llvm.org
Mon Nov 10 03:08:17 PST 2025


https://github.com/andrey-golubev created https://github.com/llvm/llvm-project/pull/167298

TimingManager and its components (e.g. helper classes and utility functions) reside in mlir namespace. Certain components are generic enough that it makes sense to enclose them into an additional namespace.

>From 9792b65709394f735fad53f5acf925b6e377af52 Mon Sep 17 00:00:00 2001
From: "Golubev, Andrey" <andrey.golubev at intel.com>
Date: Mon, 10 Nov 2025 11:09:19 +0000
Subject: [PATCH] [mlir][NFC] Wrap TimingManager components into namespace

TimingManager and its components (e.g. helper classes and utility
functions) reside in mlir namespace. Certain components are generic
enough that it makes sense to enclose them into an additional namespace.
---
 mlir/include/mlir/Support/Timing.h | 8 ++++++--
 mlir/lib/Support/Timing.cpp        | 5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/mlir/include/mlir/Support/Timing.h b/mlir/include/mlir/Support/Timing.h
index 50ae84735dbf0..19ec3c41e36a1 100644
--- a/mlir/include/mlir/Support/Timing.h
+++ b/mlir/include/mlir/Support/Timing.h
@@ -320,6 +320,7 @@ class TimingScope {
   Timer timer;
 };
 
+namespace timing {
 //===----------------------------------------------------------------------===//
 // OutputStrategy
 //===----------------------------------------------------------------------===//
@@ -366,6 +367,7 @@ class OutputStrategy {
 
   raw_ostream &os;
 };
+} // namespace timing
 
 //===----------------------------------------------------------------------===//
 // DefaultTimingManager
@@ -428,7 +430,7 @@ class DefaultTimingManager : public TimingManager {
   DisplayMode getDisplayMode() const;
 
   /// Change the stream where the output will be printed to.
-  void setOutput(std::unique_ptr<OutputStrategy> output);
+  void setOutput(std::unique_ptr<timing::OutputStrategy> output);
 
   /// Print and clear the timing results. Only call this when there are no more
   /// references to nested timers around, as printing post-processes and clears
@@ -461,7 +463,7 @@ class DefaultTimingManager : public TimingManager {
 
 private:
   const std::unique_ptr<detail::DefaultTimingManagerImpl> impl;
-  std::unique_ptr<OutputStrategy> out;
+  std::unique_ptr<timing::OutputStrategy> out;
 };
 
 /// Register a set of useful command-line options that can be used to configure
@@ -473,10 +475,12 @@ void registerDefaultTimingManagerCLOptions();
 /// 'registerDefaultTimingManagerOptions' to a `DefaultTimingManager`.
 void applyDefaultTimingManagerCLOptions(DefaultTimingManager &tm);
 
+namespace timing {
 /// Create an output strategy for the specified format, to be passed to
 /// DefaultTimingManager::setOutput().
 std::unique_ptr<OutputStrategy>
 createOutputStrategy(DefaultTimingManager::OutputFormat fmt, raw_ostream &os);
+} // namespace timing
 
 } // namespace mlir
 
diff --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp
index b0ac3798bc984..23e5e1ef4fcd4 100644
--- a/mlir/lib/Support/Timing.cpp
+++ b/mlir/lib/Support/Timing.cpp
@@ -28,6 +28,7 @@
 #include <optional>
 
 using namespace mlir;
+using namespace mlir::timing;
 using namespace detail;
 using DisplayMode = DefaultTimingManager::DisplayMode;
 using OutputFormat = DefaultTimingManager::OutputFormat;
@@ -623,8 +624,8 @@ void mlir::applyDefaultTimingManagerCLOptions(DefaultTimingManager &tm) {
 }
 
 std::unique_ptr<OutputStrategy>
-mlir::createOutputStrategy(DefaultTimingManager::OutputFormat fmt,
-                           raw_ostream &os) {
+mlir::timing::createOutputStrategy(DefaultTimingManager::OutputFormat fmt,
+                                   raw_ostream &os) {
   switch (fmt) {
   case OutputFormat::Text:
     return std::make_unique<OutputTextStrategy>(os);



More information about the Mlir-commits mailing list