You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2017/11/02 07:38:15 UTC
[2/3] systemml git commit: [SYSTEMML-1982] Improved IPA pass for
recompile_once functions
[SYSTEMML-1982] Improved IPA pass for recompile_once functions
This patch improved the existing inter-procedural-analysis pass for
recompile_once functions that are recompiled on function entry. So far
all functions with loops were marked for recompile_once. The problem is
that recompilation information is not available during IPA. Hence, we
correct these flags now after generating the runtime program and making
the decisions on recompilation.
Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/ee6060bf
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/ee6060bf
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/ee6060bf
Branch: refs/heads/master
Commit: ee6060bfc1576cf777dfa99c48126a5a7b35db3a
Parents: a2f0598
Author: Matthias Boehm <mb...@gmail.com>
Authored: Wed Nov 1 22:51:46 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Thu Nov 2 00:39:17 2017 -0700
----------------------------------------------------------------------
.../org/apache/sysml/parser/DMLTranslator.java | 57 +++++++++-----------
.../apache/sysml/parser/ForStatementBlock.java | 15 ++----
.../apache/sysml/parser/IfStatementBlock.java | 12 ++---
.../org/apache/sysml/parser/StatementBlock.java | 7 +--
.../sysml/parser/WhileStatementBlock.java | 12 ++---
5 files changed, 45 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/systemml/blob/ee6060bf/src/main/java/org/apache/sysml/parser/DMLTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/DMLTranslator.java b/src/main/java/org/apache/sysml/parser/DMLTranslator.java
index 75103d1..fb8404f 100644
--- a/src/main/java/org/apache/sysml/parser/DMLTranslator.java
+++ b/src/main/java/org/apache/sysml/parser/DMLTranslator.java
@@ -317,25 +317,21 @@ public class DMLTranslator
}
public void constructLops(DMLProgram dmlp) throws ParseException, LanguageException, HopsException, LopsException {
-
// for each namespace, handle function program blocks handle function
- for (String namespaceKey : dmlp.getNamespaces().keySet()){
- for (String fname: dmlp.getFunctionStatementBlocks(namespaceKey).keySet()) {
- FunctionStatementBlock current = dmlp.getFunctionStatementBlock(namespaceKey, fname);
- constructLops(current);
- }
- }
+ for( String namespaceKey : dmlp.getNamespaces().keySet() )
+ for( FunctionStatementBlock fsb : dmlp.getFunctionStatementBlocks(namespaceKey).values() )
+ constructLops(fsb);
// handle regular program blocks
- for (int i = 0; i < dmlp.getNumStatementBlocks(); i++) {
- StatementBlock current = dmlp.getStatementBlock(i);
- constructLops(current);
- }
+ for( StatementBlock sb : dmlp.getStatementBlocks() )
+ constructLops(sb);
}
- public void constructLops(StatementBlock sb)
+ public boolean constructLops(StatementBlock sb)
throws HopsException, LopsException
- {
+ {
+ boolean ret = false;
+
if (sb instanceof WhileStatementBlock)
{
WhileStatementBlock wsb = (WhileStatementBlock)sb;
@@ -348,13 +344,13 @@ public class DMLTranslator
}
// step through stmt blocks in while stmt body
for (StatementBlock stmtBlock : body){
- constructLops(stmtBlock);
+ ret |= constructLops(stmtBlock);
}
// handle while stmt predicate
Lop l = wsb.getPredicateHops().constructLops();
wsb.set_predicateLops(l);
- wsb.updatePredicateRecompilationFlag();
+ ret |= wsb.updatePredicateRecompilationFlag();
}
else if (sb instanceof IfStatementBlock)
@@ -370,16 +366,16 @@ public class DMLTranslator
}
// step through stmt blocks in if stmt ifBody
for (StatementBlock stmtBlock : ifBody)
- constructLops(stmtBlock);
+ ret |= constructLops(stmtBlock);
// step through stmt blocks in if stmt elseBody
for (StatementBlock stmtBlock : elseBody)
- constructLops(stmtBlock);
+ ret |= constructLops(stmtBlock);
// handle if stmt predicate
Lop l = isb.getPredicateHops().constructLops();
isb.set_predicateLops(l);
- isb.updatePredicateRecompilationFlag();
+ ret |= isb.updatePredicateRecompilationFlag();
}
else if (sb instanceof ForStatementBlock) //NOTE: applies to ForStatementBlock and ParForStatementBlock
@@ -394,7 +390,7 @@ public class DMLTranslator
}
// step through stmt blocks in FOR stmt body
for (StatementBlock stmtBlock : body)
- constructLops(stmtBlock);
+ ret |= constructLops(stmtBlock);
// handle for stmt predicate
if (fsb.getFromHops() != null){
@@ -409,37 +405,36 @@ public class DMLTranslator
Lop llobs = fsb.getIncrementHops().constructLops();
fsb.setIncrementLops(llobs);
}
- fsb.updatePredicateRecompilationFlags();
+ ret |= fsb.updatePredicateRecompilationFlags();
}
- else if (sb instanceof FunctionStatementBlock){
+ else if (sb instanceof FunctionStatementBlock) {
+ FunctionStatementBlock fsb = (FunctionStatementBlock) sb;
FunctionStatement functStmt = (FunctionStatement)sb.getStatement(0);
ArrayList<StatementBlock> body = functStmt.getBody();
-
if (sb.get_hops() != null && !sb.get_hops().isEmpty()) {
LOG.error(sb.printBlockErrorLocation() + "FunctionStatementBlock should not have hops");
throw new HopsException(sb.printBlockErrorLocation() + "FunctionStatementBlock should not have hops");
}
// step through stmt blocks in while stmt body
- for (StatementBlock stmtBlock : body){
- constructLops(stmtBlock);
- }
+ for( StatementBlock stmtBlock : body )
+ ret |= constructLops(stmtBlock);
+ if( fsb.isRecompileOnce() )
+ fsb.setRecompileOnce(ret);
}
// handle default case for regular StatementBlock
else {
-
if (sb.get_hops() == null)
sb.set_hops(new ArrayList<Hop>());
-
ArrayList<Lop> lops = new ArrayList<>();
- for (Hop hop : sb.get_hops()) {
+ for (Hop hop : sb.get_hops())
lops.add(hop.constructLops());
- }
sb.setLops(lops);
- sb.updateRecompilationFlag();
+ ret |= sb.updateRecompilationFlag();
}
- } // end method
+ return ret;
+ }
public Program getRuntimeProgram(DMLProgram prog, DMLConfig config)
http://git-wip-us.apache.org/repos/asf/systemml/blob/ee6060bf/src/main/java/org/apache/sysml/parser/ForStatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/ForStatementBlock.java b/src/main/java/org/apache/sysml/parser/ForStatementBlock.java
index 856e151..686ce7a 100644
--- a/src/main/java/org/apache/sysml/parser/ForStatementBlock.java
+++ b/src/main/java/org/apache/sysml/parser/ForStatementBlock.java
@@ -410,29 +410,24 @@ public class ForStatementBlock extends StatementBlock
// materialized hops recompilation flags
////
- public void updatePredicateRecompilationFlags()
- throws HopsException
- {
+ public boolean updatePredicateRecompilationFlags() throws HopsException {
if( ConfigurationManager.isDynamicRecompilation() ) {
_requiresFromRecompile = Recompiler.requiresRecompilation(getFromHops());
_requiresToRecompile = Recompiler.requiresRecompilation(getToHops());
_requiresIncrementRecompile = Recompiler.requiresRecompilation(getIncrementHops());
}
+ return (_requiresFromRecompile || _requiresToRecompile || _requiresIncrementRecompile);
}
- public boolean requiresFromRecompilation()
- {
+ public boolean requiresFromRecompilation() {
return _requiresFromRecompile;
}
- public boolean requiresToRecompilation()
- {
+ public boolean requiresToRecompilation() {
return _requiresToRecompile;
}
- public boolean requiresIncrementRecompilation()
- {
+ public boolean requiresIncrementRecompilation() {
return _requiresIncrementRecompile;
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/systemml/blob/ee6060bf/src/main/java/org/apache/sysml/parser/IfStatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/IfStatementBlock.java b/src/main/java/org/apache/sysml/parser/IfStatementBlock.java
index 2a66857..6803eb2 100644
--- a/src/main/java/org/apache/sysml/parser/IfStatementBlock.java
+++ b/src/main/java/org/apache/sysml/parser/IfStatementBlock.java
@@ -524,15 +524,13 @@ public class IfStatementBlock extends StatementBlock
// materialized hops recompilation flags
////
- public void updatePredicateRecompilationFlag()
- throws HopsException
- {
- _requiresPredicateRecompile = ConfigurationManager.isDynamicRecompilation()
- && Recompiler.requiresRecompilation(getPredicateHops());
+ public boolean updatePredicateRecompilationFlag() throws HopsException {
+ return (_requiresPredicateRecompile =
+ ConfigurationManager.isDynamicRecompilation()
+ && Recompiler.requiresRecompilation(getPredicateHops()));
}
- public boolean requiresPredicateRecompilation()
- {
+ public boolean requiresPredicateRecompilation() {
return _requiresPredicateRecompile;
}
}
http://git-wip-us.apache.org/repos/asf/systemml/blob/ee6060bf/src/main/java/org/apache/sysml/parser/StatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/StatementBlock.java b/src/main/java/org/apache/sysml/parser/StatementBlock.java
index 4a24675..c2a3e01 100644
--- a/src/main/java/org/apache/sysml/parser/StatementBlock.java
+++ b/src/main/java/org/apache/sysml/parser/StatementBlock.java
@@ -1044,9 +1044,10 @@ public class StatementBlock extends LiveVariableAnalysis implements ParseInfo
// materialized hops recompilation / updateinplace flags
////
- public void updateRecompilationFlag() throws HopsException {
- _requiresRecompile = ConfigurationManager.isDynamicRecompilation()
- && Recompiler.requiresRecompilation(get_hops());
+ public boolean updateRecompilationFlag() throws HopsException {
+ return (_requiresRecompile =
+ ConfigurationManager.isDynamicRecompilation()
+ && Recompiler.requiresRecompilation(get_hops()));
}
public boolean requiresRecompilation() {
http://git-wip-us.apache.org/repos/asf/systemml/blob/ee6060bf/src/main/java/org/apache/sysml/parser/WhileStatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/WhileStatementBlock.java b/src/main/java/org/apache/sysml/parser/WhileStatementBlock.java
index f3f613e..05e2c2c 100644
--- a/src/main/java/org/apache/sysml/parser/WhileStatementBlock.java
+++ b/src/main/java/org/apache/sysml/parser/WhileStatementBlock.java
@@ -324,15 +324,13 @@ public class WhileStatementBlock extends StatementBlock
// materialized hops recompilation flags
////
- public void updatePredicateRecompilationFlag()
- throws HopsException
- {
- _requiresPredicateRecompile = ConfigurationManager.isDynamicRecompilation()
- && Recompiler.requiresRecompilation(getPredicateHops());
+ public boolean updatePredicateRecompilationFlag() throws HopsException {
+ return (_requiresPredicateRecompile =
+ ConfigurationManager.isDynamicRecompilation()
+ && Recompiler.requiresRecompilation(getPredicateHops()));
}
- public boolean requiresPredicateRecompilation()
- {
+ public boolean requiresPredicateRecompilation() {
return _requiresPredicateRecompile;
}
}
\ No newline at end of file