160 lines
5.6 KiB
Diff
160 lines
5.6 KiB
Diff
|
|
From 9353b8793f8725568c04ba03adf8b7f84d0cd226 Mon Sep 17 00:00:00 2001
|
|||
|
|
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
|
|||
|
|
Date: Sat, 2 Sep 2023 15:57:33 +0800
|
|||
|
|
Subject: [PATCH 2/2] [PluginServer] Add class for Server Command.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
include/PluginAPI/BasicPluginOpsAPI.h | 1 +
|
|||
|
|
include/PluginAPI/PluginServerAPI.h | 1 +
|
|||
|
|
include/PluginServer/PluginOptBase.h | 2 +-
|
|||
|
|
include/PluginServer/PluginServer.h | 44 +++++++++++++++++++++++++++
|
|||
|
|
lib/PluginAPI/PluginServerAPI.cpp | 5 +++
|
|||
|
|
lib/PluginServer/main.cpp | 5 +--
|
|||
|
|
6 files changed, 55 insertions(+), 3 deletions(-)
|
|||
|
|
|
|||
|
|
diff --git a/include/PluginAPI/BasicPluginOpsAPI.h b/include/PluginAPI/BasicPluginOpsAPI.h
|
|||
|
|
index 065274d..b047175 100644
|
|||
|
|
--- a/include/PluginAPI/BasicPluginOpsAPI.h
|
|||
|
|
+++ b/include/PluginAPI/BasicPluginOpsAPI.h
|
|||
|
|
@@ -44,6 +44,7 @@ public:
|
|||
|
|
virtual string GetIncludeFile() = 0;
|
|||
|
|
virtual int GetDeclSourceLine(int64_t) = 0;
|
|||
|
|
virtual int GetDeclSourceColumn(int64_t) = 0;
|
|||
|
|
+ virtual void ShutdownCompile() = 0;
|
|||
|
|
|
|||
|
|
// CGnodeOp
|
|||
|
|
virtual vector<CGnodeOp> GetAllCGnode() = 0;
|
|||
|
|
diff --git a/include/PluginAPI/PluginServerAPI.h b/include/PluginAPI/PluginServerAPI.h
|
|||
|
|
index 9cc8498..54e18a3 100644
|
|||
|
|
--- a/include/PluginAPI/PluginServerAPI.h
|
|||
|
|
+++ b/include/PluginAPI/PluginServerAPI.h
|
|||
|
|
@@ -124,6 +124,7 @@ public:
|
|||
|
|
string GetIncludeFile() override;
|
|||
|
|
int GetDeclSourceLine(int64_t) override;
|
|||
|
|
int GetDeclSourceColumn(int64_t) override;
|
|||
|
|
+ void ShutdownCompile() override;
|
|||
|
|
private:
|
|||
|
|
mlir::Block* BlockResult(const string& funName, const string& params);
|
|||
|
|
vector<mlir::Block*> BlocksResult(const string& funName, const string& params);
|
|||
|
|
diff --git a/include/PluginServer/PluginOptBase.h b/include/PluginServer/PluginOptBase.h
|
|||
|
|
index 474d072..926ab7a 100755
|
|||
|
|
--- a/include/PluginServer/PluginOptBase.h
|
|||
|
|
+++ b/include/PluginServer/PluginOptBase.h
|
|||
|
|
@@ -74,9 +74,9 @@ public:
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
- mlir::MLIRContext context;
|
|||
|
|
InjectPoint inject;
|
|||
|
|
uint64_t func; // 保存managerSetup fun参数指针
|
|||
|
|
+ mlir::MLIRContext context;
|
|||
|
|
};
|
|||
|
|
} // namespace PluginOpt
|
|||
|
|
#endif
|
|||
|
|
diff --git a/include/PluginServer/PluginServer.h b/include/PluginServer/PluginServer.h
|
|||
|
|
index 81f92e9..3b4b8e6 100644
|
|||
|
|
--- a/include/PluginServer/PluginServer.h
|
|||
|
|
+++ b/include/PluginServer/PluginServer.h
|
|||
|
|
@@ -98,8 +98,51 @@ private:
|
|||
|
|
std::shared_ptr<PluginOptBase> opt;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
+class ServerCommand {
|
|||
|
|
+public:
|
|||
|
|
+ ServerCommand() = default;
|
|||
|
|
+ ~ServerCommand() = default;
|
|||
|
|
+ ServerCommand(const string& input, const string& dir, const string& common,
|
|||
|
|
+ const string& extra, const string& output) {
|
|||
|
|
+ this->input = input;
|
|||
|
|
+ this->dir = dir;
|
|||
|
|
+ this->common = common;
|
|||
|
|
+ this->extra = extra;
|
|||
|
|
+ this->output = output;
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ void SetInput(const string& input) { this->input = input; }
|
|||
|
|
+ void SetDir(const string& dir) { this->dir = dir; }
|
|||
|
|
+ void SetCommon(const string& common) { this->common = common; }
|
|||
|
|
+ void SetExtra(const string& extra) { this->extra = extra; }
|
|||
|
|
+ void SetOutput(const string& output) { this->output = output; }
|
|||
|
|
+
|
|||
|
|
+ string GetInput() { return this->input; }
|
|||
|
|
+ string GetDir() { return this->dir; }
|
|||
|
|
+ string GetCommon() { return this->common; }
|
|||
|
|
+ string GetExtra() { return this->extra; }
|
|||
|
|
+ string GetOutput() { return this->output; }
|
|||
|
|
+private:
|
|||
|
|
+ string input;
|
|||
|
|
+ string dir;
|
|||
|
|
+ string common;
|
|||
|
|
+ string extra;
|
|||
|
|
+ string output;
|
|||
|
|
+};
|
|||
|
|
+
|
|||
|
|
class PluginServer {
|
|||
|
|
public:
|
|||
|
|
+ void SetServerCommand(
|
|||
|
|
+ const string& input, const string& dir, const string& common,
|
|||
|
|
+ const string& extra, const string& output) {
|
|||
|
|
+ this->serverCMD.SetInput(input);
|
|||
|
|
+ this->serverCMD.SetDir(dir);
|
|||
|
|
+ this->serverCMD.SetCommon(common);
|
|||
|
|
+ this->serverCMD.SetExtra(extra);
|
|||
|
|
+ this->serverCMD.SetOutput(output);
|
|||
|
|
+ }
|
|||
|
|
+ ServerCommand GetServerCommand() { return this->serverCMD; }
|
|||
|
|
+
|
|||
|
|
PluginServer(LogPriority priority, const string& port)
|
|||
|
|
{
|
|||
|
|
userFunState = STATE_WAIT_BEGIN;
|
|||
|
|
@@ -276,6 +319,7 @@ public:
|
|||
|
|
void RemoteCallClientWithAPI(const string& api, const string& params);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
+ ServerCommand serverCMD;
|
|||
|
|
/* 用户函数执行状态,client返回结果后为STATE_RETURN,开始执行下一个函数 */
|
|||
|
|
volatile UserFunStateEnum userFunState;
|
|||
|
|
mlir::MLIRContext *context;
|
|||
|
|
diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp
|
|||
|
|
index 09bd358..00a2a35 100644
|
|||
|
|
--- a/lib/PluginAPI/PluginServerAPI.cpp
|
|||
|
|
+++ b/lib/PluginAPI/PluginServerAPI.cpp
|
|||
|
|
@@ -472,6 +472,11 @@ llvm::SmallVector<mlir::Plugin::FieldDeclOp> PluginServerAPI::GetFields(uint64_t
|
|||
|
|
return PluginServer::GetInstance()->GetFieldsResult(funName, params);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
+void PluginServerAPI::ShutdownCompile() {
|
|||
|
|
+ string funName = __func__;
|
|||
|
|
+ PluginServer::GetInstance()->RemoteCallClientWithAPI(funName, "");
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
void PluginServerAPI::SetDeclName(uint64_t newfieldId, uint64_t fieldId)
|
|||
|
|
{
|
|||
|
|
Json::Value root;
|
|||
|
|
diff --git a/lib/PluginServer/main.cpp b/lib/PluginServer/main.cpp
|
|||
|
|
index 333d55e..669d5e4 100644
|
|||
|
|
--- a/lib/PluginServer/main.cpp
|
|||
|
|
+++ b/lib/PluginServer/main.cpp
|
|||
|
|
@@ -24,7 +24,7 @@ using namespace PinServer;
|
|||
|
|
|
|||
|
|
int main(int argc, char** argv)
|
|||
|
|
{
|
|||
|
|
- const int argcNum = 2; // 参数只有2个,argv[0]:port argv[1]:log级别
|
|||
|
|
+ const int argcNum = 7;
|
|||
|
|
if (argc != argcNum) {
|
|||
|
|
printf("param num:%d, should be:%d\n", argc, argcNum);
|
|||
|
|
return -1;
|
|||
|
|
@@ -32,6 +32,7 @@ int main(int argc, char** argv)
|
|||
|
|
std::string port = argv[0];
|
|||
|
|
LogPriority priority = (LogPriority)atoi(argv[1]);
|
|||
|
|
PluginServer server(priority, port);
|
|||
|
|
+ server.SetServerCommand(argv[2], argv[3], argv[4], argv[5], argv[6]);
|
|||
|
|
server.RunServer();
|
|||
|
|
return 0;
|
|||
|
|
-}
|
|||
|
|
\ No newline at end of file
|
|||
|
|
+}
|
|||
|
|
--
|
|||
|
|
2.33.0
|
|||
|
|
|