[Mlir-commits] [mlir] 6fd9e59 - [mlir] Fix exports in mlir_async_runtime
Renato Golin
llvmlistbot at llvm.org
Wed Nov 11 06:11:40 PST 2020
Author: Paul Lietar
Date: 2020-11-11T14:11:16Z
New Revision: 6fd9e59e1b3ac15430eccd4011e063605f58039c
URL: https://github.com/llvm/llvm-project/commit/6fd9e59e1b3ac15430eccd4011e063605f58039c
DIFF: https://github.com/llvm/llvm-project/commit/6fd9e59e1b3ac15430eccd4011e063605f58039c.diff
LOG: [mlir] Fix exports in mlir_async_runtime
The MLIR_ASYNCRUNTIME_EXPORT macro was being defined to be either
__declspec(dllexport) or __declspec(dllimport), depending on whether
mlir_c_runner_utils_EXPORTS is defined. The latter was a copy/paste
error and should have been mlir_async_runtime_EXPORTS.
Additionally, the uses of that macro in the .cpp file were unnecessary,
as only function declarations need to be exported, not their definitions.
Differential Revision: https://reviews.llvm.org/D91196
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 f3fcbb98c208..e47c71c44dfc 100644
--- a/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
+++ b/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h
@@ -16,14 +16,14 @@
#ifdef _WIN32
#ifndef MLIR_ASYNCRUNTIME_EXPORT
-#ifdef mlir_c_runner_utils_EXPORTS
+#ifdef mlir_async_runtime_EXPORTS
// We are building this library
#define MLIR_ASYNCRUNTIME_EXPORT __declspec(dllexport)
#define MLIR_ASYNCRUNTIME_DEFINE_FUNCTIONS
#else
// We are using this library
#define MLIR_ASYNCRUNTIME_EXPORT __declspec(dllimport)
-#endif // mlir_c_runner_utils_EXPORTS
+#endif // mlir_async_runtime_EXPORTS
#endif // MLIR_ASYNCRUNTIME_EXPORT
#else
#define MLIR_ASYNCRUNTIME_EXPORT
diff --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
index c4d1bba954cc..9af1a8d89020 100644
--- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
+++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
@@ -34,14 +34,13 @@ struct AsyncToken {
};
// Create a new `async.token` in not-ready state.
-extern "C" MLIR_ASYNCRUNTIME_EXPORT AsyncToken *mlirAsyncRuntimeCreateToken() {
+extern "C" AsyncToken *mlirAsyncRuntimeCreateToken() {
AsyncToken *token = new AsyncToken;
return token;
}
// Switches `async.token` to ready state and runs all awaiters.
-extern "C" MLIR_ASYNCRUNTIME_EXPORT void
-mlirAsyncRuntimeEmplaceToken(AsyncToken *token) {
+extern "C" void mlirAsyncRuntimeEmplaceToken(AsyncToken *token) {
std::unique_lock<std::mutex> lock(token->mu);
token->ready = true;
token->cv.notify_all();
@@ -49,16 +48,14 @@ mlirAsyncRuntimeEmplaceToken(AsyncToken *token) {
awaiter();
}
-extern "C" MLIR_ASYNCRUNTIME_EXPORT void
-mlirAsyncRuntimeAwaitToken(AsyncToken *token) {
+extern "C" void mlirAsyncRuntimeAwaitToken(AsyncToken *token) {
std::unique_lock<std::mutex> lock(token->mu);
if (!token->ready)
token->cv.wait(lock, [token] { return token->ready; });
delete token;
}
-extern "C" MLIR_ASYNCRUNTIME_EXPORT void
-mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) {
+extern "C" void mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) {
#if LLVM_ENABLE_THREADS
std::thread thread([handle, resume]() { (*resume)(handle); });
thread.detach();
@@ -67,9 +64,9 @@ mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) {
#endif
}
-extern "C" MLIR_ASYNCRUNTIME_EXPORT void
-mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token, CoroHandle handle,
- CoroResume resume) {
+extern "C" void mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token,
+ CoroHandle handle,
+ CoroResume resume) {
std::unique_lock<std::mutex> lock(token->mu);
auto execute = [token, handle, resume]() {
@@ -87,8 +84,7 @@ mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token, CoroHandle handle,
// Small async runtime support library for testing.
//===----------------------------------------------------------------------===//
-extern "C" MLIR_ASYNCRUNTIME_EXPORT void
-mlirAsyncRuntimePrintCurrentThreadId() {
+extern "C" void mlirAsyncRuntimePrintCurrentThreadId() {
static thread_local std::thread::id thisId = std::this_thread::get_id();
std::cout << "Current thread id: " << thisId << "\n";
}
More information about the Mlir-commits
mailing list