[llvm-branch-commits] [mlir] 11f1027 - [mlir] AsyncRuntime: mode runtime declarations to mlir::runtime namespace

Eugene Zhulenev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 16 11:09:25 PST 2020


Author: Eugene Zhulenev
Date: 2020-12-16T11:05:21-08:00
New Revision: 11f1027b4d8d851c94497330bb901bd5753188f3

URL: https://github.com/llvm/llvm-project/commit/11f1027b4d8d851c94497330bb901bd5753188f3
DIFF: https://github.com/llvm/llvm-project/commit/11f1027b4d8d851c94497330bb901bd5753188f3.diff

LOG: [mlir] AsyncRuntime: mode runtime declarations to mlir::runtime namespace

Define Async runtime related typedefs in the `mlir::runtime` namespace.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D93391

Added: 
    

Modified: 
    mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
    mlir/lib/ExecutionEngine/AsyncRuntime.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h b/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
index 54724af4133d..e3d90198f36c 100644
--- a/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
+++ b/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
@@ -32,6 +32,9 @@
 #define MLIR_ASYNCRUNTIME_DEFINE_FUNCTIONS
 #endif // _WIN32
 
+namespace mlir {
+namespace runtime {
+
 //===----------------------------------------------------------------------===//
 // Async runtime API.
 //===----------------------------------------------------------------------===//
@@ -102,4 +105,7 @@ mlirAsyncRuntimeAwaitAllInGroupAndExecute(AsyncGroup *, CoroHandle, CoroResume);
 
 extern "C" MLIR_ASYNCRUNTIME_EXPORT void mlirAsyncRuntimePrintCurrentThreadId();
 
+} // namespace runtime
+} // namespace mlir
+
 #endif // MLIR_EXECUTIONENGINE_ASYNCRUNTIME_H_

diff  --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
index 3b90b9c694f3..3bfed86aa996 100644
--- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
+++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
@@ -24,10 +24,14 @@
 #include <thread>
 #include <vector>
 
+using namespace mlir::runtime;
+
 //===----------------------------------------------------------------------===//
 // Async runtime API.
 //===----------------------------------------------------------------------===//
 
+namespace mlir {
+namespace runtime {
 namespace {
 
 // Forward declare class defined below.
@@ -66,12 +70,6 @@ class AsyncRuntime {
   std::atomic<int32_t> numRefCountedObjects;
 };
 
-// Returns the default per-process instance of an async runtime.
-AsyncRuntime *getDefaultAsyncRuntimeInstance() {
-  static auto runtime = std::make_unique<AsyncRuntime>();
-  return runtime.get();
-}
-
 // -------------------------------------------------------------------------- //
 // A base class for all reference counted objects created by the async runtime.
 // -------------------------------------------------------------------------- //
@@ -110,6 +108,12 @@ class RefCounted {
 
 } // namespace
 
+// Returns the default per-process instance of an async runtime.
+static AsyncRuntime *getDefaultAsyncRuntimeInstance() {
+  static auto runtime = std::make_unique<AsyncRuntime>();
+  return runtime.get();
+}
+
 struct AsyncToken : public RefCounted {
   // AsyncToken created with a reference count of 2 because it will be returned
   // to the `async.execute` caller and also will be later on emplaced by the
@@ -140,6 +144,9 @@ struct AsyncGroup : public RefCounted {
   std::vector<std::function<void()>> awaiters;
 };
 
+} // namespace runtime
+} // namespace mlir
+
 // Adds references to reference counted runtime object.
 extern "C" void mlirAsyncRuntimeAddRef(RefCountedObjPtr ptr, int32_t count) {
   RefCounted *refCounted = static_cast<RefCounted *>(ptr);


        


More information about the llvm-branch-commits mailing list