[llvm] dfd74db - [ORC] Move SimpleRemoteEPCServer::Dispatcher into OrcShared.
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 8 11:43:14 PDT 2021
In file included from
../../llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp:9:
In file included from
../../llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h:18:
../../llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h:161:8:
error: no type named 'condition_variable' in namespace 'std'
std::condition_variable OutstandingCV;
~~~~~^
1 error generated.
Fixed in dd384d28140.
On Fri, Oct 8, 2021 at 11:30 AM Lang Hames via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
>
> Author: Lang Hames
> Date: 2021-10-08T11:29:57-07:00
> New Revision: dfd74db9813b0c7c64038c303726ba43f335e07a
>
> URL:
> https://github.com/llvm/llvm-project/commit/dfd74db9813b0c7c64038c303726ba43f335e07a
> DIFF:
> https://github.com/llvm/llvm-project/commit/dfd74db9813b0c7c64038c303726ba43f335e07a.diff
>
> LOG: [ORC] Move SimpleRemoteEPCServer::Dispatcher into OrcShared.
>
> Renames SimpleRemoteEPCServer::Dispatcher to SimpleRemoteEPCDispatcher and
> moves it into OrcShared. SimpleRemoteEPCServer::ThreadDispatcher is
> similarly
> moved and renamed to DynamicThreadPoolSimpleRemoteEPCDispatcher.
>
> This will allow these classes to be reused by SimpleRemoteEPC on the
> controller
> side of the connection.
>
> 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 f3dcb0fd8ba62..03a6710fccda8 100644
> --- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
> +++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h
> @@ -15,6 +15,7 @@
> #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"
> @@ -138,6 +139,29 @@ 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 38c413db2e947..dd721203410b4 100644
> ---
> a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h
> +++
> b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h
> @@ -37,28 +37,6 @@ 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;
>
> @@ -68,7 +46,9 @@ class SimpleRemoteEPCServer : public
> SimpleRemoteEPCTransportClient {
> std::vector<std::unique_ptr<ExecutorBootstrapService>> &services() {
> return Services;
> }
> - void setDispatcher(std::unique_ptr<Dispatcher> D) { S.D =
> std::move(D); }
> + void setDispatcher(std::unique_ptr<SimpleRemoteEPCDispatcher> D) {
> + S.D = std::move(D);
> + }
> void setErrorReporter(unique_function<void(Error)> ReportError) {
> S.ReportError = std::move(ReportError);
> }
> @@ -166,7 +146,7 @@ class SimpleRemoteEPCServer : public
> SimpleRemoteEPCTransportClient {
> enum { ServerRunning, ServerShuttingDown, ServerShutDown } RunState;
> Error ShutdownErr = Error::success();
> std::unique_ptr<SimpleRemoteEPCTransport> T;
> - std::unique_ptr<Dispatcher> D;
> + std::unique_ptr<SimpleRemoteEPCDispatcher> 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 62f4ff8a34090..37d57c0d2d1bf 100644
> --- a/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
> +++ b/llvm/lib/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
> @@ -241,5 +241,32 @@ 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 b23d5670b2509..dba46ecdb7b0c 100644
> --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
> +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
> @@ -24,33 +24,6 @@ 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 cf1b03a141c5e..a9e330984ef90 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<SimpleRemoteEPCServer::ThreadDispatcher>());
> +
> std::make_unique<DynamicThreadPoolSimpleRemoteEPCDispatcher>());
> 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 7100c274b988b..b1ba6a9e6bac3 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<SimpleRemoteEPCServer::ThreadDispatcher>());
> +
> std::make_unique<DynamicThreadPoolSimpleRemoteEPCDispatcher>());
> S.bootstrapSymbols() =
> SimpleRemoteEPCServer::defaultBootstrapSymbols();
> S.services().push_back(
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211008/f0e008f7/attachment.html>
More information about the llvm-commits
mailing list