(.js)
laraImport("clava.memoi.MemoiGen");
(.lara)
import clava.memoi.MemoiGen;
new MemoiGen(target)
ApplyPolicy
MemoiGen.ApplyPolicy = {
ALWAYS : function(report) {
return true;
},
NOT_EMPTY : function(report) {
if(MemoiUtils.mean(report.elements, report.reportCount) === 0) {
debug('skipped - no calls');
return false;
}
return true;
},
_OVER_X_PCT : function(report, x) {
var hits = MemoiUtils.mean(report.hits, report.reportCount);
var calls = MemoiUtils.mean(report.calls, report.reportCount);
var ratio = calls === 0 ? 0 : hits/calls;
println("_OVER_X_PCT " + x);
println("hits: " + hits);
println("calls: " + calls);
println("ratio: " + ratio);
return ratio > x;
},
OVER_15_PCT : function(report) {
return MemoiGen.ApplyPolicy._OVER_X_PCT(report, 0.15);
},
OVER_25_PCT : function(report) {
return MemoiGen.ApplyPolicy._OVER_X_PCT(report, 0.25);
},
OVER_50_PCT : function(report) {
return MemoiGen.ApplyPolicy._OVER_X_PCT(report, 0.5);
},
OVER_75_PCT : function(report) {
return MemoiGen.ApplyPolicy._OVER_X_PCT(report, 0.75);
},
OVER_90_PCT : function(report) {
return MemoiGen.ApplyPolicy._OVER_X_PCT(report, 0.9);
}
};
generate()
Generates a table for all calls of the target function.
If a profiling reports are provided, the reports are used to
determine whether to generate for all target or for each single
target.
generateAll()
Generates a table for all calls of the target function.
If a profiling reports are provided, the reports are used to
determine whether to generate for all target or for each single
target.
generateEach()
Generates a table for each call of the target function.
If a profiling reports are provided, the reports are used to
determine whether to generate for all target or for each single
target.
generatePerfectInst()
setApplyPolicy(policy)
Sets the apply policy.
Defaults to MemoiApplyPolicy.NOT_EMPTY.
setApproxBits(bits)
Sets the approximation bits in the final application.
Defaults to 0.
setDebug(isDebug)
Sets whether to generate debug code in the final application.
setEmpty(isEmpty)
Sets whether to generate an empty table in the final application.
setOnline(isOnline)
Sets whether to generate update code in the final application.
setProfFromDir(dir)
Checks dir for reports matching the current target.
setProfFromFileNames(names)
Checks files with the given names for reports matching the current target.
setResetFunc(isResetFunc)
Sets whether to generate a reset function.
setTableSize(size)
Sets the table size in the final application.
Defaults to 65536.
setUpdateAlways(isUpdateAlways)
Sets whether to always update the table on a miss, even if not vacant.
setZeroSim(isZeroSim)
Sets whether to generate code for a 0% sim.