Package com.impetus.labs.korus.addons.constructs.parallelfor

Examples of com.impetus.labs.korus.addons.constructs.parallelfor.Parallel


  {
    long initialTime, finalTime;
    initialTime = System.currentTimeMillis();

    // Create an object of the construct to be used
    Parallel parallel = new Parallel();
    int number = 40000;
    // Specify begin, end and grainSize according to the machine
    int begin = 1;
    int end = number;
    int grainSize = 20000;

    BlockedRange range = new BlockedRange(begin, end, grainSize);

    // Create an object of a class extending ParallelTask Class
    ParallelFactorial af = new ParallelFactorial(parallel, range);

    // Pass the object to the parallelFor construct
    parallel.parallelFor(af);

    // Get the finalResult of execution
    Object obj = parallel.getResult();

    finalTime = System.currentTimeMillis();
    System.out.println("Total Time Taken by ParallelFactorialTest : "
        + (finalTime - initialTime));
View Full Code Here


    int start = 1;
    int end = 10;
    int grainSize = 5;
    BlockedRange range = new BlockedRange(start, end, grainSize);

    Parallel parallel = new Parallel();
    SummationTask task = new SummationTask(parallel, range);
    parallel.parallelFor(task);
    Object obj = parallel.getResult();
    assertTrue(obj instanceof Integer);
    assertEquals(55, ((Integer) obj).intValue());

  }
View Full Code Here

  {
    int start1 = 1;
    int end1 = 10;
    int grainSize1 = 5;
    BlockedRange range1 = new BlockedRange(start1, end1, grainSize1);
    Parallel parallel1 = new Parallel();

    int start2 = 1;
    int end2 = 12;
    int grainSize2 = 6;

    BlockedRange range2 = new BlockedRange(start2, end2, grainSize2);
    Parallel parallel2 = new Parallel();

    SummationTask task1 = new SummationTask(parallel1, range1);
    SummationTask task2 = new SummationTask(parallel2, range2);

    parallel1.parallelFor(task1);
    parallel2.parallelFor(task2);

    Object obj1 = parallel1.getResult();
    assertTrue(obj1 instanceof Integer);
    assertEquals(55, ((Integer) obj1).intValue());

    Object obj2 = parallel2.getResult();
    assertTrue(obj2 instanceof Integer);
    assertEquals(78, ((Integer) obj2).intValue());

  }
View Full Code Here

    // After data is generated actual value of
    long initalTime = System.currentTimeMillis();

    // Create an object of the construct to be used
    Parallel parallel = new Parallel();

    if (rccArray != null && rccArray.length >= 1)
    {

      // Specify begin, end and grainSize according to the machine
      int begin = 1;
      int end = rccArray.length;
      int grainSize = rccArray.length / 4;

      BlockedRange range = new BlockedRange(begin, end, grainSize);

      // Create an object of a class extending ParallelTask Class
      ParallelSpearmans ps = new ParallelSpearmans(parallel, range,
          rccArray);

      try
      {
        // Pass the object to the parallelFor construct
        parallel.parallelFor(ps);

        // Get the finalResult of execution
        Object obj = parallel.getResult();
        System.out.println("The value of Rho = "
            + ((Double) obj).doubleValue());

      } catch (Exception e)
      {
        e.printStackTrace();
      }

    }
    long finalTime = System.currentTimeMillis();
    System.out.println("Time Taken by ParallelSpearmansTest : "
        + (finalTime - initalTime));

    // ShutDown when task done.
    parallel.cleanup();

  }
View Full Code Here

  {

    long startTime = System.currentTimeMillis();

    // Create an object of the construct to be used
    Parallel parallel = new Parallel();

    // specify begin, end and grainSize according to the machine
    int begin = 1;
    // number of steps the curve should be divided. Bigger the number, more
    // accurate will be the value of the area under curve.
    // Therefore, blockedRangeEnd = num_steps(in SerialTrapezoid) =
    // 100000000;
    int end = 1000000000;

    // grainSize equal to blockedRangeEnd/2 to enable two threads
    int grainSize = end/4;

    BlockedRange range = new BlockedRange(begin, end, grainSize);

    // Create an object of a class extending ParallelTask Class
    ParallelTrapazoid pt = new ParallelTrapazoid(parallel, range);
    try
    {
      // Pass the object to the parallelFor construct
      parallel.parallelFor(pt);

      // Get the finalResult of execution
      Object object = parallel.getResult();

      System.out.println("AreaUnderCurve: "
          + ((Double) object).doubleValue());
    }

    catch (Exception e)
    {
      e.printStackTrace();
    }

    long endTime = System.currentTimeMillis();
    System.out.println("Total Time Taken :" + (endTime - startTime));

    // ShutDown when task done.
    parallel.cleanup();

  }
View Full Code Here

TOP

Related Classes of com.impetus.labs.korus.addons.constructs.parallelfor.Parallel

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.