use of org.apache.sysml.runtime.instructions.gpu.GPUInstruction in project incubator-systemml by apache.
the class ProgramConverter method cloneInstruction.
public static Instruction cloneInstruction(Instruction oInst, long pid, boolean plain, boolean cpFunctions) {
Instruction inst = null;
String tmpString = oInst.toString();
try {
if (oInst instanceof CPInstruction || oInst instanceof SPInstruction || oInst instanceof MRInstruction || oInst instanceof GPUInstruction) {
if (oInst instanceof FunctionCallCPInstruction && cpFunctions) {
FunctionCallCPInstruction tmp = (FunctionCallCPInstruction) oInst;
if (!plain) {
// safe replacement because target variables might include the function name
// note: this is no update-in-place in order to keep the original function name as basis
tmpString = tmp.updateInstStringFunctionName(tmp.getFunctionName(), tmp.getFunctionName() + CP_CHILD_THREAD + pid);
}
// otherwise: preserve function name
}
inst = InstructionParser.parseSingleInstruction(tmpString);
} else if (oInst instanceof MRJobInstruction) {
// clone via copy constructor
inst = new MRJobInstruction((MRJobInstruction) oInst);
} else
throw new DMLRuntimeException("Failed to clone instruction: " + oInst);
} catch (Exception ex) {
throw new DMLRuntimeException(ex);
}
// save replacement of thread id references in instructions
inst = saveReplaceThreadID(inst, ProgramConverter.CP_ROOT_THREAD_ID, ProgramConverter.CP_CHILD_THREAD + pid);
return inst;
}
use of org.apache.sysml.runtime.instructions.gpu.GPUInstruction in project systemml by apache.
the class ProgramConverter method cloneInstruction.
public static Instruction cloneInstruction(Instruction oInst, long pid, boolean plain, boolean cpFunctions) {
Instruction inst = null;
String tmpString = oInst.toString();
try {
if (oInst instanceof CPInstruction || oInst instanceof SPInstruction || oInst instanceof MRInstruction || oInst instanceof GPUInstruction) {
if (oInst instanceof FunctionCallCPInstruction && cpFunctions) {
FunctionCallCPInstruction tmp = (FunctionCallCPInstruction) oInst;
if (!plain) {
// safe replacement because target variables might include the function name
// note: this is no update-in-place in order to keep the original function name as basis
tmpString = tmp.updateInstStringFunctionName(tmp.getFunctionName(), tmp.getFunctionName() + CP_CHILD_THREAD + pid);
}
// otherwise: preserve function name
}
inst = InstructionParser.parseSingleInstruction(tmpString);
} else if (oInst instanceof MRJobInstruction) {
// clone via copy constructor
inst = new MRJobInstruction((MRJobInstruction) oInst);
} else
throw new DMLRuntimeException("Failed to clone instruction: " + oInst);
} catch (Exception ex) {
throw new DMLRuntimeException(ex);
}
// save replacement of thread id references in instructions
inst = saveReplaceThreadID(inst, ProgramConverter.CP_ROOT_THREAD_ID, ProgramConverter.CP_CHILD_THREAD + pid);
return inst;
}
use of org.apache.sysml.runtime.instructions.gpu.GPUInstruction in project incubator-systemml by apache.
the class GPUInstructionParser method parseSingleInstruction.
public static GPUInstruction parseSingleInstruction(String str) {
if (str == null || str.isEmpty())
return null;
GPUINSTRUCTION_TYPE cptype = InstructionUtils.getGPUType(str);
if (cptype == null)
throw new DMLRuntimeException("Unable derive cptype for instruction: " + str);
GPUInstruction cpinst = parseSingleInstruction(cptype, str);
if (cpinst == null)
throw new DMLRuntimeException("Unable to parse instruction: " + str);
return cpinst;
}
use of org.apache.sysml.runtime.instructions.gpu.GPUInstruction in project systemml by apache.
the class GPUInstructionParser method parseSingleInstruction.
public static GPUInstruction parseSingleInstruction(String str) {
if (str == null || str.isEmpty())
return null;
GPUINSTRUCTION_TYPE cptype = InstructionUtils.getGPUType(str);
if (cptype == null)
throw new DMLRuntimeException("Unable derive cptype for instruction: " + str);
GPUInstruction cpinst = parseSingleInstruction(cptype, str);
if (cpinst == null)
throw new DMLRuntimeException("Unable to parse instruction: " + str);
return cpinst;
}
Aggregations