From bb84b5da3be57a2ea89b9e00ec65351494fa6e4b Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 15 Jul 2010 23:15:20 +0000 Subject: [PATCH] make it easier to read --- .../Benchmarks/oooJava/labyrinth/Router.java | 107 ++++++++---------- 1 file changed, 45 insertions(+), 62 deletions(-) diff --git a/Robust/src/Benchmarks/oooJava/labyrinth/Router.java b/Robust/src/Benchmarks/oooJava/labyrinth/Router.java index 80d71cea..5629922e 100644 --- a/Robust/src/Benchmarks/oooJava/labyrinth/Router.java +++ b/Robust/src/Benchmarks/oooJava/labyrinth/Router.java @@ -326,69 +326,52 @@ public class Router { * ============================================================== * =============== void router_solve (void* argPtr); */ - public void solve(Object argPtr) - { - - Solve_Arg routerArgPtr = (Solve_Arg) argPtr; - Router routerPtr = routerArgPtr.routerPtr; - Maze mazePtr = routerArgPtr.mazePtr; - int workload = routerArgPtr.rblock_workload; - List_t pathVectorListPtr = routerArgPtr.pathVectorListPtr; - - Queue_t masterWorkQueuePtr = mazePtr.workQueuePtr; - Grid masterGridPtr = mazePtr.gridPtr; - int bendCost = routerPtr.bendCost; - - int id = 0; - - while(!masterWorkQueuePtr.queue_isEmpty() ) -// System.out.println("HAHAHA"); -// while(!isEmpty(masterWorkQueuePtr) ) - { - Queue_t redoQueue = masterWorkQueuePtr.Pqueue_alloc(masterWorkQueuePtr.capacity); - while(!masterWorkQueuePtr.queue_isEmpty()) -// while(!isEmpty(masterWorkQueuePtr) ) - { - //moved to outside rBlock due to potential r/w conflicts - Queue_t localWorkQueue = masterWorkQueuePtr.queue_getUpTo(workload); - System.out.println("Got work!"); - - sese P - { - //Clone needed since new paths are added to local Grid. Cannot add to master Grid because of rBlock p conflicts - Grid MGClone = masterGridPtr.alloc(masterGridPtr.width, masterGridPtr.height, masterGridPtr.depth); - masterGridPtr.copy(MGClone, masterGridPtr); - - Vector_t computedPaths = solveLogic(localWorkQueue, MGClone, routerPtr, bendCost, workload); - } + public void solve(Object argPtr) { + Solve_Arg routerArgPtr = (Solve_Arg) argPtr; + Router routerPtr = routerArgPtr.routerPtr; + Maze mazePtr = routerArgPtr.mazePtr; + int workload = routerArgPtr.rblock_workload; + List_t pathVectorListPtr = routerArgPtr.pathVectorListPtr; + + Queue_t masterWorkQueuePtr = mazePtr.workQueuePtr; + Grid masterGridPtr = mazePtr.gridPtr; + int bendCost = routerPtr.bendCost; + + int id = 0; + + while(!masterWorkQueuePtr.queue_isEmpty() ) { + Queue_t redoQueue = masterWorkQueuePtr.Pqueue_alloc(masterWorkQueuePtr.capacity); + while(!masterWorkQueuePtr.queue_isEmpty()) { + Queue_t localWorkQueue = masterWorkQueuePtr.queue_getUpTo(workload); + + sese P { + //Clone needed since new paths are added to local Grid. Cannot add to master Grid because of rBlock p conflicts + Grid MGClone = masterGridPtr.alloc(masterGridPtr.width, masterGridPtr.height, masterGridPtr.depth); + masterGridPtr.copy(MGClone, masterGridPtr); + + Vector_t computedPaths = solveLogic(localWorkQueue, MGClone, routerPtr, bendCost, workload); + } - sese S - { - Vector_t sucessfulPaths = computedPaths.vector_alloc(workload); - - CoordPathWrapper singlePathSolution = (CoordPathWrapper) computedPaths.vector_popBack(); - while(singlePathSolution != null) { - if(masterGridPtr.TM_addPath(singlePathSolution.pathVector)) - //fail - redoQueue.queue_push(singlePathSolution.coordinatePair); - else //success - { - sucessfulPaths.vector_pushBack(singlePathSolution.pathVector); - System.out.println("Path # " + ++id + " added sucessfully!"); - } - - singlePathSolution = (CoordPathWrapper)computedPaths.vector_popBack(); - } - - pathVectorListPtr.insert(sucessfulPaths); - }//end of sese S - - }//end of inner while - - masterWorkQueuePtr = redoQueue; - - }//end of outer while - } + sese S { + Vector_t sucessfulPaths = computedPaths.vector_alloc(workload); + CoordPathWrapper singlePathSolution = (CoordPathWrapper) computedPaths.vector_popBack(); + while(singlePathSolution != null) { + if(masterGridPtr.TM_addPath(singlePathSolution.pathVector)) { + //fail + redoQueue.queue_push(singlePathSolution.coordinatePair); + } else { + //success + sucessfulPaths.vector_pushBack(singlePathSolution.pathVector); + System.out.println("Path # " + ++id + " added sucessfully!"); + } + singlePathSolution = (CoordPathWrapper)computedPaths.vector_popBack(); + } + pathVectorListPtr.insert(sucessfulPaths); + }//end of sese S + }//end of inner while + masterWorkQueuePtr = redoQueue; + }//end of outer while + } private Vector_t solveLogic(Queue_t localWorkQueue, Grid MGCopyPtr, Router routerPtr, int bendCost, int workload) { /* -- 2.34.1