Skip to content
Merged
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
16 changes: 14 additions & 2 deletions benchmark/src/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void runSingleThreadTest(std::string configName) {
cfg->fromFile(configName);
AMMBench::MatrixLoaderTable mLoaderTable;
uint64_t sketchDimension;
ConfigMapPtr breakDownResult= nullptr;
sketchDimension = cfg->tryU64("sketchDimension", 50, true);
uint64_t coreBind = cfg->tryU64("coreBind", 0, true);
uint64_t usingMeter = cfg->tryU64("usingMeter", 0, true);
Expand Down Expand Up @@ -81,6 +82,7 @@ auto B = torch::rand({(long) aCol, (long) bCol});*/
if (eMeter != nullptr) {
eMeter->stopMeter();
}
breakDownResult=br.getBreakDown();
} else {
AMMBench::CPPAlgoTable cppAlgoTable;
std::string cppAlgoTag = cfg->tryString("cppAlgoTag", "mm", true);
Expand All @@ -101,7 +103,10 @@ auto B = torch::rand({(long) aCol, (long) bCol});*/
if (eMeter != nullptr) {
eMeter->stopMeter();
}

if(useCPP && cppAlgoPtr)
{
breakDownResult=cppAlgoPtr->getBreakDown();
}
}

std::string ruName = "default";
Expand Down Expand Up @@ -130,8 +135,15 @@ auto B = torch::rand({(long) aCol, (long) bCol});*/
resultCsv->edit("froError", (double) froError);
resultCsv->edit("errorBoundRatio", (double) errorBoundRatio);
resultCsv->toFile(ruName + ".csv");
INTELLI_INFO("Done. here is result");
INTELLI_INFO("Done. here is overall result");
std::cout << resultCsv->toString() << endl;
if(breakDownResult)
{
INTELLI_INFO("I also have some break down result");
std::cout << breakDownResult->toString() << endl;
breakDownResult->toFile(ruName+"_breakdown.csv");
}

}

int main(int argc, char **argv) {
Expand Down
2 changes: 1 addition & 1 deletion commit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BRANCH=NIGHTLY_TEST
BRANCH=BREAKDOWN
git init
git checkout -b $BRANCH
git add .
Expand Down
3 changes: 1 addition & 2 deletions commit_info
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
1. Update the example scripts in scripts/scanThreads
2. Add the parameter passing logic to CPPAlgos
1. add the function of exporting algorithm breakdown
17 changes: 16 additions & 1 deletion include/CPPAlgos/AbstractCPPAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ namespace AMMBench {
* @brief The abstract class of c++ algos
*/
class AbstractCPPAlgo {
protected:
/**
* @brief the default time break dowm variables
* @note By default, we decompose each AMM as
* - buildA, to translate A matrix
* - buildB, to translate B matrix
* - fABTime, to conduct mm or table look-up over the reduced A,B
* - postProcessTime, if f(A,B) is not the finall result, measure the time spend for post process
*/
uint64_t buildATime=0,buildBTime=0,fABTime=0,postProcessTime=0;

public:
AbstractCPPAlgo() {

Expand All @@ -40,7 +51,11 @@ class AbstractCPPAlgo {
* @return the output c matrix
*/
virtual torch::Tensor amm(torch::Tensor A, torch::Tensor B, uint64_t sketchSize);

/**
* @brief to get the breakdown of this algorithm, returned as a config map
* @return the key-value table breakdown in ConfigMapPtr;
*/
virtual INTELLI::ConfigMapPtr getBreakDown();
};
/**
* @ingroup AMMBENCH_CppAlgos
Expand Down
13 changes: 12 additions & 1 deletion include/Parallelization/BlockPartitionRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ class BlockPartitionWorker : public INTELLI::AbstractC20Thread {

}
uint64_t getElapsedTime();

/**
* @brief to export the algorithm breakdown
* @note only valid for c++ algo
* @return the key-value table breakdown in ConfigMapPtr;
*/
virtual INTELLI::ConfigMapPtr getBreakDown();
};
/**
* @ingroup PARTITION_RUNNER
Expand Down Expand Up @@ -169,6 +174,12 @@ class BlockPartitionRunner {
* @param ru The result csv to be appended
*/
void appendThreadInfo(INTELLI::ConfigMapPtr ru);
/**
* @brief to export the algorithm breakdown
* @note only valid for c++ algo
* @return the key-value table breakdown in ConfigMapPtr;
*/
virtual INTELLI::ConfigMapPtr getBreakDown();
};

} // AMMBench
Expand Down
20 changes: 17 additions & 3 deletions src/CPPAlgos/AbstractCPPAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
//

#include <CPPAlgos/AbstractCPPAlgo.h>
#include <Utils/UtilityFunctions.h>
#include <time.h>
void AMMBench::AbstractCPPAlgo::setConfig(INTELLI::ConfigMapPtr cfg) {
assert(cfg);
}
torch::Tensor AMMBench::AbstractCPPAlgo::amm(torch::Tensor A, torch::Tensor B, uint64_t sketchSize) {
std::cout << sketchSize;
INTELLI_INFO("I am mm");
return torch::matmul(A, B);
assert(sketchSize);
struct timeval tstart;
//INTELLI_INFO("I am mm");
gettimeofday(&tstart,NULL);
auto C= torch::matmul(A, B);
fABTime=INTELLI::UtilityFunctions::timeLastUs(tstart);
return C;
}
INTELLI::ConfigMapPtr AMMBench::AbstractCPPAlgo::getBreakDown() {
INTELLI::ConfigMapPtr cfg = newConfigMap();
cfg->edit("buildATime", (uint64_t)buildATime);
cfg->edit("buildBTime", (uint64_t)buildBTime);
cfg->edit("fABTime", (uint64_t)fABTime);
cfg->edit("postProcessTime",(uint64_t)postProcessTime);
return cfg;
}
2 changes: 1 addition & 1 deletion src/CPPAlgos/INT8CPPAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ torch::Tensor AMMBench::INT8CPPAlgo::amm(torch::Tensor A, torch::Tensor B, uint6
scalingB = torch::abs(B).max().item<float>() / 127.0;
auto ta = (A / scalingA).to(torch::kInt8);
auto tb = (B / scalingB).to(torch::kInt8);
// torch::matmul(ta, tb);
torch::matmul(ta, tb);
return torch::zeros({A.size(0), B.size(1)});
return torch::matmul(ta, tb).to(torch::kFloat) * scalingA * scalingB;
//return C*scalingA*scalingB/127.0/127.0;
Expand Down
11 changes: 11 additions & 0 deletions src/Parallelization/BlockPartitionRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ void AMMBench::BlockPartitionWorker::inlineMain() {
gettimeofday(&tend, NULL);
//std::cout<<subC;
}
INTELLI::ConfigMapPtr AMMBench::BlockPartitionWorker::getBreakDown() {
if(useCPP&&cppAlgoPtr)
{
return cppAlgoPtr->getBreakDown();
}
return nullptr;
}
uint64_t AMMBench::BlockPartitionWorker::getElapsedTime() {
return INTELLI::UtilityFunctions::timeLast(tstart, tend);
}
Expand Down Expand Up @@ -133,4 +140,8 @@ void AMMBench::BlockPartitionRunner::appendThreadInfo(INTELLI::ConfigMapPtr ru)
std::string keyElapesedTime = "thread" + to_string(i) + "RunTime";
ru->edit(keyElapesedTime, (uint64_t) workers[i]->getElapsedTime());
}
}

INTELLI::ConfigMapPtr AMMBench::BlockPartitionRunner::getBreakDown() {
return workers[0]->getBreakDown();
}