255 lines
11 KiB
Diff
255 lines
11 KiB
Diff
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
|
|
|