1 / 16

A Concurrent Matrix Transpose Algorithm, The Verification

A Concurrent Matrix Transpose Algorithm, The Verification. Presented by Pourya Jafari. Algorithm Review: Determine preprocessing. Intra-process shift = row index After Intra-process; every column index is equal to original row index j” = j + i’ = i

yoko
Download Presentation

A Concurrent Matrix Transpose Algorithm, The Verification

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Concurrent Matrix Transpose Algorithm, The Verification Presented by Pourya Jafari

  2. Algorithm Review: Determine preprocessing • Intra-process shift = row index • After Intra-process; every column index is equal to original row index • j” = j + i’ = i • i’: Row index after pre-processing i’ = i - L • i - L + j = i • Now we can determine preprocess shift-up L = - j

  3. Algorithm Review: Determine Post Processing • Change of indices so far • (i - j, j) → (i - j, i - j + j) → (i - j, i) = (m, n) • One operation to change row index to j • n - m = (i - (i - j))= j

  4. Pre-process inside each thread Shift rows Intra-process/thread communication Shift columns Post-process inside each thread Shift rows again Algorithm Review: : All Steps

  5. UML Diagram

  6. CProcess: Heart of Concurrency • Might send/receive multiple items • Determines the indices that need to be shifted • Packs them in form of a message • Sends the message to the next CProcess and receive from the previous process in the shift chain • Unpack the received message • Assign the items inside to the same indices determined in the first step

  7. Running Launcher under JPF CProcess 1: done! MProcess : done! Launcher : all threads done! ========================== error #1 gov.nasa.jpf.jvm.NotDeadlockedProperty deadlock encountered: thread index=0,name=main,status=TERMINATED,this=null,target=null,priority=5,lockC ount=0 thread index=1,name=CProcess@ab6b,status=WAITING,this=org.jcsp.lang.ParThread@518 ,priority=5,lockCount=1 thread index=2,name=CProcess@aa76,status=WAITING,this=org.jcsp.lang.ParThread@550 ,priority=5,lockCount=1 ========================= trace #1 navy 310 % jpf -c ./jpf.properties Launcher | more JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center ============================= system under test application: /cs/home/pourya/6490/Launcher.java ============== search started: 11/27/07 1:24 PM Launcher : start threads CProcess 0: starts CProcess 1: starts MProcess : initate intraprocess stage CProcess 0: finished step 0 CProcess 0: 0 0 CProcess 0: 1 1000000 CProcess 0: done! CProcess 1: finished step 0 CProcess 1: 0 1 CProcess 1: 1 1000001

  8. Simple JCSP test import org.jcsp.lang.*; Public class test { public static void main(String[] args) { new Parallel { new CSProcess[] { new TCSP(), new TCSP() } ).run(); System.out.print("Test done!\n"); } } import org.jcsp.lang.*; public class TCSP implements CSProcess { public TCSP(){ } //@Override public void run() { System.out.printf("TCSP done!\n"); } }

  9. Simple JCSP test under JPF navy 313 % jpf -c ./jpf.properties test | more JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center ====================================================== system under test application: /cs/home/pourya/6490/test.java ====================================================== search started: 11/27/07 1:43 PM TCSP done! TCSP done! Test done! ====================================================== error #1 gov.nasa.jpf.jvm.NotDeadlockedProperty deadlock encountered: thread index=0,name=main,status=TERMINATED,this=null,target=null,priority=5,lockC ount=0 thread index=1,name=TCSP@ab6c,status=WAITING,this=org.jcsp.lang.ParThread@177,pri ority=5,lockCount=1====================================================== trace #1

  10. Deadlock cause • Threads are still alive at least under JPF environment • We should force thread termination the end of run • Two solutions • System.exit(0) in the end of MProcess • Use release mechanism in Parallel under JCSP: releaseAllThreads();

  11. Modification to test and Results import org.jcsp.lang.*; class test { public static void main(String[] args) { Parallel P = new Parallel ( new CSProcess[] { new TCSP(), new TCSP() } ); P.run(); System.out.print("Test done!\n"); P.releaseAllThreads(); } } navy 317 % jpf -c ./jpf.properties test JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center ===================== system under test application: /cs/home/pourya/6490/test.java ======== search started: 11/27/07 1:06 PM TCSP done! TCSP done! Test done! Test done! . . . TCSP done! Test done! ================================== results no errors detected =================inished: 11/27/07 1:06 PM

  12. Verifying Launcher • No deadlocks after the releaseThread fix • Precision Racing Test • No racing warning or errors • Underlying mechanisms in JCSP use synchronized blocks • Functional verification?

  13. Functional verification • Each thread initially generate values using following line of code • After transpose the first and last digit will be swapped for(int i=0; i<N; i++) column[i] = PID*1000000 + i;

  14. We use a for-loop which sets a Boolean value and, then a assertion to verify results Boolean correctSoFar = true; for(i=0; i<N && correctSoFar; i++) { if (column[i] != i*1000000 + PID) correctSoFar = false; } assert (correctSoFar) : "CProcess value incorrect”);

  15. Final Results navy 310 % jpf -c ./jpf.properties Launcher | more JavaPathfinder v4.1 - (C) 1999-2007 RIACS/NASA Ames Research Center ============================= system under test application: /cs/home/pourya/6490/Launcher.java ============== search started: 11/27/07 1:35 PM Launcher : start threads CProcess 0: starts CProcess 1: starts MProcess : initate intraprocess stage CProcess 0: finished step 0 CProcess 0: 0 0 CProcess 1: starts CProcess 1: starts CProcess 1: starts CProcess 0: starts CProcess 0: starts CProcess 1: done! MProcess : done! Launcher : all threads done! . . CProcess 1: starts CProcess 1: starts CProcess 1: starts CProcess 1: starts CProcess 0: starts CProcess 0: starts CProcess 0: starts CProcess 0: starts CProcess 0: starts ============================================ results no errors detected ================== search finished: 11/27/07 1:37 PM

  16. Future work • We could break the cycle on a first-come first-served basis • Locking mechanism needed • Racing might rise with a faulty lock • Racing verification required

More Related