Package aleph

Examples of aleph.Join


   
  SharedCounter counter = new SharedCounter();
    GlobalObject object = new GlobalObject(counter);
    CounterThread thread = new CounterThread(object);

    Join join = new Join();

    int howMany = PE.numPEs();
    int iterations = 100;
    try {
      if ( args.length > 0)
        iterations = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
      System.err.println("usage: Counter <#iterations>");
      Aleph.exit(1);
    }

    System.out.println("Counter iterations: " + iterations);
    System.out.println("#PEs\ttime");
    for (int i = 0; i < PE.numPEs(); i++) {
      long duration = 0;
      for (int j = 0; j < iterations; j++) {
        Iterator e = PE.roundRobin();
        long start = System.currentTimeMillis();
        for (int k = 0; k <= i; k++)
          thread.start((PE) e.next(), join);
        join.waitFor();
        long stop = System.currentTimeMillis();
        duration += (stop - start);
      }
      System.out.println(Integer.toString(i+1) + "\t" +
       (double) duration / (double) iterations);
View Full Code Here


  public static void main(String[] args) {

    GlobalObject object = new GlobalObject(new SharedCounter());
    CounterThread thread = new CounterThread(object);

    Join join = new Join();

    int howMany = PE.numPEs();
    int iterations = 100;
    try {
      if ( args.length > 0)
        iterations = Integer.parseInt(args[0]);
    } catch (NumberFormatException e) {
      System.err.println("usage: Counter2 <#iterations>");
      Aleph.exit(1);
    }

    System.out.println("Counter iterations: " + iterations);
    System.out.println("#PEs\ttime");
    long duration = 0;
    for (int j = 0; j < iterations; j++) {
      long start = System.currentTimeMillis();
      for (Iterator e = PE.allPEs(); e.hasNext(); )
        thread.start((PE) e.next(), join);
      join.waitFor();
      long stop = System.currentTimeMillis();
      duration += (stop - start);
    }
    System.out.println(howMany + "\t" + (double) duration / (double)
        iterations);
View Full Code Here

    }
  }

  public static void main(String[] args) {
    HelloThread thread = new HelloThread();
    Join join = new Join();
    long start = System.currentTimeMillis();
    for (Iterator e = PE.allPEs(); e.hasNext(); )
      thread.start((PE) e.next(), join);
    join.waitFor();
  }
View Full Code Here

    } catch (AlephException x) {
      Aleph.panic("Release failed: " + x);
    }
  }
      //cmod
      Join join = new Join();
      for(int k=0; k<n; k++)
  if(level[k] == i) { //level i?
    if (DEBUG)
            Aleph.debug("CMode "+k+" ...");
    for(int j=k+1; j<n; j++)
      if(level[j] > level[k]) {
        Moder m = new Moder(gb[j], gb[k]);
        m.start((PE)e.next(), join);
      }
  }
      join.waitFor();
    }
   
    //write the columns back
    for(int i=0; i<n; i++) {
      Column ctmp = (Column)gb[i].open("r");
View Full Code Here

      }

      //cmod
      if (DEBUG)
        Aleph.debug("CMode " + k + " ...");
      Join join = new Join();
      for(int j=k+1; j<n; j++) {
  Moder m = new Moder(gb[j], gb[k]);
  m.start((PE)e.next(), join);
      }
      join.waitFor();
    }

    //write the columns back
    for(int i=0; i<n; i++) {
      Column ctmp = (Column)gb[i].open("r");
View Full Code Here

  public static GlobalObject buildTree(int n, int dir, int peNo, int numPE, double minX,
               double maxX, double minY, double maxY)
  {
    double med;
    Tree t = new Tree();
    Join jv = new Join();
    PE me = PE.thisPE();
    GlobalObject gb;
    int leftN, rightN;
   
    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.println("n:"+n+" dir:"+dir+" peNo:"+peNo+" numPE:"+numPE);
    if (n == 0) return null;
    gb = new GlobalObject(t);
   
    t = (Tree) gb.open("w");
    leftN = (n-1)/2;
    rightN = n-1-leftN;
    if (dir == 1) {
      dir = 0;
      med = median(minX, maxX, n);

      if (leftN == 0)
  t._left = null;
      else {
  if (me.equals(PE.getPE(peNo+numPE/2))) {  // Local PE
    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.print("Left ");
    t._left = buildTree(leftN, dir, peNo+numPE/2, numPE/2, minX, med, minY, maxY);
  } else // Remote PE
    try {
      gb.release();
    } catch (AlephException ale) {
      Aleph.warning("Release failed: " + ale.getMessage());
    }
    Builder builder = new Builder(gb, leftN, dir, peNo+numPE/2, numPE/2,
          minX, med, minY, maxY);
    builder.start(PE.getPE(peNo+numPE/2), jv);
    jv.waitFor();
    t = (Tree) gb.open("w");
  }
      }
     
      if (rightN == 0)
  t._right = null;
      else {
  if (Aleph.verbosity(Constants.LOQUACIOUS))
    System.out.print("Right ");
  // Right subtree always in local PE
  t._right = buildTree(rightN, dir, peNo, numPE/2, med, maxX, minY, maxY);
      }

      t._x = med;
      t._y = uniform(minY, maxY);

    } else {
      dir = 1;
      med = median(minY, maxY, n);

      if (leftN == 0)
  t._left = null;
      else {
  if (me.equals(PE.getPE(peNo+numPE/2))) {  // Local PE
    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.print("Left ");
    t._left = buildTree(leftN, dir, peNo+numPE/2, numPE/2, minX, maxX, minY, med);
  } else // Remote PE
    try {
      gb.release();
    } catch (AlephException ale) {
      Aleph.warning("Release failed: " + ale.getMessage());
    }
    Builder builder = new Builder(gb, leftN, dir, peNo+numPE/2, numPE/2,
          minX, maxX, minY, med);
    builder.start(PE.getPE(peNo+numPE/2), jv);
    jv.waitFor();
    t = (Tree) gb.open("w");
  }
      }

      if (rightN == 0)
  t._right = null;
      else {
  if (Aleph.verbosity(Constants.LOQUACIOUS))
    System.out.print("Right ");
  // Right subtree always in local PE
  t._right = buildTree(rightN, dir, peNo, numPE/2, minX, maxX, med, maxY);
      }

      t._y = med;
      t._x = uniform(minX, maxX);
    }

    t._size = n;
    t._next = null;
    t._prev = null;
    jv.waitFor();
   
    try {
      gb.release();
    } catch (AlephException ale) {
      Aleph.warning("Release failed: " + ale.getMessage());
View Full Code Here

    GlobalObject gleft;
    GlobalObject gright;
    GlobalObject gttmp;
    GlobalObject retval = root;
    Tree ttmp;
    Join jv = new Join();
    if (root == null) return null;
    t = (Tree) root.open("w");
    gleft = makeList(t._left); /* head of left list */
    gright = makeList(t._right); /* head of right list */
 
View Full Code Here

      } catch (AlephException ale) {
  Aleph.warning("Release failed: " + ale.getMessage());
      }
      if (t._size <= sz) return conquer(gt);
   
      Join jv = new Join();
      PE pid = gtleft.getHome();
      if (pid.equals(PE.thisPE())) {  // Local PE
  gleftval = go(gtleft, sz, nproc_2);
      } else // Remote PE
  gleftval = new GlobalObject(new Tree());
  GlobalObject gb = new GlobalObject(gleftval);
  Traveler traveler = new Traveler(gb, gtleft, sz, nproc_2);
  traveler.start(pid, jv);
      }
   
      grightval = go(gtright, sz, nproc_2);
      jv.waitFor();
      return merge(gleftval, grightval, gt, nproc);
    } catch (Exception e) {
      Aleph.panic(e);
      return null;    // not reached
    }
View Full Code Here

  public static void main (String[] args) {
    int c, i;
    GlobalObject root;
    double dt;
    int pe;
    Join join = new Join();
 
    Data data[] = new Data[ PE.numPEs() ]; // store data distribution info

    /* default values for parameters */
    int n = 16;
    int steps  = 4;
    double dtime  = 0.0125;
    int genout = 0;

    try{
      if(args.length > 0)
        inFile = args[0];
      if(args.length > 1)
        outFile = args[1];
      if(args.length > 2)
        n = Integer.parseInt( args[2] );
      if(args.length > 3)
        steps = Integer.parseInt( args[3] );
      if(args.length > 4)
        genout = Integer.parseInt( args[4] );
    }catch( NumberFormatException e ) {
      System.err.println(
        "Usage: BarnesHut [infile] [outfile] [#nodeNum=16] [#stepsToGo=4] [#outputFlag=1]");
      Aleph.exit();
    }

    if (Aleph.verbosity(Constants.LOQUACIOUS))
      System.out.println("init data ...");

    long t0 = System.currentTimeMillis();

    InitDataThread forkInitData = new InitDataThread( n );
    for (Iterator e = PE.allPEs(); e.hasNext(); )
      forkInitData.start( (PE) e.next() , join );
    join.waitFor();
    // get returned value
    while(join.hasNext()) {
      try{
        Data d = (Data)join.next();
        data[ d.pe ] = d;
      } catch (Exception e) {
  Aleph.panic(e);
      }
    }
 
    long t1 = System.currentTimeMillis();
    dt = 0.5 * dtime;
    while (steps>0) {
      if (Aleph.verbosity(Constants.LOQUACIOUS)) {
  System.out.println("-----------Steps to go - " +
         steps + " ----------------");
  System.out.println("bookkeeping ...");
      }

      for ( pe = 0; pe < PE.numPEs(); pe++ ) {
        BookKeepingThread forkBookKeeping = new BookKeepingThread( data[pe] );
        forkBookKeeping.start( PE.getPE(pe), join );
     
      join.waitFor();
      // get returned value
      while(join.hasNext()) {
        try{
          Data d = (Data)join.next();
          data[ d.pe ] = d;
        } catch (Exception e) {
    Aleph.panic(e);
        }
      }
 
      if (Aleph.verbosity(Constants.LOQUACIOUS))
  System.out.println("maketree ...");
      root = newCell(null,0,data[ PE.thisPE().getIndex() ]);
      for ( pe = 0; pe < PE.numPEs(); pe++ ) {
        MakeTreeThread forkMakeTree = new MakeTreeThread( root, data[pe] );
        forkMakeTree.start( PE.getPE(pe), join );
      }
      join.waitFor();
      // get returned value
      while(join.hasNext()) {
        try{
          Data d = (Data)join.next();
          data[ d.pe ] = d;
        } catch (Exception e) {
    Aleph.panic(e);
        }
      }

      if (Aleph.verbosity(Constants.LOQUACIOUS))
  System.out.println("compute cofm ...");
      for ( pe = 0; pe < PE.numPEs(); pe++ ) {
        HackCofmThread forkHackCofm = new HackCofmThread( data[pe] );
        forkHackCofm.start( PE.getPE(pe), join );
      }
      join.waitFor();
      // get returned value
      while(join.hasNext()) {
        try{
          Data d = (Data)join.next();
          data[ d.pe ] = d;
        } catch (Exception e) {
    Aleph.panic(e);
        }
      }
 
      if (Aleph.verbosity(Constants.LOQUACIOUS))
  System.out.println("stepvel ...");

      for ( pe = 0; pe < PE.numPEs(); pe++ ) {
        StepVelThread forkStepVel = new StepVelThread( dt, root, data[pe] );
        forkStepVel.start( PE.getPE(pe), join );
      }
      join.waitFor();
      // get returned value
      while(join.hasNext()) {
        try{
          Data d = (Data)join.next();
          data[ d.pe ] = d;
        } catch (Exception e) {
    Aleph.panic(e);
        }
      }
 
      if (Aleph.verbosity(Constants.LOQUACIOUS))
  System.out.println("steppos ...");

      for ( pe = 0; pe < PE.numPEs(); pe++ ) {
        StepPosThread forkStepPos = new StepPosThread( dtime, data[pe] );
        forkStepPos.start( PE.getPE(pe), join );
      }
      join.waitFor();
      // get returned value
      while(join.hasNext()) {
        try{
          Data d = (Data)join.next();
          data[ d.pe ] = d;
        } catch (Exception e) {
    Aleph.panic(e);
        }
      }
View Full Code Here

   */
 
  static private void PrintOut( Data data[] )
  {
    int i;
    Join join = new Join();
 
    // create an empty outfile
    try{
      FileOutputStream out = new FileOutputStream( new File( outFile ) );
      out.close();
    } catch( IOException e ){ }

    for ( int pe = 0; pe < PE.numPEs(); pe++ ) {
      OutputThread forkOutput = new OutputThread( data[pe] );
      forkOutput.start( PE.getPE(pe), join );
    }
    join.waitFor();
  }
View Full Code Here

TOP

Related Classes of aleph.Join

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.