|
| 1 | +#include <vector> |
| 2 | + |
| 3 | +#define CATCH_CONFIG_MAIN |
| 4 | +#include "catch.hpp" |
| 5 | +#include <AMMBench.h> |
| 6 | +using namespace std; |
| 7 | +using namespace INTELLI; |
| 8 | +using namespace torch; |
| 9 | +void runSingleThreadTest(std::string configName) { |
| 10 | + ConfigMapPtr cfg = newConfigMap(); |
| 11 | + cfg->fromFile(configName); |
| 12 | + AMMBench::MatrixLoaderTable mLoaderTable; |
| 13 | + uint64_t sketchDimension; |
| 14 | + sketchDimension = cfg->tryU64("sketchDimension", 50, true); |
| 15 | + uint64_t coreBind = cfg->tryU64("coreBind", 0, true); |
| 16 | + UtilityFunctions::bind2Core((int) coreBind); |
| 17 | + torch::set_num_threads(1); |
| 18 | + std::string ptFile = cfg->tryString("ptFile", "torchscripts/FDAMM.pt", true); |
| 19 | + |
| 20 | + //uint64_t customResultName = cfg->tryU64("customResultName", 0, true); |
| 21 | + INTELLI_INFO("Place me at core" + to_string(coreBind)); |
| 22 | + INTELLI_INFO( |
| 23 | + "with sketch" + to_string(sketchDimension)); |
| 24 | + torch::jit::script::Module module; |
| 25 | + INTELLI_INFO("Try pt file " + ptFile); |
| 26 | + module = torch::jit::load(ptFile); |
| 27 | + std::string matrixLoaderTag = cfg->tryString("matrixLoaderTag", "random", true); |
| 28 | + auto matLoaderPtr = mLoaderTable.findMatrixLoader(matrixLoaderTag); |
| 29 | + assert(matLoaderPtr); |
| 30 | + matLoaderPtr->setConfig(cfg); |
| 31 | + auto A = matLoaderPtr->getA(); |
| 32 | + auto B = matLoaderPtr->getB(); |
| 33 | + /*torch::manual_seed(114514); |
| 34 | +//555 |
| 35 | +auto A = torch::rand({(long) aRow, (long) aCol}); |
| 36 | +auto B = torch::rand({(long) aCol, (long) bCol});*/ |
| 37 | + INTELLI_INFO("Generation done, conducting..."); |
| 38 | + ThreadPerf pef((int) coreBind); |
| 39 | + pef.setPerfList(); |
| 40 | + pef.start(); |
| 41 | + auto C =module.forward({A, B, (long) sketchDimension}).toTensor(); |
| 42 | + pef.end(); |
| 43 | + std::string ruName = "default"; |
| 44 | + |
| 45 | + auto resultCsv = pef.resultToConfigMap(); |
| 46 | + resultCsv->toFile(ruName + ".csv"); |
| 47 | + INTELLI_INFO("Done. here is result"); |
| 48 | + std::cout << resultCsv->toString() << endl; |
| 49 | +} |
| 50 | +TEST_CASE("Test the Tug of War", "[short]") |
| 51 | +{ |
| 52 | + int a = 0; |
| 53 | + runSingleThreadTest("scripts/config_tugOfWar.csv"); |
| 54 | + // place your test here |
| 55 | + REQUIRE(a == 0); |
| 56 | +} |
0 commit comments