Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
f29d744cf8
!57 [Fix] Fix patch errors during the prep phase
From: @dguangya 
Reviewed-by: @wumingchuan 
Signed-off-by: @wumingchuan
2023-09-21 12:38:37 +00:00
dingguangya
d188724dda [Fix] Fix patch errors during the prep phase 2023-09-21 20:15:04 +08:00
openeuler-ci-bot
9d1e5c121e
!56 [Sync] Sync patch from openeuler/pin-server
From: @dguangya 
Reviewed-by: @wumingchuan 
Signed-off-by: @wumingchuan
2023-09-19 07:02:03 +00:00
dingguangya
b34a0cb72b [Sync] Sync patch from openeuler/pin-server 2023-09-19 11:08:34 +08:00
openeuler-ci-bot
c74e949ed8
!46 [sync] PR-44: [Update] Fix Optimized LocalVarSummeryPass
From: @openeuler-sync-bot 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2023-03-26 11:05:58 +00:00
dingguangya
fbcbca4498 [Update] Fix Optimized LocalVarSummeryPass
(cherry picked from commit 48975a865b1a6f90295b396f4d9f7e9d5a8ca0df)
2023-03-26 16:52:25 +08:00
openeuler-ci-bot
69ba8c548e
!42 [sync] PR-40: [Update] Fix log output form
From: @openeuler-sync-bot 
Reviewed-by: @eastb233 
Signed-off-by: @eastb233
2023-03-21 09:01:57 +00:00
dingguangya
b292d9c7bb [Update] Fix log output form
(cherry picked from commit afdb1026516a6d0fee44466eb12236aa29f85f75)
2023-03-21 15:45:06 +08:00
openeuler-ci-bot
ca9dabf8cf
!38 [sync] PR-36: [Update] Fix VectorType and Fix Pass DoOptimize method
From: @openeuler-sync-bot 
Reviewed-by: @eastb233 
Signed-off-by: @eastb233
2023-03-20 02:24:03 +00:00
dingguangya
83fba63fa9 [Update] Fix VectorType and Fix Pass DoOptimize method
(cherry picked from commit 0a8a75b0a9dcef5b928a99c1b30507c51751fe75)
2023-03-19 13:35:10 +08:00
7 changed files with 867 additions and 1 deletions

View File

@ -0,0 +1,22 @@
From e7c49ce6b50918f9bdb7fdaf474d676621694595 Mon Sep 17 00:00:00 2001
From: d00573793 <dingguangya1@huawei.com>
Date: Thu, 9 Mar 2023 15:51:30 +0800
Subject: [PATCH 1/2] [Pin-server] Fix VectorType
diff --git a/lib/Dialect/PluginTypes.cpp b/lib/Dialect/PluginTypes.cpp
index 89e4b1a..6035c4f 100644
--- a/lib/Dialect/PluginTypes.cpp
+++ b/lib/Dialect/PluginTypes.cpp
@@ -415,7 +415,7 @@ unsigned PluginArrayType::getNumElements()
PluginTypeID PluginVectorType::getPluginTypeID()
{
- return PluginTypeID::ArrayTyID;
+ return PluginTypeID::VectorTyID;
}
bool PluginVectorType::isValidElementType(Type type)
--
2.33.0

View File

@ -0,0 +1,323 @@
From eb3fe5b526da6c6f514d40c688c72771b4a8b766 Mon Sep 17 00:00:00 2001
From: dingguangya <dingguangya1@huawei.com>
Date: Wed, 15 Mar 2023 10:00:18 +0800
Subject: [PATCH] [Pin-server] Fix Pass DoOptimize method and struct
self-contained
diff --git a/include/Dialect/PluginOps.td b/include/Dialect/PluginOps.td
index 28710cf..c06a4ad 100644
--- a/include/Dialect/PluginOps.td
+++ b/include/Dialect/PluginOps.td
@@ -59,7 +59,8 @@ def FunctionOp : Plugin_Op<"function", [NoSideEffect]> {
let arguments = (ins UI64Attr:$id,
StrAttr:$funcName,
OptionalAttr<BoolAttr>:$declaredInline,
- TypeAttr:$type);
+ TypeAttr:$type,
+ OptionalAttr<BoolAttr>:$validType);
let regions = (region AnyRegion:$bodyRegion);
// Add custom build methods for the operation. These method populates
@@ -69,7 +70,8 @@ def FunctionOp : Plugin_Op<"function", [NoSideEffect]> {
OpBuilderDAG<(ins "uint64_t":$id,
"StringRef":$funcName,
"bool":$declaredInline,
- "Type":$type)>
+ "Type":$type, "bool":$validType)>,
+ OpBuilderDAG<(ins "uint64_t":$id, "StringRef":$funcName, "bool":$declaredInline, "bool":$validType)>
];
let extraClassDeclaration = [{
diff --git a/include/Dialect/PluginTypes.h b/include/Dialect/PluginTypes.h
index 9693294..5c5f54a 100644
--- a/include/Dialect/PluginTypes.h
+++ b/include/Dialect/PluginTypes.h
@@ -190,12 +190,10 @@ public:
static bool isValidElementType(Type type);
- static PluginStructType get(MLIRContext *context, std::string name, ArrayRef<Type> elements, ArrayRef<std::string> elemNames);
+ static PluginStructType get(MLIRContext *context, std::string name, ArrayRef<std::string> elemNames);
std::string getName();
- ArrayRef<Type> getBody();
-
ArrayRef<std::string> getElementNames();
}; // class PluginStructType
diff --git a/include/user/StructReorder.h b/include/user/StructReorder.h
index d3e4486..573dc3c 100644
--- a/include/user/StructReorder.h
+++ b/include/user/StructReorder.h
@@ -34,10 +34,10 @@ public:
int DoOptimize()
{
- uint64_t *fun = (uint64_t *)GetFuncAddr();
+ uint64_t fun = (uint64_t)GetFuncAddr();
return DoOptimize(fun);
}
- int DoOptimize(uint64_t *fun);
+ int DoOptimize(uint64_t fun);
};
}
diff --git a/lib/Dialect/PluginOps.cpp b/lib/Dialect/PluginOps.cpp
index 40dae3a..a3462ed 100644
--- a/lib/Dialect/PluginOps.cpp
+++ b/lib/Dialect/PluginOps.cpp
@@ -118,15 +118,26 @@ bool CGnodeOp::IsRealSymbol()
// ===----------------------------------------------------------------------===//
void FunctionOp::build(OpBuilder &builder, OperationState &state,
- uint64_t id, StringRef funcName, bool declaredInline, Type type)
+ uint64_t id, StringRef funcName, bool declaredInline, Type type, bool validType)
{
state.addRegion();
state.addAttribute("id", builder.getI64IntegerAttr(id));
state.addAttribute("funcName", builder.getStringAttr(funcName));
state.addAttribute("declaredInline", builder.getBoolAttr(declaredInline));
+ state.addAttribute("validType", builder.getBoolAttr(validType));
if (type) state.addAttribute("type", TypeAttr::get(type));
}
+void FunctionOp::build(OpBuilder &builder, OperationState &state,
+ uint64_t id, StringRef funcName, bool declaredInline, bool validType)
+{
+ state.addRegion();
+ state.addAttribute("id", builder.getI64IntegerAttr(id));
+ state.addAttribute("funcName", builder.getStringAttr(funcName));
+ state.addAttribute("declaredInline", builder.getBoolAttr(declaredInline));
+ state.addAttribute("validType", builder.getBoolAttr(validType));
+}
+
Type FunctionOp::getResultType()
{
PluginIR::PluginFunctionType resultType = type().dyn_cast<PluginIR::PluginFunctionType>();
diff --git a/lib/Dialect/PluginTypes.cpp b/lib/Dialect/PluginTypes.cpp
index 6035c4f..416dbd7 100644
--- a/lib/Dialect/PluginTypes.cpp
+++ b/lib/Dialect/PluginTypes.cpp
@@ -146,29 +146,28 @@ namespace detail {
};
struct PluginStructTypeStorage : public TypeStorage {
- using KeyTy = std::tuple<std::string, ArrayRef<Type>, ArrayRef<std::string>>;
+ using KeyTy = std::tuple<std::string, ArrayRef<std::string>>;
- PluginStructTypeStorage(std::string name, ArrayRef<Type> elements, ArrayRef<std::string> elemNames)
- : name(name), elements(elements), elemNames(elemNames) {}
+ PluginStructTypeStorage(std::string name, ArrayRef<std::string> elemNames)
+ : name(name), elemNames(elemNames) {}
static PluginStructTypeStorage *construct(TypeStorageAllocator &allocator, KeyTy key)
{
return new (allocator.allocate<PluginStructTypeStorage>())
- PluginStructTypeStorage(std::get<0>(key), allocator.copyInto(std::get<1>(key)), allocator.copyInto(std::get<2>(key)));
+ PluginStructTypeStorage(std::get<0>(key), allocator.copyInto(std::get<1>(key)));
}
static unsigned hashKey(const KeyTy &key) {
// LLVM doesn't like hashing bools in tuples.
- return llvm::hash_combine(std::get<0>(key), std::get<1>(key), std::get<2>(key));
+ return llvm::hash_combine(std::get<0>(key), std::get<1>(key));
}
bool operator==(const KeyTy &key) const
{
- return std::make_tuple(name, elements, elemNames) == key;
+ return std::make_tuple(name, elemNames) == key;
}
std::string name;
- ArrayRef<Type> elements;
ArrayRef<std::string> elemNames;
};
}
@@ -493,9 +492,9 @@ bool PluginStructType::isValidElementType(Type type) {
return !type.isa<PluginVoidType, PluginFunctionType>();
}
-PluginStructType PluginStructType::get(MLIRContext *context, std::string name, ArrayRef<Type> elements, ArrayRef<std::string> elemNames)
+PluginStructType PluginStructType::get(MLIRContext *context, std::string name, ArrayRef<std::string> elemNames)
{
- return Base::get(context, name, elements, elemNames);
+ return Base::get(context, name, elemNames);
}
std::string PluginStructType::getName()
@@ -503,11 +502,6 @@ std::string PluginStructType::getName()
return getImpl()->name;
}
-ArrayRef<Type> PluginStructType::getBody()
-{
- return getImpl()->elements;
-}
-
ArrayRef<std::string> PluginStructType::getElementNames()
{
return getImpl()->elemNames;
diff --git a/lib/PluginServer/PluginJson.cpp b/lib/PluginServer/PluginJson.cpp
index c7ce788..0392b75 100755
--- a/lib/PluginServer/PluginJson.cpp
+++ b/lib/PluginServer/PluginJson.cpp
@@ -58,12 +58,6 @@ Json::Value PluginJson::TypeJsonSerialize (PluginIR::PluginTypeBase type)
std::string tyName = Ty.getName();
item["structtype"] = tyName;
size_t paramIndex = 0;
- ArrayRef<Type> paramsType = Ty.getBody();
- for (auto ty :paramsType) {
- std::string paramStr = "elemType" + std::to_string(paramIndex++);
- item["structelemType"][paramStr] = TypeJsonSerialize(ty.dyn_cast<PluginIR::PluginTypeBase>());
- }
- paramIndex = 0;
ArrayRef<std::string> paramsNames = Ty.getElementNames();
for (auto name :paramsNames) {
std::string paramStr = "elemName" + std::to_string(paramIndex++);
@@ -281,7 +275,6 @@ bool PluginJson::ProcessBlock(mlir::Block* block, mlir::Region& rg, const Json::
} else if (opCode == AsmOp::getOperationName().str()) {
AsmOpJsonDeserialize(opJson.toStyledString());
} else if (opCode == SwitchOp::getOperationName().str()) {
- printf("switch op deserialize\n");
SwitchOpJsonDeserialize(opJson.toStyledString());
} else if (opCode == GotoOp::getOperationName().str()) {
GotoOpJsonDeSerialize(opJson.toStyledString());
@@ -368,9 +361,17 @@ void PluginJson::FuncOpJsonDeSerialize(
bool declaredInline = false;
if (funcAttributes["declaredInline"] == "1") declaredInline = true;
auto location = opBuilder.getUnknownLoc();
- PluginIR::PluginTypeBase retType = TypeJsonDeSerialize(node["retType"].toStyledString());
- FunctionOp fOp = opBuilder.create<FunctionOp>(
- location, id, funcAttributes["funcName"], declaredInline, retType);
+ bool validType = false;
+ FunctionOp fOp;
+ if (funcAttributes["validType"] == "1") {
+ validType = true;
+ PluginIR::PluginTypeBase retType = TypeJsonDeSerialize(node["retType"].toStyledString());
+ fOp = opBuilder.create<FunctionOp>(
+ location, id, funcAttributes["funcName"], declaredInline, retType, validType);
+ } else {
+ fOp = opBuilder.create<FunctionOp>(location, id, funcAttributes["funcName"], declaredInline, validType);
+ }
+
mlir::Region &bodyRegion = fOp.bodyRegion();
Json::Value regionJson = node["region"];
Json::Value::Members bbMember = regionJson.getMemberNames();
@@ -445,21 +446,14 @@ PluginIR::PluginTypeBase PluginJson::TypeJsonDeSerialize(const string& data)
baseType = PluginIR::PluginFunctionType::get(PluginServer::GetInstance()->GetContext(), returnTy, typelist);
} else if (id == static_cast<uint64_t>(PluginIR::StructTyID)) {
std::string tyName = type["structtype"].asString();
- llvm::SmallVector<Type> typelist;
- Json::Value::Members elemTypeNum = type["structelemType"].getMemberNames();
- for (size_t paramIndex = 0; paramIndex < elemTypeNum.size(); paramIndex++) {
- string Key = "elemType" + std::to_string(paramIndex);
- mlir::Type paramTy = TypeJsonDeSerialize(type["structelemType"][Key].toStyledString());
- typelist.push_back(paramTy);
- }
llvm::SmallVector<std::string> names;
Json::Value::Members elemNameNum = type["structelemName"].getMemberNames();
- for (size_t paramIndex = 0; paramIndex < elemTypeNum.size(); paramIndex++) {
+ for (size_t paramIndex = 0; paramIndex < elemNameNum.size(); paramIndex++) {
std::string Key = "elemName" + std::to_string(paramIndex);
std::string elemName = type["structelemName"][Key].asString();
names.push_back(elemName);
}
- baseType = PluginIR::PluginStructType::get(PluginServer::GetInstance()->GetContext(), tyName, typelist, names);
+ baseType = PluginIR::PluginStructType::get(PluginServer::GetInstance()->GetContext(), tyName, names);
}
else {
if (PluginTypeId == PluginIR::VoidTyID) {
diff --git a/user/ArrayWidenPass.cpp b/user/ArrayWidenPass.cpp
index 591ecdb..db8223a 100644
--- a/user/ArrayWidenPass.cpp
+++ b/user/ArrayWidenPass.cpp
@@ -1475,13 +1475,13 @@ static void convertToNewLoop(LoopOp* loop, FunctionOp* funcOp)
return;
}
-static void ProcessArrayWiden(uint64_t *fun)
+static void ProcessArrayWiden(uint64_t fun)
{
std::cout << "Running first pass, awiden\n";
PluginServerAPI pluginAPI;
- FunctionOp funcOp = pluginAPI.GetFunctionOpById((uint64_t)fun);
+ FunctionOp funcOp = pluginAPI.GetFunctionOpById(fun);
if (funcOp == nullptr) return;
context = funcOp.getOperation()->getContext();
@@ -1498,7 +1498,7 @@ static void ProcessArrayWiden(uint64_t *fun)
}
}
-int ArrayWidenPass::DoOptimize(uint64_t *fun)
+int ArrayWidenPass::DoOptimize(uint64_t fun)
{
ProcessArrayWiden(fun);
return 0;
diff --git a/user/InlineFunctionPass.cpp b/user/InlineFunctionPass.cpp
index a51e6fe..cc4c7c4 100755
--- a/user/InlineFunctionPass.cpp
+++ b/user/InlineFunctionPass.cpp
@@ -30,7 +30,7 @@ static void UserOptimizeFunc(void)
vector<FunctionOp> allFunction = pluginAPI.GetAllFunc();
int count = 0;
for (size_t i = 0; i < allFunction.size(); i++) {
- if (allFunction[i].declaredInlineAttr().getValue())
+ if (allFunction[i] && allFunction[i].declaredInlineAttr().getValue())
count++;
}
fprintf(stderr, "declaredInline have %d functions were declared.\n", count);
diff --git a/user/LocalVarSummeryPass.cpp b/user/LocalVarSummeryPass.cpp
index c336487..04d4ac9 100755
--- a/user/LocalVarSummeryPass.cpp
+++ b/user/LocalVarSummeryPass.cpp
@@ -44,6 +44,7 @@ static void LocalVarSummery(void)
}
mlir::Plugin::FunctionOp funcOp = allFunction[i];
printf("func name is :%s\n", funcOp.funcNameAttr().getValue().str().c_str());
+ if (funcOp.validTypeAttr().getValue()) {
mlir::Type dgyty = funcOp.type();
if (auto ty = dgyty.dyn_cast<PluginIR::PluginFunctionType>()) {
if(auto stTy = ty.getReturnType().dyn_cast<PluginIR::PluginStructType>()) {
@@ -69,6 +70,7 @@ static void LocalVarSummery(void)
printf("\n Param type id : %d\n", ty.dyn_cast<PluginIR::PluginTypeBase>().getPluginTypeID());
}
}
+ }
for (size_t j = 0; j < decls.size(); j++) {
auto decl = decls[j];
string name = decl.symNameAttr().getValue().str();
diff --git a/user/StructReorder.cpp b/user/StructReorder.cpp
index f4e824e..ab2f086 100644
--- a/user/StructReorder.cpp
+++ b/user/StructReorder.cpp
@@ -177,10 +177,10 @@ static bool handle_type(PluginIR::PluginTypeBase type)
return false;
}
-static void ProcessStructReorder(uint64_t *fun)
+static void ProcessStructReorder(uint64_t fun)
{
fprintf(stderr, "Running first pass, structreoder\n");
-
+
PluginServerAPI pluginAPI;
vector<CGnodeOp> allnodes = pluginAPI.GetAllCGnode();
fprintf(stderr, "allnodes size is %d\n", allnodes.size());
@@ -222,7 +222,7 @@ static void ProcessStructReorder(uint64_t *fun)
}
-int StructReorderPass::DoOptimize(uint64_t *fun)
+int StructReorderPass::DoOptimize(uint64_t fun)
{
ProcessStructReorder(fun);
return 0;
--
2.33.0

View File

@ -0,0 +1,254 @@
From 61f8e5ee493220d7571ac7d3bf730d6856660753 Mon Sep 17 00:00:00 2001
From: d00573793 <dingguangya1@huawei.com>
Date: Mon, 20 Mar 2023 21:45:03 +0800
Subject: [PATCH] [Pin-server] Fix log output form
diff --git a/lib/PluginAPI/PluginServerAPI.cpp b/lib/PluginAPI/PluginServerAPI.cpp
index 273aafe..09bd358 100644
--- a/lib/PluginAPI/PluginServerAPI.cpp
+++ b/lib/PluginAPI/PluginServerAPI.cpp
@@ -27,7 +27,7 @@ using namespace mlir::Plugin;
static bool CheckAttribute(string &attribute)
{
if (attribute == "NULL") {
- printf("param attribute is NULL,check fail!\n");
+ fprintf(stderr, "param attribute is NULL,check fail!\n");
return false;
}
return true;
diff --git a/lib/PluginServer/PluginLog.cpp b/lib/PluginServer/PluginLog.cpp
index 9c0a08f..10b8bc8 100644
--- a/lib/PluginServer/PluginLog.cpp
+++ b/lib/PluginServer/PluginLog.cpp
@@ -47,14 +47,14 @@ void PluginLog::GetLogFileName(string& fileName)
{
time_t nowTime = time(nullptr);
if (nowTime == -1) {
- printf("%s fail\n", __func__);
+ fprintf(stderr, "%s fail\n", __func__);
}
struct tm *t = localtime(&nowTime);
char buf[100];
int ret = sprintf(buf, "/tmp/pin_server%d_%4d%02d%02d_%02d_%02d_%02d.log", getppid(),
t->tm_year + BASE_DATE, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
if (ret < 0) {
- printf("%s sprintf fail\n", __func__);
+ fprintf(stderr, "%s sprintf fail\n", __func__);
}
fileName = buf;
}
@@ -91,14 +91,14 @@ void PluginLog::LogWrite(const char *tag, const char *msg)
{
time_t nowTime = time(nullptr);
if (nowTime == -1) {
- printf("%s fail\n", __func__);
+ fprintf(stderr, "%s fail\n", __func__);
}
struct tm *t = localtime(&nowTime);
char buf[30];
int ret = sprintf(buf, "%4d-%02d-%02d %02d:%02d:%02d ", t->tm_year + BASE_DATE, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
if (ret < 0) {
- printf("%s sprintf fail\n", __func__);
+ fprintf(stderr, "%s sprintf fail\n", __func__);
}
string stag = tag;
string smsg = msg;
@@ -109,7 +109,7 @@ void PluginLog::LogWrite(const char *tag, const char *msg)
void PluginLog::LogPrint(LogPriority pri, const char *tag, const char *buf)
{
if (pri <= priority) {
- printf("%s%s", tag, buf);
+ fprintf(stderr, "%s%s", tag, buf);
}
g_mutex.lock();
@@ -123,7 +123,7 @@ void PluginLog::LOGE(const char *fmt, ...)
va_start(ap, fmt);
int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap);
if (ret < 0) {
- printf("%s vsnprintf fail\n", __func__);
+ fprintf(stderr, "%s vsnprintf fail\n", __func__);
}
va_end(ap);
@@ -136,7 +136,7 @@ void PluginLog::LOGW(const char *fmt, ...)
va_start(ap, fmt);
int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap);
if (ret < 0) {
- printf("%s vsnprintf fail\n", __func__);
+ fprintf(stderr, "%s vsnprintf fail\n", __func__);
}
va_end(ap);
LogPrint(PRIORITY_WARN, "WARN:", logBuf);
@@ -148,7 +148,7 @@ void PluginLog::LOGI(const char *fmt, ...)
va_start(ap, fmt);
int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap);
if (ret < 0) {
- printf("%s vsnprintf fail\n", __func__);
+ fprintf(stderr, "%s vsnprintf fail\n", __func__);
}
va_end(ap);
LogPrint(PRIORITY_INFO, "INFO:", logBuf);
@@ -160,7 +160,7 @@ void PluginLog::LOGD(const char *fmt, ...)
va_start(ap, fmt);
int ret = vsnprintf(logBuf, LOG_BUF_SIZE, fmt, ap);
if (ret < 0) {
- printf("%s vsnprintf fail\n", __func__);
+ fprintf(stderr, "%s vsnprintf fail\n", __func__);
}
va_end(ap);
LogPrint(PRIORITY_DEBUG, "DEBUG:", logBuf);
diff --git a/user/ArrayWidenPass.cpp b/user/ArrayWidenPass.cpp
index db8223a..475f784 100644
--- a/user/ArrayWidenPass.cpp
+++ b/user/ArrayWidenPass.cpp
@@ -46,7 +46,7 @@ std::map<uint64_t, std::string> opNameMap;
static void PassManagerSetupFunc(void)
{
- printf("PassManagerSetupFunc in\n");
+ fprintf(stderr, "PassManagerSetupFunc in\n");
}
enum EDGE_FLAG {
@@ -878,27 +878,27 @@ static bool checkOriginLoopInfo(LoopOp loop)
static bool checkRecordLoopForm(LoopOp loop)
{
if (!recordOriginLoopExitInfo (loop)) {
- printf ("\nFailed to record loop exit information.\n");
+ fprintf(stderr, "\nFailed to record loop exit information.\n");
return false;
}
if (!recordOriginLoopHeader (loop)) {
- printf ("\nFailed to record loop header information.\n");
+ fprintf(stderr, "\nFailed to record loop header information.\n");
return false;
}
if (!recordOriginLoopLatch (loop)) {
- printf ("\nFailed to record loop latch information.\n");
+ fprintf(stderr, "\nFailed to record loop latch information.\n");
return false;
}
if (!recordOriginLoopBody (loop)) {
- printf ("\nFailed to record loop body information.\n");
+ fprintf(stderr, "\nFailed to record loop body information.\n");
return false;
}
if (!checkOriginLoopInfo (loop)) {
- printf ("\nFailed to check origin loop information.\n");
+ fprintf(stderr, "\nFailed to check origin loop information.\n");
return false;
}
@@ -908,22 +908,22 @@ static bool checkRecordLoopForm(LoopOp loop)
static bool determineLoopForm(LoopOp loop)
{
if (loop.innerLoopIdAttr().getInt() != 0 && loop.numBlockAttr().getInt() != 3) {
- printf ("\nWrong loop form, there is inner loop or redundant bb.\n");
+ fprintf(stderr, "\nWrong loop form, there is inner loop or redundant bb.\n");
return false;
}
if (loop.GetSingleExit().first || !loop.GetLatch()) {
- printf ("\nWrong loop form, only one exit or loop_latch does not exist.\n");
+ fprintf(stderr, "\nWrong loop form, only one exit or loop_latch does not exist.\n");
return false;
}
if (!isLoopSingleBackedge(loop)) {
- printf ("\nWrong loop form, loop back edges are not unique.\n");
+ fprintf(stderr, "\nWrong loop form, loop back edges are not unique.\n");
return false;
}
if (!isLoopSinglePreheaderBB(loop)) {
- printf ("\nWrong loop form, loop preheader bb are not unique.\n");
+ fprintf(stderr, "\nWrong loop form, loop preheader bb are not unique.\n");
return false;
}
@@ -1488,11 +1488,11 @@ static void ProcessArrayWiden(uint64_t fun)
mlir::OpBuilder opBuilder_temp = mlir::OpBuilder(context);
opBuilder = &opBuilder_temp;
string name = funcOp.funcNameAttr().getValue().str();
- printf("Now process func : %s \n", name.c_str());
+ fprintf(stderr, "Now process func : %s \n", name.c_str());
vector<LoopOp> allLoop = funcOp.GetAllLoops();
for (auto &loop : allLoop) {
if (determineLoopForm(loop)) {
- printf("The loop form is success matched, and the loop can be optimized.\n");
+ fprintf(stderr, "The loop form is success matched, and the loop can be optimized.\n");
convertToNewLoop(&loop, &funcOp);
}
}
diff --git a/user/LocalVarSummeryPass.cpp b/user/LocalVarSummeryPass.cpp
index 04d4ac9..b7e104e 100755
--- a/user/LocalVarSummeryPass.cpp
+++ b/user/LocalVarSummeryPass.cpp
@@ -36,38 +36,38 @@ static void LocalVarSummery(void)
map<string, string> args = PluginServer::GetInstance()->GetArgs();
for (size_t i = 0; i < allFunction.size(); i++) {
uint64_t funcID = allFunction[i].idAttr().getValue().getZExtValue();
- printf("In the %ldth function:\n", i);
+ fprintf(stderr, "In the %ldth function:\n", i);
vector<mlir::Plugin::LocalDeclOp> decls = pluginAPI.GetDecls(funcID);
int64_t typeFilter = -1u;
if (args.find("type_code") != args.end()) {
typeFilter = (int64_t)pluginAPI.GetTypeCodeFromString(args["type_code"]);
}
mlir::Plugin::FunctionOp funcOp = allFunction[i];
- printf("func name is :%s\n", funcOp.funcNameAttr().getValue().str().c_str());
+ fprintf(stderr, "func name is :%s\n", funcOp.funcNameAttr().getValue().str().c_str());
if (funcOp.validTypeAttr().getValue()) {
mlir::Type dgyty = funcOp.type();
if (auto ty = dgyty.dyn_cast<PluginIR::PluginFunctionType>()) {
if(auto stTy = ty.getReturnType().dyn_cast<PluginIR::PluginStructType>()) {
- printf("func return type is PluginStructType\n");
+ fprintf(stderr, "func return type is PluginStructType\n");
std::string tyName = stTy.getName();
- printf(" struct name is : %s\n", tyName.c_str());
+ fprintf(stderr, " struct name is : %s\n", tyName.c_str());
llvm::ArrayRef<std::string> paramsNames = stTy.getElementNames();
for (auto name :paramsNames) {
std::string pName = name;
- printf("\n struct argname is : %s\n", pName.c_str());
+ fprintf(stderr, "\n struct argname is : %s\n", pName.c_str());
}
}
if(auto stTy = ty.getReturnType().dyn_cast<PluginIR::PluginVectorType>()) {
- printf("func return type is PluginVectorType\n");
- printf(" vector elem num : %d\n", stTy.getNumElements());
- printf(" vector elem type id : %d\n", stTy.getElementType().dyn_cast<PluginIR::PluginTypeBase>().getPluginTypeID());
+ fprintf(stderr, "func return type is PluginVectorType\n");
+ fprintf(stderr, " vector elem num : %d\n", stTy.getNumElements());
+ fprintf(stderr, " vector elem type id : %d\n", stTy.getElementType().dyn_cast<PluginIR::PluginTypeBase>().getPluginTypeID());
}
size_t paramIndex = 0;
llvm::ArrayRef<mlir::Type> paramsType = ty.getParams();
for (auto ty : ty.getParams()) {
- printf("\n Param index : %ld\n", paramIndex++);
- printf("\n Param type id : %d\n", ty.dyn_cast<PluginIR::PluginTypeBase>().getPluginTypeID());
+ fprintf(stderr, "\n Param index : %ld\n", paramIndex++);
+ fprintf(stderr, "\n Param type id : %d\n", ty.dyn_cast<PluginIR::PluginTypeBase>().getPluginTypeID());
}
}
}
@@ -76,7 +76,7 @@ static void LocalVarSummery(void)
string name = decl.symNameAttr().getValue().str();
int64_t declTypeID = decl.typeIDAttr().getValue().getZExtValue();
if (declTypeID == typeFilter) {
- printf("\tFind %ldth target type %s\n", j, name.c_str());
+ fprintf(stderr, "\tFind %ldth target type %s\n", j, name.c_str());
}
}
}
--
2.33.0

View File

@ -0,0 +1,29 @@
From 085d310af6b860b00245c0ceb88c9cc8413ae67e Mon Sep 17 00:00:00 2001
From: d00573793 <dingguangya1@huawei.com>
Date: Fri, 24 Mar 2023 18:41:45 +0800
Subject: [PATCH] [Pin-server] Optimized LocalVarSummeryPass
diff --git a/user/LocalVarSummeryPass.cpp b/user/LocalVarSummeryPass.cpp
index b7e104e..4f72a2a 100755
--- a/user/LocalVarSummeryPass.cpp
+++ b/user/LocalVarSummeryPass.cpp
@@ -35,6 +35,7 @@ static void LocalVarSummery(void)
vector<mlir::Plugin::FunctionOp> allFunction = pluginAPI.GetAllFunc();
map<string, string> args = PluginServer::GetInstance()->GetArgs();
for (size_t i = 0; i < allFunction.size(); i++) {
+ if (allFunction[i] == nullptr) continue;
uint64_t funcID = allFunction[i].idAttr().getValue().getZExtValue();
fprintf(stderr, "In the %ldth function:\n", i);
vector<mlir::Plugin::LocalDeclOp> decls = pluginAPI.GetDecls(funcID);
@@ -73,6 +74,7 @@ static void LocalVarSummery(void)
}
for (size_t j = 0; j < decls.size(); j++) {
auto decl = decls[j];
+ if (decl == nullptr) continue;
string name = decl.symNameAttr().getValue().str();
int64_t declTypeID = decl.typeIDAttr().getValue().getZExtValue();
if (declTypeID == typeFilter) {
--
2.33.0

View File

@ -0,0 +1,37 @@
From e7ae3a2b7852b4da6dccdd23f6caa20812a59660 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E6=99=A8=E5=8D=89?= <zhengchenhui1@huawei.com>
Date: Thu, 7 Sep 2023 11:40:37 +0800
Subject: [PATCH 1/2] Fix BUILD errors
---
CMakeLists.txt | 1 +
lib/PluginServer/PluginLog.cpp | 1 +
2 files changed, 2 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 233f345..569fabf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,7 @@ include(AddLLVM)
include(AddMLIR)
#include(HandleLLVMOptions)
+include_directories(${GRPC_INCLUDE_DIR})
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
diff --git a/lib/PluginServer/PluginLog.cpp b/lib/PluginServer/PluginLog.cpp
index 10b8bc8..c405da1 100644
--- a/lib/PluginServer/PluginLog.cpp
+++ b/lib/PluginServer/PluginLog.cpp
@@ -25,6 +25,7 @@
#include <fstream>
#include <mutex>
#include <csignal>
+#include <unistd.h>
#include "PluginServer/PluginLog.h"
namespace PinLog {
--
2.33.0

View File

@ -0,0 +1,159 @@
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

View File

@ -1,6 +1,6 @@
Name: pin-server
Version: 0.4.0
Release: 6
Release: 11
Summary: Pin (Plug-IN framework) server provides plugin APIs for compiler optimization developers to develop optimization pass.
License: Apache 2.0
URL: https://gitee.com/openeuler/pin-server
@ -33,6 +33,12 @@ Patch20: 0020-Pin-server-Add-CGnodeOp.patch
Patch21: 0021-Pin-server-The-lto-flag-is-used-to-control-the-pass-.patch
Patch22: 0022-Pin-server-Add-support-for-decl-and-field-SetDeclNam.patch
Patch23: 0023-Pin-server-Add-StructReorderPASS-demo.patch
Patch24: 0024-Pin-server-Fix-VectorType.patch
Patch25: 0025-Pin-server-Fix-Pass-DoOptimize-method-and-struct-sel.patch
Patch26: 0026-Pin-server-Fix-log-output-form.patch
Patch27: 0027-Pin-server-Optimized-LocalVarSummeryPass.patch
Patch28: 0028-Fix-BUILD-errors.patch
Patch29: 0029-PluginServer-Add-class-for-Server-Command.patch
%description
Pin (Plug-IN framework) server provides plugin APIs for compiler optimization developers to develop optimization pass.
@ -71,6 +77,12 @@ A demo for pin-server
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
mkdir -p _build
cd _build
@ -111,6 +123,36 @@ find %{_libdir} -type f -name "libMLIRServerAPI.so" -exec strip "{}" ";"
%config(noreplace) /etc/ld.so.conf.d/%{name}-%{_arch}.conf
%changelog
* Thu Sep 21 2023 dingguangya <dingguangya1@huawei.com> - 0.4.0-11
- Type:Fix
- ID:NA
- SUG:NA
- DESC:Fix patch errors during the prep phase
* Tue Sep 19 2023 dingguangya <dingguangya1@huawei.com> - 0.4.0-10
- Type:Update
- ID:NA
- SUG:NA
- DESC:Sync patch from openeuler/pin-server
* Sat Mar 25 2023 dingguangya <dingguangya1@huawei.com> - 0.4.0-9
- Type:Update
- ID:NA
- SUG:NA
- DESC:Fix Optimized LocalVarSummeryPass
* Tue Mar 21 2023 dingguangya <dingguangya1@huawei.com> - 0.4.0-8
- Type:Update
- ID:NA
- SUG:NA
- DESC:Fix log output form
* Fri Mar 17 2023 dingguangya <dingguangya1@huawei.com> - 0.4.0-7
- Type:Update
- ID:NA
- SUG:NA
- DESC:Fix VectorType and Fix Pass DoOptimize method
* Tue Mar 07 2023 dingguangya <dingguangya1@huawei.com> - 0.4.0-6
- Type:Update
- ID:NA