Search in sources :

Example 1 with GPUInstruction

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;
}
Also used : SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) SpoofCPInstruction(org.apache.sysml.runtime.instructions.cp.SpoofCPInstruction) VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) GPUInstruction(org.apache.sysml.runtime.instructions.gpu.GPUInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) MRInstruction(org.apache.sysml.runtime.instructions.mr.MRInstruction) GPUInstruction(org.apache.sysml.runtime.instructions.gpu.GPUInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) ExternalFunctionInvocationInstruction(org.apache.sysml.udf.ExternalFunctionInvocationInstruction) SpoofCPInstruction(org.apache.sysml.runtime.instructions.cp.SpoofCPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction) SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) MRInstruction(org.apache.sysml.runtime.instructions.mr.MRInstruction) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 2 with GPUInstruction

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;
}
Also used : SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) SpoofCPInstruction(org.apache.sysml.runtime.instructions.cp.SpoofCPInstruction) VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) GPUInstruction(org.apache.sysml.runtime.instructions.gpu.GPUInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) MRInstruction(org.apache.sysml.runtime.instructions.mr.MRInstruction) GPUInstruction(org.apache.sysml.runtime.instructions.gpu.GPUInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) ExternalFunctionInvocationInstruction(org.apache.sysml.udf.ExternalFunctionInvocationInstruction) SpoofCPInstruction(org.apache.sysml.runtime.instructions.cp.SpoofCPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction) SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) MRInstruction(org.apache.sysml.runtime.instructions.mr.MRInstruction) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 3 with GPUInstruction

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;
}
Also used : ReorgGPUInstruction(org.apache.sysml.runtime.instructions.gpu.ReorgGPUInstruction) RelationalBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.RelationalBinaryGPUInstruction) GPUInstruction(org.apache.sysml.runtime.instructions.gpu.GPUInstruction) ArithmeticBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.ArithmeticBinaryGPUInstruction) BuiltinBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.BuiltinBinaryGPUInstruction) BuiltinUnaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.BuiltinUnaryGPUInstruction) ConvolutionGPUInstruction(org.apache.sysml.runtime.instructions.gpu.ConvolutionGPUInstruction) MatrixMatrixAxpyGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MatrixMatrixAxpyGPUInstruction) MMTSJGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MMTSJGPUInstruction) AggregateUnaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.AggregateUnaryGPUInstruction) MatrixIndexingGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MatrixIndexingGPUInstruction) MatrixAppendGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MatrixAppendGPUInstruction) AggregateBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.AggregateBinaryGPUInstruction) GPUINSTRUCTION_TYPE(org.apache.sysml.runtime.instructions.gpu.GPUInstruction.GPUINSTRUCTION_TYPE) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 4 with GPUInstruction

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;
}
Also used : ReorgGPUInstruction(org.apache.sysml.runtime.instructions.gpu.ReorgGPUInstruction) RelationalBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.RelationalBinaryGPUInstruction) GPUInstruction(org.apache.sysml.runtime.instructions.gpu.GPUInstruction) ArithmeticBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.ArithmeticBinaryGPUInstruction) BuiltinBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.BuiltinBinaryGPUInstruction) BuiltinUnaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.BuiltinUnaryGPUInstruction) ConvolutionGPUInstruction(org.apache.sysml.runtime.instructions.gpu.ConvolutionGPUInstruction) MatrixMatrixAxpyGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MatrixMatrixAxpyGPUInstruction) MMTSJGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MMTSJGPUInstruction) AggregateUnaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.AggregateUnaryGPUInstruction) MatrixIndexingGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MatrixIndexingGPUInstruction) MatrixAppendGPUInstruction(org.apache.sysml.runtime.instructions.gpu.MatrixAppendGPUInstruction) AggregateBinaryGPUInstruction(org.apache.sysml.runtime.instructions.gpu.AggregateBinaryGPUInstruction) GPUINSTRUCTION_TYPE(org.apache.sysml.runtime.instructions.gpu.GPUInstruction.GPUINSTRUCTION_TYPE) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)4 GPUInstruction (org.apache.sysml.runtime.instructions.gpu.GPUInstruction)4 Instruction (org.apache.sysml.runtime.instructions.Instruction)2 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)2 CPInstruction (org.apache.sysml.runtime.instructions.cp.CPInstruction)2 FunctionCallCPInstruction (org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction)2 SpoofCPInstruction (org.apache.sysml.runtime.instructions.cp.SpoofCPInstruction)2 VariableCPInstruction (org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)2 AggregateBinaryGPUInstruction (org.apache.sysml.runtime.instructions.gpu.AggregateBinaryGPUInstruction)2 AggregateUnaryGPUInstruction (org.apache.sysml.runtime.instructions.gpu.AggregateUnaryGPUInstruction)2 ArithmeticBinaryGPUInstruction (org.apache.sysml.runtime.instructions.gpu.ArithmeticBinaryGPUInstruction)2 BuiltinBinaryGPUInstruction (org.apache.sysml.runtime.instructions.gpu.BuiltinBinaryGPUInstruction)2 BuiltinUnaryGPUInstruction (org.apache.sysml.runtime.instructions.gpu.BuiltinUnaryGPUInstruction)2 ConvolutionGPUInstruction (org.apache.sysml.runtime.instructions.gpu.ConvolutionGPUInstruction)2 GPUINSTRUCTION_TYPE (org.apache.sysml.runtime.instructions.gpu.GPUInstruction.GPUINSTRUCTION_TYPE)2 MMTSJGPUInstruction (org.apache.sysml.runtime.instructions.gpu.MMTSJGPUInstruction)2 MatrixAppendGPUInstruction (org.apache.sysml.runtime.instructions.gpu.MatrixAppendGPUInstruction)2 MatrixIndexingGPUInstruction (org.apache.sysml.runtime.instructions.gpu.MatrixIndexingGPUInstruction)2 MatrixMatrixAxpyGPUInstruction (org.apache.sysml.runtime.instructions.gpu.MatrixMatrixAxpyGPUInstruction)2 RelationalBinaryGPUInstruction (org.apache.sysml.runtime.instructions.gpu.RelationalBinaryGPUInstruction)2