From: <jik...@li...> - 2011-07-12 06:41:49
|
details: http://jikesrvm.hg.sourceforge.net/hgweb/jikesrvm/soc2011/rev/84029a70dce4 changeset: 10423:84029a70dce4 user: Michael Taylor <mic...@gm...> date: Tue Jul 12 02:41:34 2011 -0400 description: Parallel typePropagation V1 1.2x fop Bench diffstat: rvm/src/org/jikesrvm/compilers/opt/Simple.java | 102 +++++++++++++++++++++++++- 1 files changed, 100 insertions(+), 2 deletions(-) diffs (119 lines): diff -r ab1c9ed8e2dd -r 84029a70dce4 rvm/src/org/jikesrvm/compilers/opt/Simple.java --- a/rvm/src/org/jikesrvm/compilers/opt/Simple.java Sun Jul 10 19:25:41 2011 -0400 +++ b/rvm/src/org/jikesrvm/compilers/opt/Simple.java Tue Jul 12 02:41:34 2011 -0400 @@ -164,8 +164,17 @@ copyPropagation(ir); // Simple type propagation. // This pass uses the register list, but doesn't modify it. - if (typeProp) { - typePropagation(ir); + registerSize = ir.numberRegisters(); + if (typeProp) { + if (parallel) { + if (registerSize > 6000) { + paralleltypePropagation(ir); + } else { + typePropagation(ir); + } + } else { + typePropagation(ir); + } } // Perform simple bounds-check and arraylength elimination. // This pass incrementally updates the register list @@ -477,6 +486,95 @@ } } +public static Runnable paralleltypePropagationrunPass(final int threadId, final IR ir, final int numThreads) { + return new Runnable() { + + public void run() { + + int nRegisters = ir.numberRegisters(); //Total number Registers in current Method + /*Calculate starting position in each Thread + *starts with floating point then casts back down to Integer*/ + int i = (int)(((double)nRegisters/numThreads)*((double)threadId)); + /*Calculate starting position in each Thread + *starts with floating point then casts back down to Integer*/ + int end = (int)(((double)nRegisters/numThreads)*((double)threadId + 1)); + + // Use register list to enumerate register objects (FAST) + Register elemNext; + for (Register reg = ir.regpool.getNthSymbolicRegister(i); i < end; reg = elemNext, i++) { + elemNext = reg.getNext(); + + // Type propagation not possible if reg has no uses + if (reg.useList == null) { + continue; + } + // Type propagation not possible if reg has no defs + if (reg.defList == null) { + continue; + } + // Do not attempt type propagation if reg has multiple defs + if (!reg.isSSA()) { + continue; + } + // Now reg has exactly one definition + RegisterOperand lhs = reg.defList; + Instruction instr = lhs.instruction; + Operator op = instr.operator(); + // Type propagation not possible if lhs is not in a move instr + if (!op.isMove()) { + continue; + } + Operand rhsOp = Move.getVal(instr); + // Do not attempt type propagation if RHS is not a register + if (!(rhsOp instanceof RegisterOperand)) { + continue; + } + RegisterOperand rhs = (RegisterOperand) rhsOp; + // Propagate the type in the def + lhs.copyType(rhs); + + // Now propagate lhs into all uses; substitute rhs.type for lhs.type + for (RegisterOperand use = reg.useList; use != null; use = use.getNext()) { + // if rhs.type is a supertype of use.type, don't do it + // because use.type has more detailed information + if (ClassLoaderProxy.includesType(rhs.getType(), use.getType()) == YES) { + continue; + } + // If Magic has been employed to convert an int to a reference, + // don't undo the effects! + if (rhs.getType().isPrimitiveType() && !use.getType().isPrimitiveType()) { + continue; + } + use.copyType(rhs); + } + }//end for + } + }; + } + + /** + * Parallel Perform flow-insensitive type propagation using register list + * information. Note: register list MUST be initialized BEFORE + * calling this routine. + * + * <p> Kept separate from copyPropagation loop to enable clients + * more flexibility. + * + * @param ir the IR in question + */ + private static void paralleltypePropagation(IR ir) { + int numThreads = 2; + OptCompilerThread thread = new OptCompilerThread(numThreads); + for (int i = 0; i < numThreads; i++) { + try { + thread.execute(paralleltypePropagationrunPass(i, ir, numThreads)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + thread.shutdown(); + } + /** * Perform flow-insensitive propagation to eliminate bounds checks * and arraylength for arrays with static lengths. Only useful on the HIR |