|
24 | 24 | #include <thread>
|
25 | 25 | #include <vector>
|
26 | 26 |
|
| 27 | +using namespace mlir::runtime; |
| 28 | + |
27 | 29 | //===----------------------------------------------------------------------===//
|
28 | 30 | // Async runtime API.
|
29 | 31 | //===----------------------------------------------------------------------===//
|
30 | 32 |
|
| 33 | +namespace mlir { |
| 34 | +namespace runtime { |
31 | 35 | namespace {
|
32 | 36 |
|
33 | 37 | // Forward declare class defined below.
|
@@ -66,12 +70,6 @@ class AsyncRuntime {
|
66 | 70 | std::atomic<int32_t> numRefCountedObjects;
|
67 | 71 | };
|
68 | 72 |
|
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 |
| - |
75 | 73 | // -------------------------------------------------------------------------- //
|
76 | 74 | // A base class for all reference counted objects created by the async runtime.
|
77 | 75 | // -------------------------------------------------------------------------- //
|
@@ -110,6 +108,12 @@ class RefCounted {
|
110 | 108 |
|
111 | 109 | } // namespace
|
112 | 110 |
|
| 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 | + |
113 | 117 | struct AsyncToken : public RefCounted {
|
114 | 118 | // AsyncToken created with a reference count of 2 because it will be returned
|
115 | 119 | // to the `async.execute` caller and also will be later on emplaced by the
|
@@ -140,6 +144,9 @@ struct AsyncGroup : public RefCounted {
|
140 | 144 | std::vector<std::function<void()>> awaiters;
|
141 | 145 | };
|
142 | 146 |
|
| 147 | +} // namespace runtime |
| 148 | +} // namespace mlir |
| 149 | + |
143 | 150 | // Adds references to reference counted runtime object.
|
144 | 151 | extern "C" void mlirAsyncRuntimeAddRef(RefCountedObjPtr ptr, int32_t count) {
|
145 | 152 | RefCounted *refCounted = static_cast<RefCounted *>(ptr);
|
|
0 commit comments