Compare commits

..

3 Commits

Author SHA1 Message Date
pl@gohorb.ba-horb.de
61653c5d88 modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java 2023-05-25 10:05:10 +02:00
pl@gohorb.ba-horb.de
3cd608a4ac modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java
modified:   src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
2023-05-15 16:56:04 +02:00
pl@gohorb.ba-horb.de
deec0ae706 Start branch unif23NoOptParallel
modified:   Makefile
	modified:   src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java
	modified:   src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
2023-04-24 17:18:45 +02:00
4 changed files with 38 additions and 49 deletions

View File

@@ -1,16 +1,3 @@
full:
mvn -DskipTests package
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_full.jar
NoMinMax:
mvn -DskipTests package
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoMinMax.jar
NoOpt:
mvn -DskipTests package
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoOpt.jar
NoOptParallel: NoOptParallel:
mvn -DskipTests package mvn -DskipTests package
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoOptParallel.jar cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoOptParallel.jar

View File

@@ -70,7 +70,7 @@ public class JavaTXCompiler {
//public static JavaTXCompiler INSTANCE; //public static JavaTXCompiler INSTANCE;
final CompilationEnvironment environment; final CompilationEnvironment environment;
Boolean resultmodel = false; Boolean resultmodel = true;
public final Map<File, SourceFile> sourceFiles = new HashMap<>(); public final Map<File, SourceFile> sourceFiles = new HashMap<>();
Boolean log = false; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll? Boolean log = false; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel(); public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();

View File

@@ -82,6 +82,8 @@ public class TypeUnify {
try { try {
logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n"); logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n");
logFile.flush(); logFile.flush();
unifyTask.statistics.write("Backtracking: " + unifyTask.noBacktracking);
unifyTask.statistics.write("\nLoops: " + unifyTask.noLoop);
} }
catch (IOException e) { catch (IOException e) {
System.err.println("no log-File"); System.err.println("no log-File");

View File

@@ -82,7 +82,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
private static int totalnoOfThread = 0; private static int totalnoOfThread = 0;
int thNo; int thNo;
protected boolean one = false; protected boolean one = false;
Integer MaxNoOfThreads = 8; Integer MaxNoOfThreads = 128;
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/"; public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
Writer logFile; Writer logFile;
@@ -258,7 +258,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
protected Set<Set<UnifyPair>> compute() { protected Set<Set<UnifyPair>> compute() {
if (one) { if (one) {
System.out.println("two"); //System.out.println("two");
} }
one = true; one = true;
Set<UnifyPair> neweq = new HashSet<>(eq); Set<UnifyPair> neweq = new HashSet<>(eq);
@@ -659,7 +659,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//a <. theta, theta <. a oder a =. theta enthalten //a <. theta, theta <. a oder a =. theta enthalten
//statistics //statistics
writeStatistics("\nNumber of Constraints (" + rekTiefe + "): " + topLevelSets.size()); //writeStatistics("\nNumber of Constraints (" + rekTiefe + "): " + topLevelSets.size());
Set<Set<UnifyPair>> oneElems = new HashSet<>(); Set<Set<UnifyPair>> oneElems = new HashSet<>();
oneElems.addAll(topLevelSets.stream() oneElems.addAll(topLevelSets.stream()
@@ -679,7 +679,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//writeLog("nextSet: " + nextSet.toString()); //writeLog("nextSet: " + nextSet.toString());
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet); List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
writeStatistics(" Start Number of elements ( " /* + nextSetasList.get(0).stream().findFirst().get().getBasePair()*/ +"): (" + rekTiefe + "): " + nextSetasList.size()); //writeStatistics(" Start Number of elements ( " /* + nextSetasList.get(0).stream().findFirst().get().getBasePair()*/ +"): (" + rekTiefe + "): " + nextSetasList.size());
/* /*
try { try {
@@ -797,7 +797,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
while (nextSetasList.size() > 0) { while (nextSetasList.size() > 0) {
//statistics //statistics
writeStatistics(" Actual Number of elements( " + nextSetasList.get(0).stream().findFirst().get().getBasePair() +"): (" + rekTiefe + "): " + nextSetasList.size()); //writeStatistics(" Actual Number of elements( " + nextSetasList.get(0).stream().findFirst().get().getBasePair() +"): (" + rekTiefe + "): " + nextSetasList.size());
Set<UnifyPair> a_last = a; Set<UnifyPair> a_last = a;
/* Liste der Faelle für die parallele Verarbeitung /* Liste der Faelle für die parallele Verarbeitung
@@ -817,7 +817,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("nextSet: " + nextSet.toString()); writeLog("nextSet: " + nextSet.toString());
writeLog("nextSetasList: " + nextSetasList.toString()); writeLog("nextSetasList: " + nextSetasList.toString());
///* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang /* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang
if (variance == 1) { if (variance == 1) {
a = oup.max(nextSetasList.iterator()); a = oup.max(nextSetasList.iterator());
nextSetasList.remove(a); nextSetasList.remove(a);
@@ -889,10 +889,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
} }
} }
//Nextvar an Hand Varianzbestimmung auskommentieren Ende */ Nextvar an Hand Varianzbestimmung auskommentieren Ende */
//a = nextSetasList.remove(0); //statisticsList a = nextSetasList.remove(0); //statisticsList
writeStatistics(a.toString()); //writeStatistics(a.toString());
if (oderConstraint) {//Methodconstraints werden abgespeichert für die Bytecodegenerierung von Methodenaufrufen if (oderConstraint) {//Methodconstraints werden abgespeichert für die Bytecodegenerierung von Methodenaufrufen
methodSignatureConstraint.addAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint()); methodSignatureConstraint.addAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint());
//System.out.println("ERSTELLUNG: " +methodSignatureConstraint); //System.out.println("ERSTELLUNG: " +methodSignatureConstraint);
@@ -947,9 +947,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("a in " + variance + " "+ a); writeLog("a in " + variance + " "+ a);
writeLog("nextSetasListRest: " + nextSetasListRest.toString()); writeLog("nextSetasListRest: " + nextSetasListRest.toString());
} }
while (!nextSetasListRest.isEmpty()) { while (!nextSetasList.isEmpty()) {
Set<UnifyPair> nSaL = nextSetasListRest.remove(0); Set<UnifyPair> nSaL = nextSetasList.remove(0);
synchronized (this) { nextSetasList.remove(nSaL); synchronized (this) { //nextSetasList.remove(nSaL);
writeLog("1 RM" + nSaL.toString()); writeLog("1 RM" + nSaL.toString());
} }
@@ -1049,9 +1049,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("a in " + variance + " "+ a); writeLog("a in " + variance + " "+ a);
writeLog("nextSetasListRest: " + nextSetasListRest.toString()); writeLog("nextSetasListRest: " + nextSetasListRest.toString());
} }
while (!nextSetasListRest.isEmpty()) { while (!nextSetasList.isEmpty()) {
Set<UnifyPair> nSaL = nextSetasListRest.remove(0); Set<UnifyPair> nSaL = nextSetasList.remove(0);
synchronized (this) { nextSetasList.remove(nSaL); synchronized (this) { //nextSetasList.remove(nSaL);
writeLog("-1 RM" + nSaL.toString()); writeLog("-1 RM" + nSaL.toString());
} }
@@ -1151,9 +1151,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("a in " + variance + " "+ a); writeLog("a in " + variance + " "+ a);
writeLog("nextSetasListRest: " + nextSetasListRest.toString()); writeLog("nextSetasListRest: " + nextSetasListRest.toString());
} }
while (!nextSetasListRest.isEmpty()) { while (!nextSetasList.isEmpty()) {
Set<UnifyPair> nSaL = nextSetasListRest.remove(0); Set<UnifyPair> nSaL = nextSetasList.remove(0);
nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03 //nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03
Set<UnifyPair> newEq = new HashSet<>(eq); Set<UnifyPair> newEq = new HashSet<>(eq);
Set<Set<UnifyPair>> newElems = new HashSet<>(elems); Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints); List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
@@ -1213,9 +1213,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}}} }}}
//Ab hier alle parallele Berechnungen wieder zusammengeführt. //Ab hier alle parallele Berechnungen wieder zusammengeführt.
if (hilf == 1) //if (hilf == 1)
System.out.println(); //System.out.println();
writeStatistics("Zusammengeführt(" + rekTiefe + "): " + nextSetasList.size()); //writeStatistics("Zusammengeführt(" + rekTiefe + "): " + nextSetasList.size());
if (oderConstraint) {//Wenn weiteres Element nextSetasList genommen wird, muss die vorherige methodsignatur geloescht werden if (oderConstraint) {//Wenn weiteres Element nextSetasList genommen wird, muss die vorherige methodsignatur geloescht werden
methodSignatureConstraint.removeAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint()); methodSignatureConstraint.removeAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint());
//System.out.println("REMOVE: " +methodSignatureConstraint); //System.out.println("REMOVE: " +methodSignatureConstraint);
@@ -1327,7 +1327,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
result = par_res; result = par_res;
if (!par_res.isEmpty() && par_res.iterator().next() instanceof WildcardType) { if (!par_res.isEmpty() && par_res.iterator().next() instanceof WildcardType) {
System.out.println(""); //System.out.println("");
} }
} }
else { else {
@@ -1343,7 +1343,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//break; //break;
} }
// /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG
if (!result.isEmpty() && (!isUndefinedPairSetSet(res) || !aParDef.isEmpty())) { if (!result.isEmpty() && (!isUndefinedPairSetSet(res) || !aParDef.isEmpty())) {
if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1) if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1)
System.out.print(""); System.out.print("");
@@ -1480,7 +1480,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
} }
} }
//auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */ auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
if (isUndefinedPairSetSet(res) && aParDef.isEmpty()) { if (isUndefinedPairSetSet(res) && aParDef.isEmpty()) {
int nofstred= 0; int nofstred= 0;
@@ -1513,9 +1513,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
return new Pair<>(su, x.getGroundBasePair());}) return new Pair<>(su, x.getGroundBasePair());})
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));
if (res.size() > 1) { if (res.size() > 1) {
System.out.println(); //System.out.println();
} }
// /* statistics no erase /* statistics no erase
writeLog("nextSetasList vor filter-Aufruf: " + nextSetasList); writeLog("nextSetasList vor filter-Aufruf: " + nextSetasList);
if (!oderConstraint) {//PL 2023-02-08 eingefuegt: Bei oderconstraints sind Subststitutionen nicht als Substitutionen in idesem Sinne zu sehen if (!oderConstraint) {//PL 2023-02-08 eingefuegt: Bei oderconstraints sind Subststitutionen nicht als Substitutionen in idesem Sinne zu sehen
nextSetasList = nextSetasList.stream().filter(x -> { nextSetasList = nextSetasList.stream().filter(x -> {
@@ -1528,7 +1528,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
} }
writeLog("nextSetasList nach filter-Aufruf: " + nextSetasList); writeLog("nextSetasList nach filter-Aufruf: " + nextSetasList);
// */ */
nofstred = nextSetasList.size(); nofstred = nextSetasList.size();
//NOCH NICHT korrekt PL 2018-10-12 //NOCH NICHT korrekt PL 2018-10-12
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) //nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
@@ -1546,11 +1546,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString()); writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString());
noBacktracking++; noBacktracking++;
writeLog("Number of Backtracking: " + noBacktracking); writeLog("Number of Backtracking: " + noBacktracking);
writeStatistics("Number of erased elements: " + (len - nextSetasList.size())); //writeStatistics("Number of erased elements: " + (len - nextSetasList.size()));
writeStatistics("Number of Backtracking: " + noBacktracking); //writeStatistics("Number of Backtracking: " + noBacktracking);
System.out.println(""); //System.out.println("");
} }
else writeStatistics("res: " + res.toString()); else //writeStatistics("res: " + res.toString());
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) { //if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
// return result; // return result;
//} //}
@@ -1559,9 +1559,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//} //}
//else result.stream().filter(y -> !isUndefinedPairSet(y)); //else result.stream().filter(y -> !isUndefinedPairSet(y));
writeLog("res: " + res.toString()); writeLog("res: " + res.toString());
writeStatistics(" End Number of Elements (" + rekTiefe + "): " + nextSetasList.size()); //writeStatistics(" End Number of Elements (" + rekTiefe + "): " + nextSetasList.size());
noLoop++; noLoop++;
writeStatistics("Number of Loops: " + noLoop); //writeStatistics("Number of Loops: " + noLoop);
} }
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen //2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
writeLog("Return computeCR: " + result.toString()); writeLog("Return computeCR: " + result.toString());
@@ -2057,7 +2057,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//System.out.println(pair); //System.out.println(pair);
if (first) { //writeLog(pair.toString()+"\n"); if (first) { //writeLog(pair.toString()+"\n");
if (((PlaceholderType)(pair.getLhsType())).getName().equals("AR")) { if (((PlaceholderType)(pair.getLhsType())).getName().equals("AR")) {
System.out.println("AR"); //System.out.println("AR");
} }
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc); Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
if (pairOp == PairOperator.SMALLERNEQDOT) { if (pairOp == PairOperator.SMALLERNEQDOT) {
@@ -2630,7 +2630,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
if (finalresult) { if (finalresult) {
synchronized ( this ) { synchronized ( this ) {
try { try {
statistics.write(str + "\n"); statistics.write("Thread No. " + thNo + ": " + str + "\n");
statistics.flush(); statistics.flush();
} }