Skip to content
Snippets Groups Projects
Commit 6bf4d9d9 authored by Dean Jonas Finkes's avatar Dean Jonas Finkes
Browse files
parents ee0bef68 53f4efc9
No related branches found
No related tags found
No related merge requests found
Showing
with 51 additions and 37 deletions
...@@ -21,11 +21,6 @@ public class ForEachLoop { ...@@ -21,11 +21,6 @@ public class ForEachLoop {
list.add(5.0); list.add(5.0);
// do long computation
for (Double d : list) {
writeResultInDatabase(d);
}
} }
private static void writeResultInDatabase(final double result) { private static void writeResultInDatabase(final double result) {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
Theoretisch sind auch welche erlaubt, die nur lesende Zugriffe haben. Dann müssen die Assignments, zu denen Abhängigkeiten bestehen, noch als "final" markiert werden. Theoretisch sind auch welche erlaubt, die nur lesende Zugriffe haben. Dann müssen die Assignments, zu denen Abhängigkeiten bestehen, noch als "final" markiert werden.
Replace "AND (totalruntime>150 OR totalruntime = 0)" with ...totalruntime>{minExecutionTime}... to enable execution time filtering
--> -->
<pattern display="true"> <pattern display="true">
<name>Foreach-Loop Parallelisation</name> <name>Foreach-Loop Parallelisation</name>
...@@ -75,6 +77,7 @@ ...@@ -75,6 +77,7 @@
<pp java="1.7" name="Java 1.7 mzl"> <pp java="1.7" name="Java 1.7 mzl">
<!-- find last CF before the loop --> <!-- find last CF before the loop -->
<query><![CDATA[ <query><![CDATA[
//1: Mark place to insert thread pool
MATCH (loopInit) MATCH (loopInit)
WHERE id(loopInit)={loopInitID} WHERE id(loopInit)={loopInitID}
WITH loopInit WITH loopInit
...@@ -86,6 +89,7 @@ ...@@ -86,6 +89,7 @@
<query src="subpatterns/create_threadpool.xml"/> <query src="subpatterns/create_threadpool.xml"/>
<!-- mark init assignment--> <!-- mark init assignment-->
<query><![CDATA[ <query><![CDATA[
//3: Mark init Assignments
MATCH (loopInit) MATCH (loopInit)
WHERE id(loopInit)={loopInitID} WHERE id(loopInit)={loopInitID}
WITH loopInit WITH loopInit
...@@ -106,6 +110,7 @@ ...@@ -106,6 +110,7 @@
<query src="subpatterns/create_anonymous_class_constructor.xml"/> <query src="subpatterns/create_anonymous_class_constructor.xml"/>
<!-- find first cf after loop --> <!-- find first cf after loop -->
<query><![CDATA[ <query><![CDATA[
//5: Mark place to insert joinloop
MATCH (loopInit) MATCH (loopInit)
WHERE id(loopInit)={loopInitID} WHERE id(loopInit)={loopInitID}
WITH loopInit WITH loopInit
...@@ -121,6 +126,7 @@ ...@@ -121,6 +126,7 @@
<query src="subpatterns/create_forkjoinpool_joinloop.xml"/> <query src="subpatterns/create_forkjoinpool_joinloop.xml"/>
<!-- mark loop body nodes--> <!-- mark loop body nodes-->
<query><![CDATA[ <query><![CDATA[
//7: mark body begin and end
MATCH (loopInit) MATCH (loopInit)
WHERE id(loopInit)={loopInitID} WHERE id(loopInit)={loopInitID}
WITH loopInit WITH loopInit
...@@ -145,6 +151,7 @@ ...@@ -145,6 +151,7 @@
<!-- insert thread init nodes into loop body--> <!-- insert thread init nodes into loop body-->
<query src="subpatterns/create_thread_init.xml"/> <query src="subpatterns/create_thread_init.xml"/>
<query><![CDATA[ <query><![CDATA[
//10: return
MATCH (class) MATCH (class)
WHERE id(class) = {classID} WHERE id(class) = {classID}
return class as display return class as display
......
...@@ -9,6 +9,7 @@ in first node to get the replacements in other subqueries. ...@@ -9,6 +9,7 @@ in first node to get the replacements in other subqueries.
Requires the loop var assigment node with attribute "isLoopAssignment = true" Requires the loop var assigment node with attribute "isLoopAssignment = true"
--> -->
<query><![CDATA[ <query><![CDATA[
//4: create anonymous class
MATCH (initAssignment) MATCH (initAssignment)
WHERE initAssignment.isLoopAssignment = true WHERE initAssignment.isLoopAssignment = true
WITH initAssignment WITH initAssignment
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
//TODO: sdg2java has a problem with consecutive for loops, so we insert a print statemant between them. This has to be removed once the bug in sdg2java is fixed. //TODO: sdg2java has a problem with consecutive for loops, so we insert a print statemant between them. This has to be removed once the bug in sdg2java is fixed.
--> -->
<query><![CDATA[ <query><![CDATA[
//6: create join loop
MATCH (start)-[replacedCF]->(end) MATCH (start)-[replacedCF]->(end)
WHERE exists(replacedCF.replaceWithThreadPoolJoinLoop) WHERE exists(replacedCF.replaceWithThreadPoolJoinLoop)
AND replacedCF.replaceWithThreadPoolJoinLoop = true AND replacedCF.replaceWithThreadPoolJoinLoop = true
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
some node with the attribute tasklistvar some node with the attribute tasklistvar
--> -->
<query><![CDATA[ <query><![CDATA[
//9: insert thread initialisation
MATCH (start) MATCH (start)
WHERE start.insertThreadInit = "begin" WHERE start.insertThreadInit = "begin"
WITH start WITH start
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
CREATE (anonymousConstructorCall)-[:CONTROL_FLOW]->(forkJoinTaskRunnableAssignment) CREATE (anonymousConstructorCall)-[:CONTROL_FLOW]->(forkJoinTaskRunnableAssignment)
CREATE (taskAssignment:Assignment {operation:"value", var:"%{task}", displayname:"%{task} = %{taskTemp}", vartype:"java.util.concurrent.ForkJoinTask", isdeclaration:true, type:"Assignment", rightValue:"%{taskTemp}", lefttypearguments: ["?"]}) CREATE (taskAssignment:Assignment {operation:"value", var:"%{task}", displayname:"%{task} = %{taskTemp}", vartype:"java.util.concurrent.ForkJoinTask", isdeclaration:true, type:"Assignment", rightValue:"%{taskTemp}", lefttypearguments: ["?"]})
CREATE (forkJoinTaskRunnableAssignment)-[:CONTROL_FLOW]->(taskAssignment) CREATE (forkJoinTaskRunnableAssignment)-[:CONTROL_FLOW]->(taskAssignment)
CREATE (addTaskToFJPool:MethodCall {caller:tasklistVar, args:[%{task}], var:"addResultTemp", type:"MethodCall", returntype:"boolean", fqn:"java.util.List.add(java.lang.Object)", operation:"MethodCall", name:"add", vartype:"boolean", argumentscount:1, returntype:"boolean", displayname:"add(%{task})"}) CREATE (addTaskToFJPool:MethodCall {caller:tasklistVar, args:["%{task}"], var:"addResultTemp", type:"MethodCall", returntype:"boolean", fqn:"java.util.List.add(java.lang.Object)", operation:"MethodCall", name:"add", vartype:"boolean", argumentscount:1, returntype:"boolean", displayname:"add(%{task})"})
CREATE (taskAssignment)-[:CONTROL_FLOW]->(addTaskToFJPool) CREATE (taskAssignment)-[:CONTROL_FLOW]->(addTaskToFJPool)
CREATE (nop:NopStmt {type:"NopStmt", displayname:"nop"}) CREATE (nop:NopStmt {type:"NopStmt", displayname:"nop"})
CREATE (addTaskToFJPool)-[:CONTROL_FLOW]->(nop) CREATE (addTaskToFJPool)-[:CONTROL_FLOW]->(nop)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
some node with the attribute newanonymousclassname some node with the attribute newanonymousclassname
--> -->
<query><![CDATA[ <query><![CDATA[
//8: create run method for anonymous method
MATCH (a)-[del1:CONTROL_FLOW]->(start) MATCH (a)-[del1:CONTROL_FLOW]->(start)
WHERE start.moveToRun = "begin" WHERE start.moveToRun = "begin"
WITH start,del1 WITH start,del1
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
--> -->
<query> <query>
<![CDATA[ <![CDATA[
//2: create threadpool
MATCH (start)-[beforeLoopControlFlow]->(end) MATCH (start)-[beforeLoopControlFlow]->(end)
WHERE exists(beforeLoopControlFlow.replaceWithThreadPoolInit) WHERE exists(beforeLoopControlFlow.replaceWithThreadPoolInit)
AND beforeLoopControlFlow.replaceWithThreadPoolInit = true AND beforeLoopControlFlow.replaceWithThreadPoolInit = true
......
...@@ -43,16 +43,14 @@ ...@@ -43,16 +43,14 @@
DELETE cfReturn DELETE cfReturn
// Create Configuration nodes // Create Configuration nodes
MERGE (assignTemp:Assignment { MERGE (assignTemp:Assignment {operation: "new",
operation: "new", var: "%{temp$}" + id(function),
var: "%{temp$0}",
vartype: function.vartype, vartype: function.vartype,
type: "Assignment", type: "Assignment",
rightValue: function.rightValue, rightValue: function.rightValue,
displayname: "%{temp$0} = " + function.rightValue}) displayname: "%{temp$}"+ id(function) + " = " + function.rightValue})
-[:CONTROL_FLOW]-> -[:CONTROL_FLOW]->
(initNode:MethodCall:ConstructorCall { (initNode:MethodCall:ConstructorCall {caller: assignTemp.var,
caller: "%{temp$0}",
fqn: function.vartype + ".<init>()", fqn: function.vartype + ".<init>()",
name:"<init>", name:"<init>",
type:"MethodCall", type:"MethodCall",
...@@ -61,17 +59,16 @@ ...@@ -61,17 +59,16 @@
returntype: "void", returntype: "void",
displayname: "<init>()"}) displayname: "<init>()"})
-[:CONTROL_FLOW]-> -[:CONTROL_FLOW]->
(assignValue:Assignment { (assignValue:Assignment {operation: "value",
operation: "value", var: "%{stage$}" + id(function),
var: "%{stage$0}",
vartype: function.vartype, vartype: function.vartype,
isdeclaration: true, isdeclaration: true,
type: "Assignment", type: "Assignment",
rightValue: "%{temp$0}", rightValue: assignTemp.var,
displayname: "%{stage$0} = %{temp$0}"}) displayname: "%{stage$}"+ id(function) +" = " + assignTemp.var})
// Create InputPort // Create InputPort
MERGE (inputPort:Assignment:MethodCall { CREATE (inputPort:Assignment:MethodCall {
caller: assignValue.var, caller: assignValue.var,
fqn: "teetime.framework.AbstractConsumerStage.getInputPort()", fqn: "teetime.framework.AbstractConsumerStage.getInputPort()",
operation: "MethodCall", operation: "MethodCall",
...@@ -94,7 +91,7 @@ ...@@ -94,7 +91,7 @@
displayname: "%{temp$6} = (teetime.framework.InputPort) %{temp$5}" }) displayname: "%{temp$6} = (teetime.framework.InputPort) %{temp$5}" })
// Create OutputPort // Create OutputPort
MERGE (outputPort:Assignment:MethodCall { CREATE (outputPort:Assignment:MethodCall {
caller: assignValue.var, caller: assignValue.var,
fqn: functionClass.fqn + ".getOutputPort()", fqn: functionClass.fqn + ".getOutputPort()",
operation: "MethodCall", operation: "MethodCall",
...@@ -116,6 +113,9 @@ ...@@ -116,6 +113,9 @@
nopkind:"Pipe"}) nopkind:"Pipe"})
-[:CONTROL_FLOW]-> -[:CONTROL_FLOW]->
(successor) (successor)
MERGE (functionPipe)-[:IS_TRANSFORMED_THROUGH_START]->(nopCS)
MERGE (endPipe)-[:IS_TRANSFORMED_THROUGH_END]->(nopCS)
MERGE (nopCS)-[:HAS_CONFIGURATION]->(assignTemp) MERGE (nopCS)-[:HAS_CONFIGURATION]->(assignTemp)
MERGE (nopCS)-[:INPUTPORT_START]->(inputPort) MERGE (nopCS)-[:INPUTPORT_START]->(inputPort)
MERGE (nopCS)-[:INPUTPORT_END]->(inputPortCast) MERGE (nopCS)-[:INPUTPORT_END]->(inputPortCast)
...@@ -313,8 +313,10 @@ ...@@ -313,8 +313,10 @@
displayname: "return" } displayname: "return" }
// Delete pipe // Delete pipe
WITH functionPipe, endPipe WITH functionPipe, endPipe, nopCS, predecessor
MATCH pipe = (functionPipe)-[*]->(endPipe) MATCH pipe = (functionPipe)-[*]->(endPipe)
OPTIONAL MATCH (predecessor)-[:IS_TRANSFORMED_THROUGH_END]->(preNop)
MERGE (preNop)-[:CONTROL_FLOW]->(nopCS)
FOREACH (n IN nodes(pipe) | DETACH DELETE n) FOREACH (n IN nodes(pipe) | DETACH DELETE n)
]]> ]]>
</query> </query>
\ No newline at end of file
...@@ -44,13 +44,13 @@ ...@@ -44,13 +44,13 @@
// Create Configuration nodes // Create Configuration nodes
MERGE (assignTemp:Assignment {operation: "new", MERGE (assignTemp:Assignment {operation: "new",
var: "%{temp$0}", var: "%{temp$}" + id(function),
vartype: function.vartype, vartype: function.vartype,
type: "Assignment", type: "Assignment",
rightValue: function.rightValue, rightValue: function.rightValue,
displayname: "%{temp$0} = " + function.rightValue}) displayname: "%{temp$}"+ id(function) + " = " + function.rightValue})
-[:CONTROL_FLOW]-> -[:CONTROL_FLOW]->
(initNode:MethodCall:ConstructorCall {caller: "%{temp$0}", (initNode:MethodCall:ConstructorCall {caller: assignTemp.var,
fqn: function.vartype + ".<init>()", fqn: function.vartype + ".<init>()",
name:"<init>", name:"<init>",
type:"MethodCall", type:"MethodCall",
...@@ -60,22 +60,22 @@ ...@@ -60,22 +60,22 @@
displayname: "<init>()"}) displayname: "<init>()"})
-[:CONTROL_FLOW]-> -[:CONTROL_FLOW]->
(assignValue:Assignment {operation: "value", (assignValue:Assignment {operation: "value",
var: "%{stage$0}", var: "%{stage$}" + id(function),
vartype: function.vartype, vartype: function.vartype,
isdeclaration: true, isdeclaration: true,
type: "Assignment", type: "Assignment",
rightValue: "%{temp$0}", rightValue: assignTemp.var,
displayname: "%{stage$0} = %{temp$0}"}) displayname: "%{stage$}"+ id(function) +" = " + assignTemp.var})
// Create InputPort // Create InputPort
MERGE (inputPort:Assignment:MethodCall {caller: assignValue.var, CREATE (inputPort:Assignment:MethodCall {caller: assignValue.var,
fqn: "teetime.framework.AbstractConsumerStage.getInputPort()", fqn: "teetime.framework.AbstractConsumerStage.getInputPort()",
operation: "MethodCall", operation: "MethodCall",
var: "%{temp$5}", var: "%{temp$5}",
name: "getInputPort", name: "getInputPort",
vartype: "teetime.framework.InputPort", vartype: "teetime.framework.InputPort",
type: "Assignment", type: "Assignment",
rightValue: "virtualinvoke %{stage$0}.<" + functionClass.fqn + ": teetime.framework.InputPort getInputPort()>()", rightValue: "virtualinvoke "+ assignValue.var + ".<" + functionClass.fqn + ": teetime.framework.InputPort getInputPort()>()",
args: [], args: [],
argumentscount: "0", argumentscount: "0",
displayname: "%{temp$5} = getInputPort()", displayname: "%{temp$5} = getInputPort()",
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
displayname: "%{temp$6} = (teetime.framework.InputPort) %{temp$5}" }) displayname: "%{temp$6} = (teetime.framework.InputPort) %{temp$5}" })
// Create OutputPort // Create OutputPort
MERGE (outputPort:Assignment:MethodCall {caller: assignValue.var, CREATE (outputPort:Assignment:MethodCall {caller: assignValue.var,
fqn: functionClass.fqn + ".getOutputPort()", fqn: functionClass.fqn + ".getOutputPort()",
operation: "MethodCall", operation: "MethodCall",
var: "%{temp$7}", var: "%{temp$7}",
...@@ -110,6 +110,9 @@ ...@@ -110,6 +110,9 @@
nopkind:"Pipe"}) nopkind:"Pipe"})
-[:CONTROL_FLOW]-> -[:CONTROL_FLOW]->
(successor) (successor)
MERGE (functionPipe)-[:IS_TRANSFORMED_THROUGH_START]->(nopCS)
MERGE (endPipe)-[:IS_TRANSFORMED_THROUGH_END]->(nopCS)
MERGE (nopCS)-[:HAS_CONFIGURATION]->(assignTemp) MERGE (nopCS)-[:HAS_CONFIGURATION]->(assignTemp)
MERGE (nopCS)-[:INPUTPORT_START]->(inputPort) MERGE (nopCS)-[:INPUTPORT_START]->(inputPort)
MERGE (nopCS)-[:INPUTPORT_END]->(inputPortCast) MERGE (nopCS)-[:INPUTPORT_END]->(inputPortCast)
...@@ -267,8 +270,10 @@ ...@@ -267,8 +270,10 @@
displayname: "return" } displayname: "return" }
// Delete pipe // Delete pipe
WITH functionPipe, endPipe WITH functionPipe, endPipe, nopCS, predecessor
MATCH pipe = (functionPipe)-[*]->(endPipe) MATCH pipe = (functionPipe)-[*]->(endPipe)
OPTIONAL MATCH (predecessor)-[:IS_TRANSFORMED_THROUGH_END]->(preNop)
MERGE (preNop)-[:CONTROL_FLOW]->(nopCS)
FOREACH (n IN nodes(pipe) | DETACH DELETE n) FOREACH (n IN nodes(pipe) | DETACH DELETE n)
]]> ]]>
</query> </query>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment