Package cl.niclabs.skandium

Examples of cl.niclabs.skandium.Skandium


   * {@inheritDoc}
   */
  @Override
  public Future<R> input(P param){
   
    Skandium skandium = Skandium.getSingleton();
   
    Stream<P,R> stream = skandium.newStream(this);
   
    return stream.input(param);
  }
View Full Code Here


  /**
   * {@inheritDoc}
   */
  @Override
  public Future<R>[] input(P param[]){
    Skandium skandium = Skandium.getSingleton();
   
    Stream<P,R> stream = skandium.newStream(this);
   
    return stream.input(param);
  }
View Full Code Here

        DECIMALS = Integer.parseInt(args[1]);
        PARTS    = Integer.parseInt(args[2]);
      }
      System.out.println("Computing Pi threads="+THREADS+" decimals="+ DECIMALS+" parts="+PARTS+ ".");
     
      Skandium skandium = new Skandium(THREADS);
     
    // 1. Define the skeleton program structure
    Skeleton<Interval, BigDecimal> pi = new Map<Interval, BigDecimal>(
        new SplitInterval(PARTS), //number of parts to divide by
        new PiComputer(),
        new MergeResults());

    Stream<Interval, BigDecimal> stream = skandium.newStream(pi);
   
    // 2. Input parameters with the defauls singleton Skandium object
        long init = System.currentTimeMillis();
    Future<BigDecimal> future = stream.input(new Interval(0, DECIMALS));
View Full Code Here

     
       Skeleton<Board, Count> nqueens = //Always subdivide the first row.
         new Map<Board, Count>(new DivideBoard(), subskel, new ConquerCount());
      
       //2. Create a new Skandium instance with 2 execution threads
         Skandium skandium = new Skandium(THREADS);

         //3. Open a Stream to input parameters
         Stream<Board, Count> stream = skandium.newStream(nqueens);
        
         //4. Input parameters
         long init = System.currentTimeMillis();
         Future<Count> future = stream.input(new Board(BOARD));

         //5. Do something else here.
         //...
        
         //6. Block for the results
         Count result = future.get();
         System.out.println(result+" in "+(System.currentTimeMillis() - init)+"[ms]");
        
         //7. Shutdown the system
         skandium.shutdown();
        
    }
View Full Code Here

    System.out.println("Computing BubbleSort threads="+THREADS+" size="+ SIZE + ".");

    Skeleton<ArrayList<Integer>, ArrayList<Integer>> bsort = new For<ArrayList<Integer>>(
        new BSExecute(), in.size());

    Skandium skandium = new Skandium(THREADS);
   
    long init = System.currentTimeMillis();
   
    Future<ArrayList<Integer>> future = bsort.input(in);
    try {
      out = future.get();
      System.out.println((System.currentTimeMillis() - init)+"[ms]: "+out.toArray());
      for(int i=0; i<out.size()-2;i++) {
        if(out.get(i) > out.get(i+1)) throw new Exception("Not sorted! "+ i + " "+ (i+1));
           }
     
      skandium.shutdown();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    Skeleton<ArrayList<Integer>, ArrayList<Integer>> msort = new DaC<ArrayList<Integer>, ArrayList<Integer>>(
        new MSCondition(SIZE/(THREADS*2)), new MSSplit(), new MSExecute(),
        new MSMerge());
   
    Skandium skandium = new Skandium(THREADS);

    long init = System.currentTimeMillis();
    Future<ArrayList<Integer>> future = msort.input(in);
    try {
      out = future.get();
      System.out.println((System.currentTimeMillis() - init)+"[ms]: "+out.toArray());
      for(int i=0; i<out.size()-2;i++) {
        if(out.get(i) > out.get(i+1)) throw new Exception("Not sorted! "+ i + " "+ (i+1));
      }

      skandium.shutdown();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

           new DivideOperands(),
           new StandardMultiply(),
           new ConquerMatrix());
      
       //2. Create a new Skandium instance
         Skandium skandium = new Skandium(THREADS);

         //3. Open a Stream to input parameters
         Stream<Operands, Matrix> stream = skandium.newStream(multiply);

         //4. Input parameters
         long init = System.currentTimeMillis();
         Future<Matrix> future = stream.input(new Operands(newRandomMatrix(SIZE), newRandomMatrix(SIZE)));

         //5. Do something else here.
         //...
        
         //6. Block for the results
         Matrix result = future.get();
         System.out.println("Done:"+result.length()+"x"+result.length()+ "in "+(System.currentTimeMillis() - init)+"[ms]");
    
         //7. Shutdown the system
         skandium.shutdown();
    }
View Full Code Here

        new ShouldSplit(SIZE/(THREADS*2))//threshold size for recursion
        new SplitList(), //number of parts to divide by
        new Sort(),
        new MergeList());

    Skandium skandium = new Skandium(THREADS);
   
    Stream<Range, Range> stream = skandium.newStream(sort);
   
    // 2. Input parameters with the defaults singleton Skandium object
      long init = System.currentTimeMillis();
     
    Future<Range> future = stream.input(new Range(generate(SIZE),0, SIZE-1));
View Full Code Here

TOP

Related Classes of cl.niclabs.skandium.Skandium

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.