亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? reduction.java

?? this code is a parallel programming code . such code is esay but is very useful to understand how to
?? JAVA
字號:
/*   Where there are no comments below, insert them   Such comments should explain the purpose of important   aspects of the code, and document classes, methods etc.   They should communicate useful information, not merely   state the obvious  (e.g." i:=i+1 // add 1 to i" will lose   marks).*/public class Reduction{  CubbyHole [] storage;             // data parallel "machine" "pvar"  int inArrayLength;                // length of intput array  public BarrierSynch waiting;      // object for barrier synchronisation.  NodeThread nthread;               // temp var for starting threads  ApplyObj applic;                  // the function passed in as a parameter  int number_of_iters;              // total number of iterations  int i,j;  /* ==========================================================     Main Method.. initialize; start up threads for DP step     ==========================================================  */  public Object Reduce(ApplyObj applic,Object[] inArray){    inArrayLength = inArray.length;  // get the length from input array    this.applic = applic;    storage = new CubbyHole[inArrayLength];    initializeStorage(inArray);// put value    number_of_iters = (int) Math.ceil(Math.log(                                 (double)inArrayLength)/				      Math.log(2.0));// how many times the iterations . for example , 6 element shuold hace 3 iteration    // sample tracing code -- outputs "storage"    for (j=0; j< inArrayLength; j++) {      System.out.println( "^^ " + storage[j].get());      };// display the value /*   DATA PARALLEL STEPS -- make sure code for a step is complete*/      // this does only one DP step -- edit the loop control appropriately      for (i=1; i <= number_of_iters; i++){        waiting = new BarrierSynch(inArrayLength+1 ); // create barrier        System.out.println("************************"+"STEP " + i);   // display for each step		// trace: which DP step?          for (j=0; j< inArrayLength; j++) {                System.out.println( "reduction result " + storage[j].get());                }// display the differernt vaule of the array for each step      System.out.println("************************"+"STEP " + i);        startThreads();                    // start DP step        waiting.iveArrived(999);          // Reduce enters barrier    };  // end for/*  QUESTION 1:   Reduce, and all the threads, participate in the barrier.   The program may behave incorrectly if only the threads use the   barrier. Explain why.   Write your answer here:ANSWER:In this code, Reduce is a supervisor thread and the startThread () creates the threads.In the first step, this method creates the old threads. These threads compute  andupdate the data. After that the supervisor (Reduce) should make sure that all threadsalready finished their work. Then, new threads can use the data that already updatedby old threads for next computation. Thus, we must ensure that both threads andReduce must participate the barrier. Just threats participating the barrier not supervisorwill cause problems.For instance, some old threads do not finished their work and thenew threads try to access the data that are still processing by the old threads. Thus,the data are corrupted and the result may be wrong.*/    System.out.println("Finished -- what a relief");    return storage[0].get();// display the finall result  }  /* ==========================================================     Fill up CubbyHoles with data from inArray     ==========================================================  */     private void initializeStorage(Object[] inArray){     int i;    for (i=0;i< inArrayLength;i++){      storage[i] = new CubbyHole();      (storage[i]).put(inArray[i]);    }  }/*  QUESTION 2:   What would be the effect on the behaviour of your data   parallel emulation if the methods of class CubbyHole   were not synchronized?   Explain briefly in a few lines inserted here:ANSWER:Class CubbyHole must employ synchronized. Synchronized just like asemaphore can avoid the race condition and protect the critical section.For example, if a thread needs to "get" an object in CubbyHole, then theobject will be locked. No other thread can access this object until thisthread finish to use this object. If class CubbyHole does not invoke thesynchronized mechanism, then every thread can access the critical sectionin same time, which is a problem just like writer and reader problem.For example, one thread read a value of an object is 100, at the same timeanother thread write this value to 0. So, to avoid this situation, the class CubbyHolemust employ the synchronized mechanism.*/  /* ==============================================================     Start up threads with a pointer to this object plus a thread     number.     ==============================================================  */  private void startThreads(){    int i = 0;    for (i=0;i < inArrayLength; i++){      nthread = new NodeThread(this,i);      nthread.start();// threats start     }  }}class NodeThread extends Thread{  int myId;  BarrierSynch myBarrier;  CubbyHole myCubby;  Reduction myParent;  ApplyObj myApplic;  NodeThread(Reduction parent,int id){    myId = id;    myBarrier = parent.waiting;    myCubby = parent.storage[id];    myParent = parent;    myApplic = parent.applic;  }  /* ==================================================================     The run method is invoked by running start on each thread.     Defining the code for this method is much of the work in your     project. In this project run will implement the code for     the part each thread plays in the reduction process.     This will generally involve using Myapplic and writing to     myCubby  and other CubbyHoles.     Barrier synchronizations is needed to provide end-of-step synch.     Each thread will have a different role according     to its thread number.     ==================================================================  */  public void run(){    // <insert code here>    // this is the code executed by individual "processors" in a    // data parallel step: remember to determine active/inactive threads    // The code below this line needs to be modified...    // at the moment it does almost nothing.    int step;       step=(int)Math.pow((double)2,((double)myParent.i-1));// myParent.i is the number of step       //       if(((myId%((int)Math.pow((double)2,(double)myParent.i))))==0){               if((myId+step)<myParent.inArrayLength){                       myCubby.put(myApplic.f(myCubby.get(),myParent.storage[myId+step].get()));               }       }    System.out.println("Hello there from thread: " + myId);    myBarrier.iveArrived(myId); // Theads entry the barrier    System.out.println("Thread finished " + myId);   }  }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美福利一区二区| 欧美一级一区二区| 国产精品久久久久久一区二区三区| 免费的国产精品| 精品国免费一区二区三区| 国产一区不卡视频| 欧美国产激情二区三区 | 一本一道久久a久久精品| 国产精品国模大尺度视频| 99精品视频在线免费观看| 亚洲免费大片在线观看| 欧美日韩高清一区二区| 美腿丝袜亚洲色图| 国产农村妇女精品| 99久久国产免费看| 婷婷综合五月天| 久久人人爽人人爽| 91在线视频免费91| 日本欧美一区二区三区| 国产日本一区二区| 色婷婷国产精品| 青青草视频一区| 久久九九国产精品| 91福利区一区二区三区| 久久精品国产999大香线蕉| 日本一区免费视频| 欧美日韩视频在线第一区| 91天堂素人约啪| 日本 国产 欧美色综合| 中文字幕精品三区| 欧美人牲a欧美精品| 高清成人免费视频| 天天色综合成人网| 国产精品私人自拍| 日韩一区二区电影网| 成人福利视频在线看| 日韩精品每日更新| 自拍偷拍亚洲激情| 欧美精品一区男女天堂| 欧美性猛交一区二区三区精品| 精品制服美女丁香| 亚洲午夜视频在线| 亚洲国产成人午夜在线一区 | 欧美日韩精品福利| 国产69精品久久99不卡| 午夜伊人狠狠久久| 欧美精品一区二区蜜臀亚洲| 欧美日韩中文精品| aaa国产一区| 精品系列免费在线观看| 五月婷婷色综合| 亚洲三级理论片| 欧美高清一级片在线观看| 欧美电视剧在线看免费| 欧美私人免费视频| 色综合久久久久久久久| 成人国产精品免费观看| 国产一区二区三区精品视频| 免费看欧美美女黄的网站| 亚洲精品成a人| 最新欧美精品一区二区三区| 久久久国际精品| 日韩一区二区三区三四区视频在线观看| 精品美女一区二区| 欧美一区二区三区在线看| 在线亚洲一区二区| 91成人免费网站| 一本大道久久a久久精二百| av电影在线不卡| 国产69精品一区二区亚洲孕妇| 韩日欧美一区二区三区| 麻豆精品在线看| 青青草成人在线观看| 污片在线观看一区二区| 亚洲一二三四区| 亚洲超碰精品一区二区| 婷婷成人激情在线网| 亚洲五月六月丁香激情| 亚洲尤物在线视频观看| 亚洲一区二区三区四区在线观看| 亚洲欧洲精品一区二区三区| 国产精品久久午夜夜伦鲁鲁| 日本一区二区三区在线观看| 久久久国产精华| 国产拍揄自揄精品视频麻豆| 国产精品嫩草99a| 国产精品你懂的| 亚洲男同1069视频| 夜夜精品视频一区二区| 香蕉加勒比综合久久| 日韩国产一二三区| 青青草国产成人av片免费| 狠狠色狠狠色综合系列| 成人美女视频在线看| 91麻豆123| 欧美酷刑日本凌虐凌虐| 精品美女在线播放| 国产拍揄自揄精品视频麻豆| 亚洲欧洲成人精品av97| 亚洲国产精品嫩草影院| 免费看日韩a级影片| 国产一区三区三区| 成人一区二区视频| 在线精品亚洲一区二区不卡| 5月丁香婷婷综合| 久久久久久久久久久99999| 国产精品护士白丝一区av| 亚洲一区精品在线| 久久99久久精品| 成人黄色在线看| 欧美精品免费视频| 精品国产成人在线影院| 日韩理论在线观看| 天天操天天色综合| 国产精品乡下勾搭老头1| 成人精品gif动图一区| 欧美日韩在线三区| 久久久精品国产99久久精品芒果| 亚洲三级在线免费观看| 精品综合免费视频观看| 色屁屁一区二区| 久久综合久色欧美综合狠狠| 亚洲品质自拍视频| 九九九精品视频| 在线免费观看日本欧美| 国产色爱av资源综合区| 亚洲va国产va欧美va观看| 国产.欧美.日韩| 3d动漫精品啪啪1区2区免费| 亚洲天堂免费在线观看视频| 久久机这里只有精品| 欧美在线观看18| 国产精品免费观看视频| 另类小说欧美激情| 欧美日韩综合不卡| 国模一区二区三区白浆| 欧美精品乱码久久久久久按摩| 国产精品久久久久四虎| 国内精品伊人久久久久av一坑 | 国产mv日韩mv欧美| 在线不卡一区二区| 亚洲精品免费在线观看| 国产99精品视频| 精品理论电影在线| 视频在线观看91| 欧美性欧美巨大黑白大战| 国产精品久久久久久户外露出| 久久av中文字幕片| 欧美区视频在线观看| 亚洲六月丁香色婷婷综合久久| 粉嫩绯色av一区二区在线观看| 91精品国产综合久久香蕉麻豆| 亚洲日本一区二区三区| 丁香婷婷综合色啪| 久久久精品tv| 国产精品一区2区| 日韩女优视频免费观看| 蜜桃久久久久久久| 91精品婷婷国产综合久久性色| 亚洲一区中文在线| 在线中文字幕一区| 亚洲一区二区在线视频| 欧洲精品在线观看| 亚洲一级二级三级在线免费观看| 色综合天天综合色综合av| 日韩一区欧美二区| 在线国产电影不卡| 亚洲精品高清视频在线观看| 日本精品免费观看高清观看| 亚洲天天做日日做天天谢日日欢 | 99精品欧美一区| ...xxx性欧美| 91免费国产在线观看| 亚洲欧洲成人自拍| 色婷婷综合久久| 一区二区三区国产精品| 欧美欧美欧美欧美| 亚洲成av人在线观看| 欧美一区二区三区男人的天堂| 日韩精品电影一区亚洲| 欧美tickling挠脚心丨vk| 国产精品99久久久久久宅男| 国产视频一区在线播放| av成人老司机| 一区二区三区在线观看网站| 欧美日韩免费在线视频| 蜜臀久久99精品久久久久宅男 | 日韩av网站在线观看| 日韩精品在线一区| 国产精品88av| 亚洲欧美日韩一区二区三区在线观看| 一本大道久久a久久综合| 亚洲国产精品天堂| 久久综合精品国产一区二区三区 | 亚洲 欧美综合在线网络| 欧美日韩夫妻久久| 久久福利视频一区二区| 亚洲欧美一区二区在线观看| 精品视频色一区| 国内精品久久久久影院一蜜桃|