From 1db10b968d62a4e29a35933d1b7539fbff56b9ec Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 23 Jun 2009 03:26:41 +0000 Subject: [PATCH] small changes to support porting the parallel code in Bayes make QuickSort more generic in common library --- .../src/Benchmarks/SingleTM/Bayes/Bayes.java | 18 +++++++++++------- .../SingleTM/Bayes/FindBestTaskArg.java | 2 +- Robust/src/Benchmarks/SingleTM/Bayes/Net.java | 8 ++++---- Robust/src/Benchmarks/SingleTM/Bayes/makefile | 2 +- .../Benchmarks/SingleTM/common/QuickSort.java | 9 +++------ 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/Bayes/Bayes.java b/Robust/src/Benchmarks/SingleTM/Bayes/Bayes.java index 5e0a8a3c..5ded7c53 100644 --- a/Robust/src/Benchmarks/SingleTM/Bayes/Bayes.java +++ b/Robust/src/Benchmarks/SingleTM/Bayes/Bayes.java @@ -231,10 +231,10 @@ public class Bayes extends Thread { Learner.createTaskList(myId, numThread, learnerPtr); Barrier.enterBarrier(); - //Barrier.enterBarrier(); - //Learner.learnStructure(myId, numThread, learnerPtr); + Barrier.enterBarrier(); + Learner.learnStructure(myId, numThread, learnerPtr); //Learner.learner_run(myId, numThread, learnerPtr); - //Barrier.enterBarrier(); + Barrier.enterBarrier(); } @@ -297,7 +297,7 @@ public class Bayes extends Thread { adtreePtr.adtree_make(dataPtr); - System.out.println("done."); + System.out.println("done.\n\n"); /* * Score original network @@ -326,13 +326,17 @@ public class Bayes extends Thread { } + /** + * Parallel work by all threads + **/ + Barrier.enterBarrier(); Learner.createTaskList(0, numThread, learnerPtr); Barrier.enterBarrier(); - //Barrier.enterBarrier(); - //Learner.learnStructure(0, numThread, learnerPtr); - //Barrier.enterBarrier(); + Barrier.enterBarrier(); + Learner.learnStructure(0, numThread, learnerPtr); + Barrier.enterBarrier(); /* Barrier.enterBarrier(); diff --git a/Robust/src/Benchmarks/SingleTM/Bayes/FindBestTaskArg.java b/Robust/src/Benchmarks/SingleTM/Bayes/FindBestTaskArg.java index 0f3efb0c..0af53cf7 100644 --- a/Robust/src/Benchmarks/SingleTM/Bayes/FindBestTaskArg.java +++ b/Robust/src/Benchmarks/SingleTM/Bayes/FindBestTaskArg.java @@ -9,7 +9,7 @@ public class FindBestTaskArg { int toId; Learner learnerPtr; - Query queries; + Query[] queries; Vector_t queryVectorPtr; Vector_t parentQueryVectorPtr; int numTotalParent; diff --git a/Robust/src/Benchmarks/SingleTM/Bayes/Net.java b/Robust/src/Benchmarks/SingleTM/Bayes/Net.java index d526a321..aadf64d7 100644 --- a/Robust/src/Benchmarks/SingleTM/Bayes/Net.java +++ b/Robust/src/Benchmarks/SingleTM/Bayes/Net.java @@ -279,13 +279,13 @@ public class Net { * ============================================================================= */ public void - net_applyOperation (Operation op, int fromId, int toId) + net_applyOperation (int op, int fromId, int toId) { - if(op.insert == OPERATION_INSERT) { + if(op == OPERATION_INSERT) { insertEdge(fromId, toId); - } else if(op.remove == OPERATION_REMOVE) { + } else if(op == OPERATION_REMOVE) { removeEdge(fromId, toId); - } else if(op.reverse == OPERATION_REVERSE) { + } else if(op == OPERATION_REVERSE) { reverseEdge(fromId, toId); } else { System.out.println("Operation failed"); diff --git a/Robust/src/Benchmarks/SingleTM/Bayes/makefile b/Robust/src/Benchmarks/SingleTM/Bayes/makefile index 0b1c238e..f1588b0f 100644 --- a/Robust/src/Benchmarks/SingleTM/Bayes/makefile +++ b/Robust/src/Benchmarks/SingleTM/Bayes/makefile @@ -20,7 +20,7 @@ SRC=tmp${MAINCLASS}.java \ ../common/Vector_t.java \ ListNode.java \ tmpList.java \ - ../common/QuickSort.java \ + QuickSort.java \ IntVector.java \ ../../../ClassLibrary/JavaSTM/Barrier.java \ ../common/LocalStartStop.java diff --git a/Robust/src/Benchmarks/SingleTM/common/QuickSort.java b/Robust/src/Benchmarks/SingleTM/common/QuickSort.java index 51f20a70..7b8e1c8c 100644 --- a/Robust/src/Benchmarks/SingleTM/common/QuickSort.java +++ b/Robust/src/Benchmarks/SingleTM/common/QuickSort.java @@ -139,17 +139,14 @@ public class QuickSort { * =========================================== */ public boolean less(Object x, Object y) { - Query aQueryPtr = (Query) x; - Query bQueryPtr = (Query) y; - if(aQueryPtr.index < bQueryPtr.index) + if(x < y) //TODO cast it to the correct type of Object return true; return false; } public int diff(Object x, Object y) { - Query aQueryPtr = (Query) x; - Query bQueryPtr = (Query) y; - return (aQueryPtr.index - bQueryPtr.index); + //TODO cast it to the correct type of Object + return(x - y); } /** -- 2.34.1