Profiling Java Programs for
           Parallelism
Authors: Clemens Hammacher, Kevin Streit,
   Sebastian Hack and Andreas Zeller



Presented by:
Anisimov Dmitry (Theoretical part)
Igdalov Dimitri (Demo)
Challenge


  How to leverage the computer power of
multicore architectures for systems that were
     not built with parallelism in mind?
The idea of article


 To try to measure the potential for parallel
execution in recent object-oriented programs.
Approach of authors

Three main steps:

    Tracing dynamic dependencies

    Detecting parallelism

    Suggesting parallelization candidates
Tracing dynamic dependences (1)


    Trace is a program P(D) obtained by running
    a program P on some input D.

    The basis of parallelism-detection algorithm
    is the execution trace of a program run on a
    specific input.
Tracing dynamic dependences (2)

During tracing we define dynamic dependencies:

    If instruction B of program consumes values
    computed by A then B is data dependent on
    A and must be executed after A.
Detecting parallelism (1)

     The dynamic dependencies form a dynamic
               dependence graph.


          This graph describes how the
    individual instructions transitively depend
           on and influence each other.
Detecting parallelism (2)


    In the dynamic dependence graph we can
identify parallel as well as serial computation
paths.

    The main serial path is critical path H.

    Critical path H is longest path whose
instructions must be executed sequentially.
Detecting parallelism (3)



    Ideal speed-up factor of parallelization is n/k
     where n is the length of program P and k is
            the length of critical path H.
Suggesting parallelization
            candidates


    Loops placed on critical path H are the most
    interesting portion of P w.r.t. parallelization.

    Loops are ranked w.r.t. the potential gain on
           the execution of program P.
Example (1)
Public static void main(String[] args) {

            int n = Integer. parseInt(args[0]);
            long[] sums = new long[n]
            long overallSum = 0;
            for (int i = 0; i < n; ++i) {
                          sums[i] = sumTo(i);
            }
            for (int i = 0; i < n; ++i) {
                          overallSum += sums[i];
            }
}

private static long sumTo(int n) {

            return n == 0 ? 0 : n + sumTo(n – 1);
}
Example (2)
Example (3)
Example (4)
Results for example

We have 4 threads for parallel execution:

    Thread 0: 0 2 4 5 10

    Thread 1: 1 3

    Thread 2: 7 8

    Thread 3: 6 9
Thank you


The End

Profiling Java Programs for Parallelism

  • 1.
    Profiling Java Programsfor Parallelism Authors: Clemens Hammacher, Kevin Streit, Sebastian Hack and Andreas Zeller Presented by: Anisimov Dmitry (Theoretical part) Igdalov Dimitri (Demo)
  • 2.
    Challenge Howto leverage the computer power of multicore architectures for systems that were not built with parallelism in mind?
  • 3.
    The idea ofarticle To try to measure the potential for parallel execution in recent object-oriented programs.
  • 4.
    Approach of authors Threemain steps:  Tracing dynamic dependencies  Detecting parallelism  Suggesting parallelization candidates
  • 5.
    Tracing dynamic dependences(1)  Trace is a program P(D) obtained by running a program P on some input D.  The basis of parallelism-detection algorithm is the execution trace of a program run on a specific input.
  • 6.
    Tracing dynamic dependences(2) During tracing we define dynamic dependencies:  If instruction B of program consumes values computed by A then B is data dependent on A and must be executed after A.
  • 7.
    Detecting parallelism (1)  The dynamic dependencies form a dynamic dependence graph. This graph describes how the individual instructions transitively depend on and influence each other.
  • 8.
    Detecting parallelism (2)  In the dynamic dependence graph we can identify parallel as well as serial computation paths.  The main serial path is critical path H.  Critical path H is longest path whose instructions must be executed sequentially.
  • 9.
    Detecting parallelism (3)  Ideal speed-up factor of parallelization is n/k where n is the length of program P and k is the length of critical path H.
  • 10.
    Suggesting parallelization candidates  Loops placed on critical path H are the most interesting portion of P w.r.t. parallelization.  Loops are ranked w.r.t. the potential gain on the execution of program P.
  • 11.
    Example (1) Public staticvoid main(String[] args) { int n = Integer. parseInt(args[0]); long[] sums = new long[n] long overallSum = 0; for (int i = 0; i < n; ++i) { sums[i] = sumTo(i); } for (int i = 0; i < n; ++i) { overallSum += sums[i]; } } private static long sumTo(int n) { return n == 0 ? 0 : n + sumTo(n – 1); }
  • 12.
  • 13.
  • 14.
  • 15.
    Results for example Wehave 4 threads for parallel execution:  Thread 0: 0 2 4 5 10  Thread 1: 1 3  Thread 2: 7 8  Thread 3: 6 9
  • 16.