Skip to content

Commit

Permalink
reformat files
Browse files Browse the repository at this point in the history
Addresses #628.
  • Loading branch information
PeiMu committed Nov 14, 2022
1 parent 43ed751 commit bc8d5d2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 45 deletions.
2 changes: 1 addition & 1 deletion applications/newton/llvm-ir/performance_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ perf_benchmark_suite_float_opt: clean make_ll benchmark_suite_opt compile_lib co
interface_lib: clean make_ll soft_float_api_opt compile_lib

auto_test_compile:
clang++ auto_test.cpp -g -o auto_test
clang++ auto_test.cpp -D DEBUG_TS -g -o auto_test

all: default

Expand Down
30 changes: 20 additions & 10 deletions applications/newton/llvm-ir/performance_test/auto_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ struct perfData {
};

struct perfData recordData(const std::string& test_cases, const std::string& param_str, std::ofstream& ofs) {
#ifdef DEBUG_TS
const size_t iteration_num = 1;
#else
const size_t iteration_num = 5;
#endif

perfData perf_data = {0, 0, 0, 0};

Expand Down Expand Up @@ -179,20 +183,26 @@ int main(int argc, char** argv) {
return -1;
}

#ifdef DEBUG_TS
std::vector<std::vector<double>> normalParameters{
// {-1000.3, -999.2},
// {-134.5, -133.8},
// {-23.9, -23.1},
// {-5.4, -4.5},
// {-0.9, -0.4},
{0.2, 0.8},
// {9.7, 10.5},
// {35.75, 36.03},
// {476.84, 477.21},
// {999.8, 1000.9}
};

std::vector<double> range_extend{1};
#else
std::vector<std::vector<double>> normalParameters{
{-1000.3, -999.2},
{-134.5, -133.8},
{-23.9, -23.1},
{-5.4, -4.5},
{-0.9, -0.4},
{0.2, 0.8},
{9.7, 10.5},
{35.75, 36.03},
{476.84, 477.21},
{999.8, 1000.9}
};
std::vector<double> range_extend{1, 10, 100, 1000, 10000, 100000};
#endif

if (argc == 3) {
range_extend.clear();
Expand Down
44 changes: 23 additions & 21 deletions src/newton/newton-irPass-LLVMIR-optimizeByRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,35 @@ irPassLLVMIROptimizeByRange(State * N)
rangeAnalysis(N, boundInfo, mi);
}

// flexprint(N->Fe, N->Fm, N->Fpinfo, "simplify control flow by range\n");
// for (auto & mi : *Mod)
// {
// simplifyControlFlow(N, boundInfo, mi);
// }
//
// passManager.add(createCFGSimplificationPass());
// passManager.add(createInstSimplifyLegacyPass());
// passManager.run(*Mod);
//
// flexprint(N->Fe, N->Fm, N->Fpinfo, "infer bound\n");
// for (auto & mi : *Mod)
// {
// rangeAnalysis(N, boundInfo, mi);
// }
//
// flexprint(N->Fe, N->Fm, N->Fpinfo, "constant substitution\n");
// for (auto & mi : *Mod)
// {
// constantSubstitution(N, boundInfo, mi);
// }
#ifdef DEBUG_TS
flexprint(N->Fe, N->Fm, N->Fpinfo, "simplify control flow by range\n");
for (auto & mi : *Mod)
{
simplifyControlFlow(N, boundInfo, mi);
}

passManager.add(createCFGSimplificationPass());
passManager.add(createInstSimplifyLegacyPass());
passManager.run(*Mod);

flexprint(N->Fe, N->Fm, N->Fpinfo, "infer bound\n");
for (auto & mi : *Mod)
{
rangeAnalysis(N, boundInfo, mi);
}

flexprint(N->Fe, N->Fm, N->Fpinfo, "constant substitution\n");
for (auto & mi : *Mod)
{
constantSubstitution(N, boundInfo, mi);
}
#else
flexprint(N->Fe, N->Fm, N->Fpinfo, "shrink data type by range\n");
for (auto & mi : *Mod)
{
shrinkType(N, boundInfo, mi);
}
#endif

dumpIR(N, "output", std::move(Mod));
}
Expand Down
13 changes: 0 additions & 13 deletions src/newton/newton-irPass-LLVMIR-shrinkTypeByRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ getTypeInfo(State * N, Value * inValue,
switch (inInstType->getTypeID())
{
case Type::IntegerTyID:
// typeInformation = getShrinkIntType(N, inValue, vrRangeIt->second);
break;
case Type::FloatTyID:
break;
Expand Down Expand Up @@ -1858,19 +1857,7 @@ shrinkType(State * N, BoundInfo * boundInfo, Function & llvmIrFunction)
* 1. construct instruction dependency link
* 2. work with roll back strategies
* */
// std::vector<std::vector<Value *>> prevDepLink = getDependencyLink(N, llvmIrFunction);
std::map<Value *, typeInfo> typeChangedInst = shrinkInstType(N, boundInfo, llvmIrFunction);
mergeCast(N, llvmIrFunction, boundInfo->virtualRegisterRange, typeChangedInst);
// std::vector<std::vector<Value *>> newDepLink = getDependencyLink(N, llvmIrFunction);

// for (auto & depLink : newDepLink)
// {
// if (rollBackStrategy(N, depLink))
// {
// rollBackDependencyLink(N, depLink, boundInfo->virtualRegisterRange, typeChangedInst);
// }
// }

// mergeCast(N, llvmIrFunction, boundInfo->virtualRegisterRange, typeChangedInst);
}
}

0 comments on commit bc8d5d2

Please sign in to comment.