From 9d37e8f63716c3404e1a9fe79914d917d6ea1aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Wed, 25 Jul 2018 20:15:29 +0200 Subject: [PATCH] modified: ../../src/de/dhbwstuttgart/core/JavaTXCompiler.java modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Parallelverarbeitungansatz implementiert Wirft noch ConcurrentModificationException Das Ergebnis der Parallelverarbeit fork.join muss in Ziel 530 muss noch geklaert werden --- src/de/dhbwstuttgart/core/JavaTXCompiler.java | 4 +-- .../typeinference/unify/TypeUnify2Task.java | 7 +++-- .../typeinference/unify/TypeUnifyTask.java | 26 ++++++++++++++----- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index 89e39b1d..fd6af924 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -175,8 +175,8 @@ public class JavaTXCompiler { return y; } ) .collect(Collectors.toCollection(HashSet::new)); varianceInheritance(xConsSet); - Set> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log); - //Set> result = unify.unify(xConsSet, finiteClosure, logFile, log); + //Set> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log); + Set> result = unify.unify(xConsSet, finiteClosure, logFile, log); System.out.println("RESULT: " + result); logFile.write("RES: " + result.toString()+"\n"); logFile.flush(); diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index 13f89ab0..873ad423 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -19,7 +19,10 @@ public class TypeUnify2Task extends TypeUnifyTask { @Override protected Set> compute() { Set> res = unify2(setToFlatten, eq, fc, parallel); - if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } - else return res; + /*if (isUndefinedPairSetSet(res)) { + return new HashSet<>(); } + else + */ + return res; } } diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 494540b2..a7f90a17 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -321,6 +321,7 @@ public class TypeUnifyTask extends RecursiveTask>> { /* * Step 6 a) Restart (fork) for pairs where subst was applied */ + /* if(parallel) { if (eqPrime.equals(eq) && !eqPrimePrime.isPresent()) //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch //PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent()) @@ -340,7 +341,8 @@ public class TypeUnifyTask extends RecursiveTask>> { fork.fork(); } } - else { // sequentiell (Step 6b is included) + else */ + { // sequentiell (Step 6b is included) if (printtag) System.out.println("nextStep: " + eqPrimePrime); if (eqPrime.equals(eq) && !eqPrimePrime.isPresent()) { //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch //PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent()) @@ -356,12 +358,12 @@ public class TypeUnifyTask extends RecursiveTask>> { eqPrimePrimeSet.add(eqPrime); } else if(eqPrimePrime.isPresent()) { - Set> unifyres = unify(eqPrimePrime.get(), fc, false); + Set> unifyres = unify(eqPrimePrime.get(), fc, parallel); eqPrimePrimeSet.addAll(unifyres); } else { - Set> unifyres = unify(eqPrime, fc, false); + Set> unifyres = unify(eqPrime, fc, parallel); eqPrimePrimeSet.addAll(unifyres); @@ -374,10 +376,11 @@ public class TypeUnifyTask extends RecursiveTask>> { /* * Step 6 b) Build the union over everything. */ - + /* if(parallel) for(TypeUnifyTask fork : forks) eqPrimePrimeSet.addAll(fork.join()); + */ /* * Step 7: Filter empty sets; @@ -508,18 +511,29 @@ public class TypeUnifyTask extends RecursiveTask>> { //if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt //writeLog("Vor unify2 Aufruf: " + eq.toString()); Set> res = new HashSet<>(); - if(parallel) { + if(parallel && (variance == 1)) { + /* + elems.add(a); + TypeUnify2Task fork = new TypeUnify2Task(elems, eq, fc, parallel, logFile, log); + fork.fork(); + res = fork.join(); + */ + Set forks = new HashSet<>(); for(Set nSaL : nextSetasListRest) { - TypeUnify2Task fork = new TypeUnify2Task(elems, eq, fc, true, logFile, log); + elems.add(nSaL); + TypeUnify2Task fork = new TypeUnify2Task(elems, eq, fc, parallel, logFile, log); forks.add(fork); fork.fork(); } for(TypeUnifyTask fork : forks) { res.addAll(fork.join()); + System.out.println(""); } + } else { + elems.add(a); res = unify2(elems, eq, fc, parallel); } if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {