Skip to content

Commit

Permalink
set enableOverload and enableBuiltinAssume as options
Browse files Browse the repository at this point in the history
Addresses #653.
  • Loading branch information
PeiMu committed May 15, 2023
1 parent b55cd95 commit 4f334c0
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 20 deletions.
46 changes: 46 additions & 0 deletions analysis/statistics/f0dd9235e099cd355073ed8d65f12fd8f81481b8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

changeset: 1483:f0dd9235e099cd355073ed8d65f12fd8f81481b8
char kNewtonVersion[] = "0.3-alpha-1483 (f0dd9235e099cd355073ed8d65f12fd8f81481b8) (build 05-13-2023-15:[email protected]_64)";
\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s
\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt

Informational Report:
---------------------
Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)...

Kernel 0 is a valid kernel:

1 1
-0.5 -0
1 0
0.5 0
0 -1
-0 -1


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0)

Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1)


Kernel 1 is a valid kernel:

1 0
-0.5 1
1 -2
0.5 -1
-0 -2
0 -2


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0)

Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2)




2 changes: 2 additions & 0 deletions src/common/common-data-structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@ typedef enum
kNewtonIrPassLLVMIRLivenessAnalysis = (1 << 14),
kNewtonirPassLLVMIROptimizeByRange = (1 << 15),
kNewtonirPassLLVMIRAutoQuantization = (1 << 16),
kNewtonirPassLLVMIREnableOverload = (1 << 17),
kNewtonirPassLLVMIREnableBuiltinAssume = (1 << 18),
/*
* Code depends on this bringing up the rear.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/newton/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ main(int argc, char *argv[])
{"targetParam", required_argument, 0, 'T'},
{"llvm-ir", required_argument, 0, 'I'},
{"llvm-ir-liveness-check", no_argument, 0, 'L'},
{"llvm-ir-enable-overload", no_argument, 0, 'o'},
{"llvm-ir-enable-builtin-assume", no_argument, 0, 'A'},
{"llvm-ir-auto-quantization", no_argument, 0, 'Q'},
{"estimator-synthesis", required_argument, 0, 420},
{"process", required_argument, 0, 421},
Expand Down Expand Up @@ -424,6 +426,18 @@ main(int argc, char *argv[])
break;
}

case 'o':
{
N->irPasses |= kNewtonirPassLLVMIREnableOverload;
break;
}

case 'A':
{
N->irPasses |= kNewtonirPassLLVMIREnableBuiltinAssume;
break;
}

case 'Q':
{
N->irPasses |= kNewtonirPassLLVMIRAutoQuantization;
Expand Down
38 changes: 20 additions & 18 deletions src/newton/newton-irPass-LLVMIR-optimizeByRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ overloadFunc(std::unique_ptr<Module> & Mod, std::map<std::string, CallInst *> &
}

void
irPassLLVMIROptimizeByRange(State * N)
irPassLLVMIROptimizeByRange(State * N, bool enableOverload, bool enableBuiltinAssume)
{
if (N->llvmIR == nullptr)
{
Expand Down Expand Up @@ -368,7 +368,7 @@ irPassLLVMIROptimizeByRange(State * N)

callerMap.clear();
funcBoundInfo.clear();
useOverLoad = true;
useOverLoad = enableOverload;
for (auto & mi : *Mod)
{
auto boundInfo = new BoundInfo();
Expand Down Expand Up @@ -448,27 +448,29 @@ irPassLLVMIROptimizeByRange(State * N)
if (useOverLoad)
overloadFunc(Mod, callerMap);

for (auto & mi : *Mod)
{
auto boundInfo = new BoundInfo();
mergeBoundInfo(boundInfo, globalBoundInfo);
rangeAnalysis(N, mi, boundInfo, callerMap, typeRange, virtualRegisterVectorRange, useOverLoad);
funcBoundInfo.emplace(mi.getName().str(), boundInfo);
std::vector<std::string> calleeNames;
collectCalleeInfo(calleeNames, funcBoundInfo, boundInfo);
}

flexprint(N->Fe, N->Fm, N->Fpinfo, "emit builtin_assume intrinsic\n");
for (auto & mi : *Mod)
{
auto boundInfoIt = funcBoundInfo.find(mi.getName().str());
if (boundInfoIt != funcBoundInfo.end()) {
emitAssume(N, boundInfoIt->second, mi);
if (enableBuiltinAssume) {
for (auto & mi : *Mod)
{
auto boundInfo = new BoundInfo();
mergeBoundInfo(boundInfo, globalBoundInfo);
rangeAnalysis(N, mi, boundInfo, callerMap, typeRange, virtualRegisterVectorRange, useOverLoad);
funcBoundInfo.emplace(mi.getName().str(), boundInfo);
std::vector<std::string> calleeNames;
collectCalleeInfo(calleeNames, funcBoundInfo, boundInfo);
}

flexprint(N->Fe, N->Fm, N->Fpinfo, "emit builtin_assume intrinsic\n");
for (auto & mi : *Mod)
{
auto boundInfoIt = funcBoundInfo.find(mi.getName().str());
if (boundInfoIt != funcBoundInfo.end()) {
emitAssume(N, boundInfoIt->second, mi);
}
// else
// {
// assert(false);
// }
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/newton/newton-irPass-LLVMIR-optimizeByRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern "C"
#endif /* __cplusplus */

void
irPassLLVMIROptimizeByRange(State * N);
irPassLLVMIROptimizeByRange(State * N, bool enableOverload, bool enableBuiltinAssume);

#ifdef __cplusplus
} /* extern "C" */
Expand Down
4 changes: 3 additions & 1 deletion src/newton/newton.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ processNewtonFile(State * N, char * filename)
}
if (N->irPasses & kNewtonirPassLLVMIROptimizeByRange)
{
irPassLLVMIROptimizeByRange(N);
bool enableOverload = N->irPasses & kNewtonirPassLLVMIREnableOverload;
bool enableBuiltinAssume = N->irPasses & kNewtonirPassLLVMIREnableBuiltinAssume;
irPassLLVMIROptimizeByRange(N, enableOverload, enableBuiltinAssume);
}
if (N->irPasses & kNewtonirPassLLVMIRAutoQuantization)
{
Expand Down

0 comments on commit 4f334c0

Please sign in to comment.