Merge Node update status file
Some checks are pending
Validate Operations / validate-operations (push) Has started running
Some checks are pending
Validate Operations / validate-operations (push) Has started running
This commit is contained in:
@@ -14,12 +14,15 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_os_ostream.h"
|
#include "llvm/Support/raw_os_ostream.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "DCPGraph/DCPAnalysis.hpp"
|
#include "DCPGraph/DCPAnalysis.hpp"
|
||||||
@@ -36,32 +39,86 @@ void generateReport(func::FuncOp funcOp, const std::string& name) {
|
|||||||
if (outputDir.empty())
|
if (outputDir.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string dialectsDir = outputDir + "/dialects/stats";
|
std::string dialectsDir = outputDir + "/dcp_graph";
|
||||||
createDirectory(dialectsDir);
|
createDirectory(dialectsDir);
|
||||||
|
|
||||||
std::fstream file(dialectsDir + "/" + name + ".txt", std::ios::out);
|
std::fstream file(dialectsDir + "/" + name + ".txt", std::ios::out);
|
||||||
llvm::raw_os_ostream os(file);
|
llvm::raw_os_ostream os(file);
|
||||||
|
|
||||||
uint64_t numSpatCompute = 0;
|
uint64_t numSpatCompute = 0;
|
||||||
std::vector<uint64_t> numWeights;
|
std::vector<std::tuple<uint64_t, uint64_t, uint64_t>> collectedData;
|
||||||
std::vector<uint64_t> numInstructions;
|
|
||||||
|
|
||||||
for (auto spatCompute : funcOp.getOps<SpatCompute>()) {
|
for (auto spatCompute : funcOp.getOps<SpatCompute>()) {
|
||||||
numSpatCompute++;
|
uint64_t numInst = 0;
|
||||||
numWeights.push_back(spatCompute.getWeights().size());
|
for (auto& _ : spatCompute.getRegion().front())
|
||||||
uint64_t numInst = 0;
|
|
||||||
for(auto& _ : spatCompute.getRegion().front() ){
|
|
||||||
numInst++;
|
numInst++;
|
||||||
}
|
collectedData.push_back({numSpatCompute++, spatCompute.getWeights().size(), numInst});
|
||||||
numInstructions.push_back(numInst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::stable_sort(collectedData.begin(),
|
||||||
|
collectedData.end(),
|
||||||
|
[](std::tuple<uint64_t, uint64_t, uint64_t> lft, std::tuple<uint64_t, uint64_t, uint64_t> rgt) {
|
||||||
|
auto [iLft, weightLft, numInstLft] = lft;
|
||||||
|
auto [iRgt, weightRgt, numInstRgt] = rgt;
|
||||||
|
|
||||||
|
if (numInstLft < numInstRgt)
|
||||||
|
return false;
|
||||||
|
else if (numInstRgt < numInstLft)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (weightLft < weightRgt)
|
||||||
|
return false;
|
||||||
|
else if (weightRgt < weightLft)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (iLft < iRgt)
|
||||||
|
return true;
|
||||||
|
else if (iRgt < iLft)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
for (uint64_t cI = 0; cI < numSpatCompute; ++cI) {
|
for (uint64_t cI = 0; cI < numSpatCompute; ++cI) {
|
||||||
os << "Compute " << cI << ":\n";
|
uint64_t lastIndex = cI;
|
||||||
os << "\tNumber of instructions " << numInstructions[cI] << "\n";
|
auto [currentComputeId, currentWeight, currentNumInst] = collectedData[cI];
|
||||||
os << "\tNumber of used crossbars " << numWeights[cI] << "\n";
|
|
||||||
|
for (uint64_t nI = cI + 1; nI < numSpatCompute; ++nI) {
|
||||||
|
auto [nextComputeId, nextWeight, nextNumInst] = collectedData[nI];
|
||||||
|
if (currentWeight == nextWeight && currentNumInst == nextNumInst)
|
||||||
|
lastIndex = nI;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "Compute " << currentComputeId;
|
||||||
|
auto expectedPrintedValue = currentComputeId + 1;
|
||||||
|
bool rangePrinted = false;
|
||||||
|
cI++;
|
||||||
|
for (; cI < lastIndex; ++cI){
|
||||||
|
auto candidateToPrint = std::get<0>(collectedData[cI]);
|
||||||
|
if (candidateToPrint == expectedPrintedValue){
|
||||||
|
expectedPrintedValue = candidateToPrint + 1;
|
||||||
|
rangePrinted = true;
|
||||||
|
} else {
|
||||||
|
if (rangePrinted) {
|
||||||
|
os << " - " << expectedPrintedValue - 1;
|
||||||
|
}
|
||||||
|
os << " , " << candidateToPrint;
|
||||||
|
rangePrinted = false;
|
||||||
|
expectedPrintedValue = candidateToPrint + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rangePrinted && currentComputeId != expectedPrintedValue - 1){
|
||||||
|
os << " - " << expectedPrintedValue - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
os << " :\n";
|
||||||
|
os << "\tNumber of instructions " << currentNumInst << "\n";
|
||||||
|
os << "\tNumber of used crossbars " << currentWeight << "\n";
|
||||||
|
cI = lastIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
os.flush();
|
os.flush();
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user