Skip to content

Commit 11f1027

Browse files
committed
[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
1 parent 4e90cad commit 11f1027

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

mlir/include/mlir/ExecutionEngine/AsyncRuntime.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#define MLIR_ASYNCRUNTIME_DEFINE_FUNCTIONS
3333
#endif // _WIN32
3434

35+
namespace mlir {
36+
namespace runtime {
37+
3538
//===----------------------------------------------------------------------===//
3639
// Async runtime API.
3740
//===----------------------------------------------------------------------===//
@@ -102,4 +105,7 @@ mlirAsyncRuntimeAwaitAllInGroupAndExecute(AsyncGroup *, CoroHandle, CoroResume);
102105

103106
extern "C" MLIR_ASYNCRUNTIME_EXPORT void mlirAsyncRuntimePrintCurrentThreadId();
104107

108+
} // namespace runtime
109+
} // namespace mlir
110+
105111
#endif // MLIR_EXECUTIONENGINE_ASYNCRUNTIME_H_

mlir/lib/ExecutionEngine/AsyncRuntime.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424
#include <thread>
2525
#include <vector>
2626

27+
using namespace mlir::runtime;
28+
2729
//===----------------------------------------------------------------------===//
2830
// Async runtime API.
2931
//===----------------------------------------------------------------------===//
3032

33+
namespace mlir {
34+
namespace runtime {
3135
namespace {
3236

3337
// Forward declare class defined below.
@@ -66,12 +70,6 @@ class AsyncRuntime {
6670
std::atomic<int32_t> numRefCountedObjects;
6771
};
6872

69-
// Returns the default per-process instance of an async runtime.
70-
AsyncRuntime *getDefaultAsyncRuntimeInstance() {
71-
static auto runtime = std::make_unique<AsyncRuntime>();
72-
return runtime.get();
73-
}
74-
7573
// -------------------------------------------------------------------------- //
7674
// A base class for all reference counted objects created by the async runtime.
7775
// -------------------------------------------------------------------------- //
@@ -110,6 +108,12 @@ class RefCounted {
110108

111109
} // namespace
112110

111+
// Returns the default per-process instance of an async runtime.
112+
static AsyncRuntime *getDefaultAsyncRuntimeInstance() {
113+
static auto runtime = std::make_unique<AsyncRuntime>();
114+
return runtime.get();
115+
}
116+
113117
struct AsyncToken : public RefCounted {
114118
// AsyncToken created with a reference count of 2 because it will be returned
115119
// to the `async.execute` caller and also will be later on emplaced by the
@@ -140,6 +144,9 @@ struct AsyncGroup : public RefCounted {
140144
std::vector<std::function<void()>> awaiters;
141145
};
142146

147+
} // namespace runtime
148+
} // namespace mlir
149+
143150
// Adds references to reference counted runtime object.
144151
extern "C" void mlirAsyncRuntimeAddRef(RefCountedObjPtr ptr, int32_t count) {
145152
RefCounted *refCounted = static_cast<RefCounted *>(ptr);

0 commit comments

Comments
 (0)