[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
This commit is contained in:
Eugene Zhulenev 2020-12-16 05:14:12 -08:00
parent 4e90cad6a6
commit 11f1027b4d
2 changed files with 19 additions and 6 deletions

View File

@ -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_

View File

@ -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 @@ private:
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 @@ private:
} // 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);