use of org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction in project systemml by apache.
the class Statistics method getCPHeavyHitterCode.
public static String getCPHeavyHitterCode(Instruction inst) {
String opcode = null;
if (inst instanceof MRJobInstruction) {
MRJobInstruction mrinst = (MRJobInstruction) inst;
opcode = "MR-Job_" + mrinst.getJobType();
} else if (inst instanceof SPInstruction) {
opcode = "SP_" + InstructionUtils.getOpCode(inst.toString());
if (inst instanceof FunctionCallCPInstruction) {
FunctionCallCPInstruction extfunct = (FunctionCallCPInstruction) inst;
opcode = extfunct.getFunctionName();
}
} else // CPInstructions
{
opcode = InstructionUtils.getOpCode(inst.toString());
if (inst instanceof FunctionCallCPInstruction) {
FunctionCallCPInstruction extfunct = (FunctionCallCPInstruction) inst;
opcode = extfunct.getFunctionName();
}
}
return opcode;
}
use of org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction in project systemml by apache.
the class ProgramConverter method rFindSerializationCandidates.
private static void rFindSerializationCandidates(ArrayList<ProgramBlock> pbs, HashSet<String> cand) {
for (ProgramBlock pb : pbs) {
if (pb instanceof WhileProgramBlock) {
WhileProgramBlock wpb = (WhileProgramBlock) pb;
rFindSerializationCandidates(wpb.getChildBlocks(), cand);
} else if (pb instanceof ForProgramBlock || pb instanceof ParForProgramBlock) {
ForProgramBlock fpb = (ForProgramBlock) pb;
rFindSerializationCandidates(fpb.getChildBlocks(), cand);
} else if (pb instanceof IfProgramBlock) {
IfProgramBlock ipb = (IfProgramBlock) pb;
rFindSerializationCandidates(ipb.getChildBlocksIfBody(), cand);
if (ipb.getChildBlocksElseBody() != null)
rFindSerializationCandidates(ipb.getChildBlocksElseBody(), cand);
} else // all generic program blocks
{
for (Instruction inst : pb.getInstructions()) if (inst instanceof FunctionCallCPInstruction) {
FunctionCallCPInstruction fci = (FunctionCallCPInstruction) inst;
String fkey = DMLProgram.constructFunctionKey(fci.getNamespace(), fci.getFunctionName());
if (// memoization for multiple calls, recursion
!cand.contains(fkey)) {
// add to candidates
cand.add(fkey);
// investigate chains of function calls
FunctionProgramBlock fpb = pb.getProgram().getFunctionProgramBlock(fci.getNamespace(), fci.getFunctionName());
rFindSerializationCandidates(fpb.getChildBlocks(), cand);
}
}
}
}
}
use of org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction in project systemml by apache.
the class ProgramConverter method createDeepCopyInstructionSet.
/**
* Creates a deep copy of an array of instructions and replaces the placeholders of parworker
* IDs with the concrete IDs of this parfor instance. This is a helper method uses for generating
* deep copies of program blocks.
*
* @param instSet list of instructions
* @param pid ?
* @param IDPrefix ?
* @param prog runtime program
* @param fnStack ?
* @param fnCreated ?
* @param plain ?
* @param cpFunctions ?
* @return list of instructions
*/
public static ArrayList<Instruction> createDeepCopyInstructionSet(ArrayList<Instruction> instSet, long pid, int IDPrefix, Program prog, HashSet<String> fnStack, HashSet<String> fnCreated, boolean plain, boolean cpFunctions) {
ArrayList<Instruction> tmp = new ArrayList<>();
for (Instruction inst : instSet) {
if (inst instanceof FunctionCallCPInstruction && cpFunctions) {
FunctionCallCPInstruction finst = (FunctionCallCPInstruction) inst;
createDeepCopyFunctionProgramBlock(finst.getNamespace(), finst.getFunctionName(), pid, IDPrefix, prog, fnStack, fnCreated, plain);
}
tmp.add(cloneInstruction(inst, pid, plain, cpFunctions));
}
return tmp;
}
use of org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction in project systemml by apache.
the class CostEstimator method maintainCPInstVariableStatistics.
private static void maintainCPInstVariableStatistics(CPInstruction inst, HashMap<String, VarStats> stats) {
if (inst instanceof VariableCPInstruction) {
String optype = inst.getOpcode();
String[] parts = InstructionUtils.getInstructionParts(inst.toString());
if (optype.equals("createvar")) {
if (parts.length < 10)
return;
String varname = parts[1];
long rlen = Long.parseLong(parts[6]);
long clen = Long.parseLong(parts[7]);
int brlen = Integer.parseInt(parts[8]);
int bclen = Integer.parseInt(parts[9]);
long nnz = Long.parseLong(parts[10]);
VarStats vs = new VarStats(rlen, clen, brlen, bclen, nnz, false);
stats.put(varname, vs);
} else if (optype.equals("cpvar")) {
String varname = parts[1];
String varname2 = parts[2];
VarStats vs = stats.get(varname);
stats.put(varname2, vs);
} else if (optype.equals("mvvar")) {
String varname = parts[1];
String varname2 = parts[2];
VarStats vs = stats.remove(varname);
stats.put(varname2, vs);
} else if (optype.equals("rmvar")) {
String varname = parts[1];
stats.remove(varname);
}
} else if (inst instanceof DataGenCPInstruction) {
DataGenCPInstruction randInst = (DataGenCPInstruction) inst;
String varname = randInst.output.getName();
long rlen = randInst.getRows();
long clen = randInst.getCols();
int brlen = randInst.getRowsInBlock();
int bclen = randInst.getColsInBlock();
long nnz = (long) (randInst.getSparsity() * rlen * clen);
VarStats vs = new VarStats(rlen, clen, brlen, bclen, nnz, true);
stats.put(varname, vs);
} else if (inst instanceof StringInitCPInstruction) {
StringInitCPInstruction iinst = (StringInitCPInstruction) inst;
String varname = iinst.output.getName();
long rlen = iinst.getRows();
long clen = iinst.getCols();
VarStats vs = new VarStats(rlen, clen, ConfigurationManager.getBlocksize(), ConfigurationManager.getBlocksize(), rlen * clen, true);
stats.put(varname, vs);
} else if (inst instanceof FunctionCallCPInstruction) {
FunctionCallCPInstruction finst = (FunctionCallCPInstruction) inst;
ArrayList<String> outVars = finst.getBoundOutputParamNames();
for (String varname : outVars) stats.put(varname, _unknownStats);
}
}
Aggregations