[HIPIFY][fix] Fix for the rest of found bugs in Statistics
+ Signs of the converted file are extended + Total converted lines and total elapsed time are fixed + Zero rates are excluded from statistics
This commit is contained in:
@@ -51,7 +51,7 @@ const char *apiNames[NUM_API_TYPES] = {
|
|||||||
"cuRAND API",
|
"cuRAND API",
|
||||||
"cuDNN API",
|
"cuDNN API",
|
||||||
"cuFFT API",
|
"cuFFT API",
|
||||||
"cuSPARSE"
|
"cuSPARSE API"
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -109,19 +109,33 @@ int StatCounter::getConvSum() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StatCounter::print(std::ostream* csv, llvm::raw_ostream* printOut, const std::string& prefix) {
|
void StatCounter::print(std::ostream* csv, llvm::raw_ostream* printOut, const std::string& prefix) {
|
||||||
conditionalPrint(csv, printOut, "\nCUDA ref type;Count\n", "[HIPIFY] info: " + prefix + " refs by type:\n");
|
for (int i = 0; i < NUM_CONV_TYPES; i++) {
|
||||||
|
if (convTypeCounters[i] > 0) {
|
||||||
|
conditionalPrint(csv, printOut, "\nCUDA ref type;Count\n", "[HIPIFY] info: " + prefix + " refs by type:\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (int i = 0; i < NUM_CONV_TYPES; i++) {
|
for (int i = 0; i < NUM_CONV_TYPES; i++) {
|
||||||
if (convTypeCounters[i] > 0) {
|
if (convTypeCounters[i] > 0) {
|
||||||
printStat(csv, printOut, counterNames[i], convTypeCounters[i]);
|
printStat(csv, printOut, counterNames[i], convTypeCounters[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conditionalPrint(csv, printOut, "\nCUDA API;Count\n", "[HIPIFY] info: " + prefix + " refs by API:\n");
|
|
||||||
for (int i = 0; i < NUM_API_TYPES; i++) {
|
for (int i = 0; i < NUM_API_TYPES; i++) {
|
||||||
printStat(csv, printOut, apiNames[i], apiCounters[i]);
|
if (apiCounters[i] > 0) {
|
||||||
|
conditionalPrint(csv, printOut, "\nCUDA API;Count\n", "[HIPIFY] info: " + prefix + " refs by API:\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
conditionalPrint(csv, printOut, "\nCUDA ref name;Count\n", "[HIPIFY] info: " + prefix + " refs by names:\n");
|
for (int i = 0; i < NUM_API_TYPES; i++) {
|
||||||
for (const auto &it : counters) {
|
if (apiCounters[i] > 0) {
|
||||||
printStat(csv, printOut, it.first, it.second);
|
printStat(csv, printOut, apiNames[i], apiCounters[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (counters.size() > 0) {
|
||||||
|
conditionalPrint(csv, printOut, "\nCUDA ref name;Count\n", "[HIPIFY] info: " + prefix + " refs by names:\n");
|
||||||
|
for (const auto &it : counters) {
|
||||||
|
printStat(csv, printOut, it.first, it.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +148,6 @@ Statistics::Statistics(const std::string& name): fileName(name) {
|
|||||||
totalBytes = (int) src_file.tellg();
|
totalBytes = (int) src_file.tellg();
|
||||||
if (totalBytes < 0) {
|
if (totalBytes < 0) {
|
||||||
totalBytes = 0;
|
totalBytes = 0;
|
||||||
hasErrors = true;
|
|
||||||
}
|
}
|
||||||
startTime = chr::steady_clock::now();
|
startTime = chr::steady_clock::now();
|
||||||
}
|
}
|
||||||
@@ -153,17 +166,27 @@ void Statistics::incrementCounter(const hipCounter &counter, const std::string&
|
|||||||
void Statistics::add(const Statistics &other) {
|
void Statistics::add(const Statistics &other) {
|
||||||
supported.add(other.supported);
|
supported.add(other.supported);
|
||||||
unsupported.add(other.unsupported);
|
unsupported.add(other.unsupported);
|
||||||
totalBytes += other.totalBytes;
|
|
||||||
totalLines += other.totalLines;
|
|
||||||
touchedBytes += other.touchedBytes;
|
touchedBytes += other.touchedBytes;
|
||||||
|
totalBytes += other.totalBytes;
|
||||||
|
touchedLines += other.touchedLines;
|
||||||
|
totalLines += other.totalLines;
|
||||||
|
if (other.hasErrors && !hasErrors) {
|
||||||
|
hasErrors = true;
|
||||||
|
}
|
||||||
|
if (startTime > other.startTime) {
|
||||||
|
startTime = other.startTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Statistics::lineTouched(int lineNumber) {
|
void Statistics::lineTouched(int lineNumber) {
|
||||||
touchedLines.insert(lineNumber);
|
touchedLinesSet.insert(lineNumber);
|
||||||
|
touchedLines = touchedLinesSet.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Statistics::bytesChanged(int bytes) {
|
void Statistics::bytesChanged(int bytes) {
|
||||||
touchedBytes += bytes;
|
touchedBytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Statistics::markCompletion() {
|
void Statistics::markCompletion() {
|
||||||
completionTime = chr::steady_clock::now();
|
completionTime = chr::steady_clock::now();
|
||||||
}
|
}
|
||||||
@@ -179,7 +202,6 @@ void Statistics::print(std::ostream* csv, llvm::raw_ostream* printOut, bool skip
|
|||||||
std::string str = "\n ERROR: Statistics is invalid due to failed hipification.\n\n";
|
std::string str = "\n ERROR: Statistics is invalid due to failed hipification.\n\n";
|
||||||
conditionalPrint(csv, printOut, str, str);
|
conditionalPrint(csv, printOut, str, str);
|
||||||
}
|
}
|
||||||
size_t changedLines = touchedLines.size();
|
|
||||||
// Total number of (un)supported refs that were converted.
|
// Total number of (un)supported refs that were converted.
|
||||||
int supportedSum = supported.getConvSum();
|
int supportedSum = supported.getConvSum();
|
||||||
int unsupportedSum = unsupported.getConvSum();
|
int unsupportedSum = unsupported.getConvSum();
|
||||||
@@ -189,10 +211,10 @@ void Statistics::print(std::ostream* csv, llvm::raw_ostream* printOut, bool skip
|
|||||||
printStat(csv, printOut, "CONVERSION %", 100 - (0 == allSum ? 100 : std::lround(double(unsupportedSum * 100) / double(allSum))));
|
printStat(csv, printOut, "CONVERSION %", 100 - (0 == allSum ? 100 : std::lround(double(unsupportedSum * 100) / double(allSum))));
|
||||||
printStat(csv, printOut, "REPLACED bytes", touchedBytes);
|
printStat(csv, printOut, "REPLACED bytes", touchedBytes);
|
||||||
printStat(csv, printOut, "TOTAL bytes", totalBytes);
|
printStat(csv, printOut, "TOTAL bytes", totalBytes);
|
||||||
printStat(csv, printOut, "CHANGED lines of code", changedLines);
|
printStat(csv, printOut, "CHANGED lines of code", touchedLines);
|
||||||
printStat(csv, printOut, "TOTAL lines of code", totalLines);
|
printStat(csv, printOut, "TOTAL lines of code", totalLines);
|
||||||
printStat(csv, printOut, "CODE CHANGED (in bytes) %", 0 == totalBytes ? 0 : std::lround(double(touchedBytes * 100) / double(totalBytes)));
|
printStat(csv, printOut, "CODE CHANGED (in bytes) %", 0 == totalBytes ? 0 : std::lround(double(touchedBytes * 100) / double(totalBytes)));
|
||||||
printStat(csv, printOut, "CODE CHANGED (in lines) %", 0 == totalLines ? 0 : std::lround(double(changedLines * 100) / double(totalLines)));
|
printStat(csv, printOut, "CODE CHANGED (in lines) %", 0 == totalLines ? 0 : std::lround(double(touchedLines * 100) / double(totalLines)));
|
||||||
typedef std::chrono::duration<double, std::milli> duration;
|
typedef std::chrono::duration<double, std::milli> duration;
|
||||||
duration elapsed = completionTime - startTime;
|
duration elapsed = completionTime - startTime;
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
@@ -204,25 +226,20 @@ void Statistics::print(std::ostream* csv, llvm::raw_ostream* printOut, bool skip
|
|||||||
|
|
||||||
void Statistics::printAggregate(std::ostream *csv, llvm::raw_ostream* printOut) {
|
void Statistics::printAggregate(std::ostream *csv, llvm::raw_ostream* printOut) {
|
||||||
Statistics globalStats = getAggregate();
|
Statistics globalStats = getAggregate();
|
||||||
globalStats.hasErrors = false;
|
|
||||||
conditionalPrint(csv, printOut, "\nTOTAL statistics:\n", "\n[HIPIFY] info: TOTAL statistics:\n");
|
|
||||||
// A file is considered "converted" if we made any changes to it.
|
// A file is considered "converted" if we made any changes to it.
|
||||||
int convertedFiles = 0;
|
int convertedFiles = 0;
|
||||||
for (const auto& p : stats) {
|
for (const auto& p : stats) {
|
||||||
if (!p.second.touchedLines.empty()) {
|
if (p.second.touchedLines && p.second.totalBytes &&
|
||||||
|
p.second.totalLines && !p.second.hasErrors) {
|
||||||
convertedFiles++;
|
convertedFiles++;
|
||||||
}
|
}
|
||||||
if (!globalStats.hasErrors && p.second.hasErrors) {
|
|
||||||
globalStats.hasErrors = true;
|
|
||||||
}
|
|
||||||
if (globalStats.startTime > p.second.startTime) {
|
|
||||||
globalStats.startTime = p.second.startTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
printStat(csv, printOut, "CONVERTED files", convertedFiles);
|
|
||||||
printStat(csv, printOut, "PROCESSED files", stats.size());
|
|
||||||
globalStats.markCompletion();
|
globalStats.markCompletion();
|
||||||
globalStats.print(csv, printOut);
|
globalStats.print(csv, printOut);
|
||||||
|
std::string str = "TOTAL statistics:";
|
||||||
|
conditionalPrint(csv, printOut, "\n" + str + "\n", "\n[HIPIFY] info: " + str + "\n");
|
||||||
|
printStat(csv, printOut, "CONVERTED files", convertedFiles);
|
||||||
|
printStat(csv, printOut, "PROCESSED files", stats.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Static state management ////
|
//// Static state management ////
|
||||||
|
|||||||
@@ -157,9 +157,10 @@ class Statistics {
|
|||||||
StatCounter supported;
|
StatCounter supported;
|
||||||
StatCounter unsupported;
|
StatCounter unsupported;
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
std::set<int> touchedLines = {};
|
std::set<int> touchedLinesSet = {};
|
||||||
unsigned touchedBytes = 0;
|
unsigned touchedLines = 0;
|
||||||
unsigned totalLines = 0;
|
unsigned totalLines = 0;
|
||||||
|
unsigned touchedBytes = 0;
|
||||||
int totalBytes = 0;
|
int totalBytes = 0;
|
||||||
chr::steady_clock::time_point startTime;
|
chr::steady_clock::time_point startTime;
|
||||||
chr::steady_clock::time_point completionTime;
|
chr::steady_clock::time_point completionTime;
|
||||||
|
|||||||
مرجع در شماره جدید
Block a user