-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBenchmark.cpp
More file actions
64 lines (59 loc) · 2.04 KB
/
Copy pathBenchmark.cpp
File metadata and controls
64 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*! \file Benchmark.h*/
/**
* @brief This is the main entry point of the entire program.
* We use this as the entry point for benchmarking.
*/
#include <AMMBench.h>
#include <Utils/UtilityFunctions.h>
using namespace std;
using namespace INTELLI;
using namespace torch;
void runSingleThreadTest(std::string configName) {
ConfigMapPtr cfg = newConfigMap();
cfg->fromFile(configName);
AMMBench::MatrixLoaderTable mLoaderTable;
uint64_t sketchDimension;
sketchDimension = cfg->tryU64("sketchDimension", 50, true);
uint64_t coreBind = cfg->tryU64("coreBind", 0, true);
UtilityFunctions::bind2Core((int) coreBind);
torch::set_num_threads(1);
std::string ptFile = cfg->tryString("ptFile", "torchscripts/FDAMM.pt", true);
//uint64_t customResultName = cfg->tryU64("customResultName", 0, true);
INTELLI_INFO("Place me at core" + to_string(coreBind));
INTELLI_INFO(
"with sketch" + to_string(sketchDimension));
torch::jit::script::Module module;
INTELLI_INFO("Try pt file " + ptFile);
module = torch::jit::load(ptFile);
std::string matrixLoaderTag = cfg->tryString("matrixLoaderTag", "random", true);
auto matLoaderPtr = mLoaderTable.findMatrixLoader(matrixLoaderTag);
assert(matLoaderPtr);
matLoaderPtr->setConfig(cfg);
auto A = matLoaderPtr->getA();
auto B = matLoaderPtr->getB();
/*torch::manual_seed(114514);
//555
auto A = torch::rand({(long) aRow, (long) aCol});
auto B = torch::rand({(long) aCol, (long) bCol});*/
INTELLI_INFO("Generation done, conducting...");
ThreadPerf pef((int) coreBind);
pef.setPerfList();
pef.start();
auto C =module.forward({A, B, (long) sketchDimension}).toTensor();
pef.end();
std::string ruName = "default";
auto resultCsv = pef.resultToConfigMap();
resultCsv->toFile(ruName + ".csv");
INTELLI_INFO("Done. here is result");
std::cout << resultCsv->toString() << endl;
}
int main(int argc, char **argv) {
string configName, outPrefix = "";
if (argc >= 2) {
configName += argv[1];
} else {
configName = "config.csv";
}
runSingleThreadTest(configName);
return 0;
}