[llvm] 8fe3d9d - Revert "[ORC] Move SimpleRemoteEPCServer::Dispatcher into OrcShared."
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 8 13:43:50 PDT 2021
Author: Lang Hames
Date: 2021-10-08T13:43:42-07:00
New Revision: 8fe3d9df0ed384037cb3789096e0dcabd6d27138
URL: https://github.com/llvm/llvm-project/commit/8fe3d9df0ed384037cb3789096e0dcabd6d27138
DIFF: https://github.com/llvm/llvm-project/commit/8fe3d9df0ed384037cb3789096e0dcabd6d27138.diff
LOG: Revert "[ORC] Move SimpleRemoteEPCServer::Dispatcher into OrcShared."
This reverts commit dfd74db9813b0c7c64038c303726ba43f335e07a.
SimpleRemoteEPC should share dispatch with the ExecutionSession, rather than
having two different dispatch systems on the controller side.
SimpleRemoteEPCServer::Dispatch doesn't need to be shared.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h
llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
llvm/tools/lli/ChildTarget/ChildTarget.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
index 5cd178cdeb867..44c56479c7c34 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
@@ -15,7 +15,6 @@
#define LLVM_EXECUTIONENGINE_ORC_SHARED_SIMPLEREMOTEEPCUTILS_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
@@ -140,29 +139,6 @@ class FDSimpleRemoteEPCTransport : public SimpleRemoteEPCTransport {
std::atomic<bool> Disconnected{false};
};
-/// Dispatches calls to runWrapper.
-class SimpleRemoteEPCDispatcher {
-public:
- virtual ~SimpleRemoteEPCDispatcher();
- virtual void dispatch(unique_function<void()> Work) = 0;
- virtual void shutdown() = 0;
-};
-
-#if LLVM_ENABLE_THREADS
-class DynamicThreadPoolSimpleRemoteEPCDispatcher
- : public SimpleRemoteEPCDispatcher {
-public:
- void dispatch(unique_function<void()> Work) override;
- void shutdown() override;
-
-private:
- std::mutex DispatchMutex;
- bool Running = true;
- size_t Outstanding = 0;
- std::condition_variable OutstandingCV;
-};
-#endif
-
struct RemoteSymbolLookupSetElement {
std::string Name;
bool Required;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h
index dd721203410b4..38c413db2e947 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h
@@ -37,6 +37,28 @@ class SimpleRemoteEPCServer : public SimpleRemoteEPCTransportClient {
public:
using ReportErrorFunction = unique_function<void(Error)>;
+ /// Dispatches calls to runWrapper.
+ class Dispatcher {
+ public:
+ virtual ~Dispatcher();
+ virtual void dispatch(unique_function<void()> Work) = 0;
+ virtual void shutdown() = 0;
+ };
+
+#if LLVM_ENABLE_THREADS
+ class ThreadDispatcher : public Dispatcher {
+ public:
+ void dispatch(unique_function<void()> Work) override;
+ void shutdown() override;
+
+ private:
+ std::mutex DispatchMutex;
+ bool Running = true;
+ size_t Outstanding = 0;
+ std::condition_variable OutstandingCV;
+ };
+#endif
+
class Setup {
friend class SimpleRemoteEPCServer;
@@ -46,9 +68,7 @@ class SimpleRemoteEPCServer : public SimpleRemoteEPCTransportClient {
std::vector<std::unique_ptr<ExecutorBootstrapService>> &services() {
return Services;
}
- void setDispatcher(std::unique_ptr<SimpleRemoteEPCDispatcher> D) {
- S.D = std::move(D);
- }
+ void setDispatcher(std::unique_ptr<Dispatcher> D) { S.D = std::move(D); }
void setErrorReporter(unique_function<void(Error)> ReportError) {
S.ReportError = std::move(ReportError);
}
@@ -146,7 +166,7 @@ class SimpleRemoteEPCServer : public SimpleRemoteEPCTransportClient {
enum { ServerRunning, ServerShuttingDown, ServerShutDown } RunState;
Error ShutdownErr = Error::success();
std::unique_ptr<SimpleRemoteEPCTransport> T;
- std::unique_ptr<SimpleRemoteEPCDispatcher> D;
+ std::unique_ptr<Dispatcher> D;
std::vector<std::unique_ptr<ExecutorBootstrapService>> Services;
ReportErrorFunction ReportError;
diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
index 37d57c0d2d1bf..62f4ff8a34090 100644
--- a/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
@@ -241,32 +241,5 @@ void FDSimpleRemoteEPCTransport::listenLoop() {
C.handleDisconnect(std::move(Err));
}
-SimpleRemoteEPCDispatcher::~SimpleRemoteEPCDispatcher() {}
-
-#if LLVM_ENABLE_THREADS
-void DynamicThreadPoolSimpleRemoteEPCDispatcher::dispatch(
- unique_function<void()> Work) {
- {
- std::lock_guard<std::mutex> Lock(DispatchMutex);
- if (!Running)
- return;
- ++Outstanding;
- }
-
- std::thread([this, Work = std::move(Work)]() mutable {
- Work();
- std::lock_guard<std::mutex> Lock(DispatchMutex);
- --Outstanding;
- OutstandingCV.notify_all();
- }).detach();
-}
-
-void DynamicThreadPoolSimpleRemoteEPCDispatcher::shutdown() {
- std::unique_lock<std::mutex> Lock(DispatchMutex);
- Running = false;
- OutstandingCV.wait(Lock, [this]() { return Outstanding == 0; });
-}
-#endif
-
} // end namespace orc
} // end namespace llvm
diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
index f548ce25093af..558209928a292 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
@@ -24,6 +24,33 @@ namespace orc {
ExecutorBootstrapService::~ExecutorBootstrapService() {}
+SimpleRemoteEPCServer::Dispatcher::~Dispatcher() {}
+
+#if LLVM_ENABLE_THREADS
+void SimpleRemoteEPCServer::ThreadDispatcher::dispatch(
+ unique_function<void()> Work) {
+ {
+ std::lock_guard<std::mutex> Lock(DispatchMutex);
+ if (!Running)
+ return;
+ ++Outstanding;
+ }
+
+ std::thread([this, Work = std::move(Work)]() mutable {
+ Work();
+ std::lock_guard<std::mutex> Lock(DispatchMutex);
+ --Outstanding;
+ OutstandingCV.notify_all();
+ }).detach();
+}
+
+void SimpleRemoteEPCServer::ThreadDispatcher::shutdown() {
+ std::unique_lock<std::mutex> Lock(DispatchMutex);
+ Running = false;
+ OutstandingCV.wait(Lock, [this]() { return Outstanding == 0; });
+}
+#endif
+
StringMap<ExecutorAddr> SimpleRemoteEPCServer::defaultBootstrapSymbols() {
StringMap<ExecutorAddr> DBS;
rt_bootstrap::addTo(DBS);
diff --git a/llvm/tools/lli/ChildTarget/ChildTarget.cpp b/llvm/tools/lli/ChildTarget/ChildTarget.cpp
index a9e330984ef90..cf1b03a141c5e 100644
--- a/llvm/tools/lli/ChildTarget/ChildTarget.cpp
+++ b/llvm/tools/lli/ChildTarget/ChildTarget.cpp
@@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
ExitOnErr(SimpleRemoteEPCServer::Create<FDSimpleRemoteEPCTransport>(
[](SimpleRemoteEPCServer::Setup &S) -> Error {
S.setDispatcher(
- std::make_unique<DynamicThreadPoolSimpleRemoteEPCDispatcher>());
+ std::make_unique<SimpleRemoteEPCServer::ThreadDispatcher>());
S.bootstrapSymbols() =
SimpleRemoteEPCServer::defaultBootstrapSymbols();
S.services().push_back(
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
index b1ba6a9e6bac3..7100c274b988b 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp
@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) {
ExitOnErr(SimpleRemoteEPCServer::Create<FDSimpleRemoteEPCTransport>(
[](SimpleRemoteEPCServer::Setup &S) -> Error {
S.setDispatcher(
- std::make_unique<DynamicThreadPoolSimpleRemoteEPCDispatcher>());
+ std::make_unique<SimpleRemoteEPCServer::ThreadDispatcher>());
S.bootstrapSymbols() =
SimpleRemoteEPCServer::defaultBootstrapSymbols();
S.services().push_back(
More information about the llvm-commits
mailing list