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

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

?? reduction.java.bak

?? this code is a parallel programming code . such code is esay but is very useful to understand how to
?? BAK
字號:
/*   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);    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());      };/*   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);   // 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();    }  }}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一区二区三区免费野_久草精品视频
亚洲一区影音先锋| 综合色中文字幕| 成人av手机在线观看| 一区二区三区四区不卡在线| 国产乱妇无码大片在线观看| 亚洲欧美日韩国产综合在线| 国产欧美日本一区二区三区| 精品国产乱码久久久久久图片| 欧美久久久久久久久| 日韩精品一区二区三区在线播放| av高清久久久| 国产欧美一区二区精品久导航 | 91精品国产综合久久久久| 中文字幕一区二区三区蜜月| 91毛片在线观看| 中文字幕不卡一区| 91啪亚洲精品| 久久久综合激的五月天| 欧美视频精品在线观看| 欧美精品乱码久久久久久按摩| 欧美精品一区二区三区在线| 亚洲国产成人一区二区三区| 一区二区成人在线观看| 国产大片一区二区| 91污在线观看| xfplay精品久久| 国产嫩草影院久久久久| 免费黄网站欧美| 久久一区二区三区四区| 99久久综合色| 日本vs亚洲vs韩国一区三区二区| 久久精品在线免费观看| 色婷婷综合在线| 玖玖九九国产精品| 亚洲美女在线国产| 日韩欧美二区三区| 91亚洲资源网| 精品一区在线看| 依依成人综合视频| www成人在线观看| 欧美少妇性性性| 国产不卡视频一区| 日韩av一区二区三区四区| 国产精品午夜电影| 日韩视频免费直播| 一本色道久久加勒比精品| 激情综合色播五月| 亚洲午夜三级在线| 国产精品久久久久桃色tv| 制服丝袜亚洲色图| 91免费国产在线| 国产成人欧美日韩在线电影| 肉肉av福利一精品导航| 亚洲精品美国一| 国产精品理伦片| 久久综合五月天婷婷伊人| 欧美午夜一区二区| 91视频你懂的| 高清成人免费视频| 狠狠久久亚洲欧美| 日本不卡视频一二三区| 亚洲国产你懂的| 亚洲人成网站色在线观看| 久久婷婷国产综合国色天香| 69堂精品视频| 欧美日本在线播放| 欧洲av一区二区嗯嗯嗯啊| 成人不卡免费av| 国产麻豆精品theporn| 美女高潮久久久| 日韩成人一级片| 午夜久久久影院| 亚洲午夜免费电影| 夜夜嗨av一区二区三区网页| 亚洲欧美日韩一区| 自拍偷拍国产亚洲| 亚洲欧美一区二区久久 | 色综合中文字幕| 成年人国产精品| www.一区二区| 91丨九色丨国产丨porny| 91美女蜜桃在线| 在线观看视频欧美| 欧美视频第二页| 制服丝袜亚洲精品中文字幕| 这里只有精品视频在线观看| 91精品国产色综合久久久蜜香臀| 欧美日韩色一区| 538在线一区二区精品国产| 国产亚洲一本大道中文在线| 国产日韩av一区| 国产精品久久久久9999吃药| 中文字幕亚洲一区二区va在线| 亚洲婷婷综合色高清在线| 一区二区三区电影在线播| 亚洲一区二区精品3399| 亚洲国产综合91精品麻豆| 日韩高清一级片| 国产一区二区三区久久久| 成人精品高清在线| 91久久精品一区二区三区| 精品视频一区 二区 三区| 欧美一区二区三区在线看| 久久午夜色播影院免费高清| 国产精品女人毛片| 亚洲妇女屁股眼交7| 日本成人超碰在线观看| 国产伦精一区二区三区| 成人av集中营| 欧美亚洲精品一区| 精品国产亚洲在线| 国产精品久久99| 亚洲成人777| 麻豆一区二区三区| jlzzjlzz国产精品久久| 欧美日韩一区二区在线观看视频 | 国产aⅴ综合色| 色系网站成人免费| 日韩欧美国产一区在线观看| 亚洲国产精品成人久久综合一区| 一二三区精品视频| 国产一区二区三区免费播放| 日本高清不卡在线观看| 日韩美女视频一区二区在线观看| 国产精品欧美久久久久无广告| 亚洲一区二区三区四区在线观看| 麻豆精品蜜桃视频网站| 91视频www| 精品国产乱码久久久久久蜜臀| 亚洲日韩欧美一区二区在线| 裸体歌舞表演一区二区| 91一区二区三区在线播放| 日韩亚洲欧美高清| 亚洲欧美成aⅴ人在线观看| 久久精品999| 欧美视频一区二区三区在线观看| 久久久久久久网| 日韩福利视频网| 99re热这里只有精品免费视频| 欧美不卡在线视频| 91美女在线看| 久久久久久久久久美女| 五月婷婷激情综合网| 成人国产在线观看| 日韩精品一区二| 亚洲高清视频中文字幕| av在线这里只有精品| 精品国产a毛片| 日韩影院精彩在线| 欧美在线观看一二区| 中文字幕一区二区三区四区不卡| 国产在线视视频有精品| 制服丝袜激情欧洲亚洲| 亚洲电影第三页| 在线国产电影不卡| 最新热久久免费视频| 国产成人日日夜夜| 久久免费视频色| 久久av资源网| 日韩欧美在线一区二区三区| 亚洲一区二区在线观看视频| 97se亚洲国产综合在线| 国产精品伦一区二区三级视频| 激情文学综合网| 精品国内二区三区| 美女免费视频一区| 日韩一级完整毛片| 日本欧美大码aⅴ在线播放| 欧美日韩精品福利| 午夜电影一区二区| 欧美精品vⅰdeose4hd| 午夜精品福利在线| 3d动漫精品啪啪一区二区竹菊 | 国产亚洲精品福利| 国产福利91精品一区二区三区| 日韩三级免费观看| 狠狠色综合日日| 久久影视一区二区| 国产sm精品调教视频网站| 欧美国产精品一区二区| 成人av在线播放网站| 中文字幕一区在线| 色久综合一二码| 亚洲成年人网站在线观看| 在线播放91灌醉迷j高跟美女| 日一区二区三区| 欧美不卡123| 高清av一区二区| 亚洲人妖av一区二区| 欧美优质美女网站| 蜜桃视频一区二区三区| 久久蜜臀精品av| 成人sese在线| 一本一本大道香蕉久在线精品| 一区二区在线看| 91精品一区二区三区久久久久久 | 丁香婷婷深情五月亚洲| 中文字幕一区二区在线播放| 91久久久免费一区二区| 琪琪一区二区三区|