Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/clients/zerospy/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,18 @@ FloatOperandSizeTable(instr_t *instr, opnd_t opnd)
#endif

bool instr_is_ignorable(instr_t *ins) {
int opc = instr_get_opcode(ins);
switch (opc) {
int opc = instr_get_opcode(ins);
switch (opc) {
#if defined(AARCH64)
case OP_ld3:
case OP_ld3r:
return true;
case OP_ld3:
case OP_ldr:
case OP_ld3r:
return true;
#endif
default:
return false;
}

return false;
default:
return false;
}
return false;
}

#else
Expand Down
13 changes: 10 additions & 3 deletions src/clients/zerospy/zerospy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,9 @@ static uint64_t PrintApproximationRedundancyPairs(per_thread_t *pt, uint64_t thr
if(grandTotalRedundantBytes==0) {
dr_fprintf(gTraceFile, "\n------------ Dumping Approximation Redundancy Info Finish -------------\n");
printf("Floating Point Report dumped\n");
threadDetailedCodeCentricMetrics.AddMember("Floating Point Redundant Info", floatingPointRedundantInfo, jsonAllocator);
threadDetailedMetrics.AddMember("Code Centric", threadDetailedCodeCentricMetrics, jsonAllocator);
threadDetailedMetricsMap[threadId] = threadDetailedMetrics;
return 0;
}

Expand Down Expand Up @@ -2113,14 +2116,16 @@ ClientThreadEnd(void *drcontext)
rapidjson::Value threadIntegerTotal(rapidjson::kObjectType);
rapidjson::Value threadFloatTotal(rapidjson::kObjectType);

char detailName[32] = {};
dr_snprintf(detailName, 32, "./thread%dCCDetail.md", threadId);
threadIntegerTotal.AddMember("rate", threadRedByteLoadINT * 100.0/threadByteLoad, jsonAllocator);
threadIntegerTotal.AddMember("fraction", rapidjson::Value((std::to_string(threadRedByteLoadINT) + "/" + std::to_string(threadByteLoad)).c_str(), jsonAllocator), jsonAllocator);
threadIntegerTotal.AddMember("detail", "file:///abspath/to/thread0CCDetail.md",
threadIntegerTotal.AddMember("detail", rapidjson::Value(detailName, jsonAllocator),
jsonAllocator);

threadFloatTotal.AddMember("rate", threadRedByteLoadFP * 100.0/threadByteLoad, jsonAllocator);
threadFloatTotal.AddMember("fraction", rapidjson::Value((std::to_string(threadRedByteLoadFP) + "/" + std::to_string(threadByteLoad)).c_str(), jsonAllocator), jsonAllocator);
threadFloatTotal.AddMember("detail", "file:///abspath/to/thread0CCDetail.md",
threadFloatTotal.AddMember("detail", rapidjson::Value(detailName, jsonAllocator),
jsonAllocator);

totalIntegerRedundantBytes.AddMember(rapidjson::Value(("Thread " + std::to_string(threadId)).c_str(), jsonAllocator), threadIntegerTotal, jsonAllocator);
Expand Down Expand Up @@ -2170,7 +2175,9 @@ ClientInit(int argc, const char *argv[])

sprintf(name+strlen(name), "/zerospy.log");
gFile = dr_open_file(name, DR_FILE_WRITE_OVERWRITE | DR_FILE_ALLOW_LARGE);
gJson = fopen("report.json", "w");
char gJsonName[MAXIMUM_PATH] = "";
sprintf(gJsonName + strlen(gJsonName), "%s/report.json", g_folder_name.c_str());
gJson = fopen(gJsonName, "w");
DR_ASSERT(gFile != INVALID_FILE);
DR_ASSERT(gJson != NULL);
if (op_enable_sampling.get_value()) {
Expand Down
13 changes: 12 additions & 1 deletion src/clients/zerospy_data_centric/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,18 @@ FloatOperandSizeTable(instr_t *instr, opnd_t opnd)
#endif

bool instr_is_ignorable(instr_t *ins) {
return false;
int opc = instr_get_opcode(ins);
switch (opc) {
#if defined(AARCH64)
case OP_ld3:
case OP_ldr:
case OP_ld3r:
return true;
#endif
default:
return false;
}
return false;
}

#else
Expand Down
81 changes: 44 additions & 37 deletions src/clients/zerospy_data_centric/zerospy_data_centric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,29 +2048,21 @@ static uint64_t PrintRedundancyPairs(per_thread_t *pt, uint64_t threadBytesLoad,
break;
}
}
#if 0
#if 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改成参数选项可以调整的吧

if(objNum<=MAX_PRINT_FULL) {
char fn[50] = {};
sprintf(fn,"%lx.redmap",(*listIt).objID);
file_t fp = dr_open(fn,"w");
FILE* fp = fopen(fn,"wb");

for(size_t i=0;i<accmap->size;++i) {
int tmp = 1;
if(bitvec_at(accmap, i)) {
fwrite(&tmp, sizeof(char), 1, fp);
} else {
tmp = 0;
fwrite(&tmp, sizeof(char), 1, fp);
}

tmp = 1;
if(bitvec_at(redmap, i)) {
fwrite(&tmp, sizeof(char), 1, fp);
} else {
tmp = 0;
fwrite(&tmp, sizeof(char), 1, fp);
}
if(accmap->size > 64) {
int wSize = accmap->size / 64 + (accmap->size % 64 == 0?0:1);
fwrite(accmap->data.dyn, wSize * 8, 1, fp);
fwrite(redmap->data.dyn, wSize * 8, 1, fp);
} else {
fwrite(&accmap->data.stat, 8, 1, fp);
fwrite(&redmap->data.stat, 8, 1, fp);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个现在不能这么写了,如果数据比较大就会分页存储了;但现在内存主要消耗在cctlib那边,这个可以保留到把分页存储改回原来的低开销、高内存开销的方法

}
fclose(fp);
dr_snprintf(keyStr, 32, "Redmap %d", dataNum);
integerRedundantInfoItem.AddMember(rapidjson::Value(keyStr, jsonAllocator), rapidjson::Value(fn, jsonAllocator), jsonAllocator);
}
Expand Down Expand Up @@ -2184,6 +2176,9 @@ static uint64_t PrintApproximationRedundancyPairs(per_thread_t *pt, uint64_t thr

if(grandTotalRedundantBytes==0) {
dr_fprintf(gTraceFile, "\n------------ Dumping Approx Redundancy Info Finish -------------\n");
threadDetailedDataCentricMetrics.AddMember("Floating Point Redundant Info", floatingPointRedundantInfo, jsonAllocator);
threadDetailedMetrics.AddMember("Data Centric", threadDetailedDataCentricMetrics, jsonAllocator);
threadDetailedMetricsMap[threadId] = threadDetailedMetrics;
return grandTotalRedundantBytes;
}
sort(tmpList.begin(), tmpList.end(), ObjRedundancyCompare);
Expand Down Expand Up @@ -2275,29 +2270,21 @@ static uint64_t PrintApproximationRedundancyPairs(per_thread_t *pt, uint64_t thr
break;
}
}
#if 0
#if 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同样

if(objNum<=MAX_PRINT_FULL) {
char fn[50] = {};
sprintf(fn,"%lx.redmap",(*listIt).objID);
file_t fp = dr_open(fn,"w");
FILE* fp = fopen(fn,"wb");

for(size_t i=0;i<accmap->size;++i) {
int tmp = 1;
if(bitvec_at(accmap, i)) {
fwrite(&tmp, sizeof(char), 1, fp);
} else {
tmp = 0;
fwrite(&tmp, sizeof(char), 1, fp);
}

tmp = 1;
if(bitvec_at(redmap, i)) {
fwrite(&tmp, sizeof(char), 1, fp);
} else {
tmp = 0;
fwrite(&tmp, sizeof(char), 1, fp);
}
if(accmap->size > 64) {
int wSize = accmap->size / 64 + (accmap->size % 64 == 0?0:1);
fwrite(accmap->data.dyn, wSize * 8, 1, fp);
fwrite(redmap->data.dyn, wSize * 8, 1, fp);
} else {
fwrite(&accmap->data.stat, 8, 1, fp);
fwrite(&redmap->data.stat, 8, 1, fp);
}
fclose(fp);
dr_snprintf(keyStr, 32, "Redmap %d", dataNum);
floatRedundantInfoItem.AddMember(rapidjson::Value(keyStr, jsonAllocator), rapidjson::Value(fn, jsonAllocator), jsonAllocator);
}
Expand Down Expand Up @@ -2416,6 +2403,23 @@ ClientThreadEnd(void *drcontext)
dr_fprintf(gFile, "\nRedundantBytesLoad: %lu %.2f",threadRedByteLoadINT, threadRedByteLoadINT * 100.0/threadByteLoad);
dr_fprintf(gFile, "\nApproxRedundantBytesLoad: %lu %.2f\n",threadRedByteLoadFP, threadRedByteLoadFP * 100.0/threadByteLoad);
}
rapidjson::Value threadIntegerTotal(rapidjson::kObjectType);
rapidjson::Value threadFloatTotal(rapidjson::kObjectType);

threadIntegerTotal.AddMember("rate", threadRedByteLoadINT * 100.0/threadByteLoad, jsonAllocator);
threadIntegerTotal.AddMember("fraction", rapidjson::Value((std::to_string(threadRedByteLoadINT) + "/" + std::to_string(threadByteLoad)).c_str(), jsonAllocator), jsonAllocator);
char detailName[32] = {};
dr_snprintf(detailName, 32, "./thread%dDCDetail.md", threadId);
threadIntegerTotal.AddMember("detail", rapidjson::Value(detailName, jsonAllocator),
jsonAllocator);

threadFloatTotal.AddMember("rate", threadRedByteLoadFP * 100.0/threadByteLoad, jsonAllocator);
threadFloatTotal.AddMember("fraction", rapidjson::Value((std::to_string(threadRedByteLoadFP) + "/" + std::to_string(threadByteLoad)).c_str(), jsonAllocator), jsonAllocator);
threadFloatTotal.AddMember("detail", rapidjson::Value(detailName, jsonAllocator),
jsonAllocator);

totalIntegerRedundantBytes.AddMember(rapidjson::Value(("Thread " + std::to_string(threadId)).c_str(), jsonAllocator), threadIntegerTotal, jsonAllocator);
totalFloatRedundantBytes.AddMember(rapidjson::Value(("Thread " + std::to_string(threadId)).c_str(), jsonAllocator), threadFloatTotal, jsonAllocator);
dr_mutex_unlock(gLock);

dr_close_file(pt->output_file);
Expand Down Expand Up @@ -2461,7 +2465,9 @@ ClientInit(int argc, const char *argv[])

sprintf(name+strlen(name), "/zerospy.log");
gFile = dr_open_file(name, DR_FILE_WRITE_OVERWRITE | DR_FILE_ALLOW_LARGE);
gJson = fopen("report.json", "w");
char gJsonName[MAXIMUM_PATH] = "";
sprintf(gJsonName + strlen(gJsonName), "%s/report.json", g_folder_name.c_str());
gJson = fopen(gJsonName, "w");
DR_ASSERT(gFile != INVALID_FILE);
DR_ASSERT(gJson != NULL);
if (op_enable_sampling.get_value()) {
Expand Down Expand Up @@ -2509,6 +2515,7 @@ ClientExit(void)
metricOverview.AddMember("Total Integer Redundant Bytes", totalIntegerRedundantBytes, jsonAllocator);
metricOverview.AddMember("Total Floating Point Redundant Bytes", totalFloatRedundantBytes, jsonAllocator);
metricOverview.AddMember("Thread Num", threadDetailedMetricsMap.size(), jsonAllocator);
metricOverview.AddMember("DC", 1, jsonAllocator);
gDoc.AddMember("Metric Overview", metricOverview, jsonAllocator);

for(auto &threadMetrics : threadDetailedMetricsMap){
Expand Down