Team 1 Loop Transformations - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Team 1 Loop Transformations

Description:

Abdul Mohammed Mateen. Li Li. Outline of the Presentation. Objective of the project. Introduction ... Evaluate different loop transformations by the OpenUH compiler ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 19
Provided by: www249
Category:

less

Transcript and Presenter's Notes

Title: Team 1 Loop Transformations


1
Team 1 Loop Transformations
  • Carmen Musat (Team Leader)
  • Abhisheik Deo
  • Srinivas Pola
  • Abdul Mohammed Mateen
  • Li Li

2
Outline of the Presentation
  • Objective of the project
  • Introduction
  • Implementation
  • Results

3
Objective of the Project
  • Evaluate different loop transformations by the
    OpenUH compiler
  • Analyze on a vector matrix multiplication program
  • Study the report file and the source-to-source
    output
  • Test different compiler directives

4
Basic concepts
  • What is LNO?
  • -Loop Nest Optimization
  • -optimize memory performance of loop nests
  • Benefits
  • cache performance
  • parallel processing

5
What does LNO optimize?
  • Locality optimization
  • Auto parallelization
  • Array privatization
  • Heuristics integrated with software pipelining
    that employ LNO
  • Dependency analysis
  • Register/Cache blocking(tiling)
  • Array padding
  • Software pipeline

6
Loop Transformation in OpenUH
  • Popular loop transformations
  • - fussion
  • - fission
  • - interchange
  • - peeling
  • - tiling
  • - unrolling
  • - pre-fetching

7
Loop Transformation in OpenUH
  • Interchange
  • -swap the order of two loops
  • -to increase parallelism, improve spatial
    locality
  • Example
  • Do j1, 100 Do i1, 100
  • Do i1, 100 ? Do j1, 100

8
Loop Transformation in OpenUH
  • Fusion/combining
  • -combine multiple loop nests into one
  • -improve data locality, reduce loop overhead
  • Example
  • Do i1, 100 Do i1, n
  • A (i) A (i-1) A (i) A (i-1)
  • enddo B (i) A
    (i)/2
  • Do i1, 100 ? enddo
  • B (j) A (j)/2
  • enddo

9
Loop Transformation in OpenUH
  • Fission
  • -split a loop nest into multiple loop nests
  • (the inverse of fusion)
  • -produces multiple less constrained loops
  • Example
  • Do i1,
    n
  • Do i1, n A (i) B
    (i)1
  • A (i) B (i)1 ? enddo
  • C (i) A(i)/2
  • Do i1,
    n
  • enddo C (i)
    A(i)/2
  • enddo

10
Loop Transformation in OpenUH
  • Unrolling
  • -duplicate the body of the loop
  • -to reduce the times of testing loop
    conditions
  • -to reduce the jumps
  • Example
  • While iltgt32 do While iltgt32
    do
  • A (i)A (i)1 ? A (i)A (i)1

  • A (i)A (i)1

11
Implementation of the Project
  • Can be divided into two parts-
  • Writing a vector matrix multiplication program
    and understanding how the compiler optimizes the
    program.
  • Testing different compiler directives to apply
    loop transformations on a small application.

12
Implementing the first part
  • Written a vector matrix multiplication program in
    C using for loops.
  • void mul_matrix(real a, real b, real c, int n,
    int p, int m)
  • int i
  • for(i 0 i lt n i)
  • ? int j
  • for(j 0 j lt m j)
  • ? int k
  • cim j 0
  • for(k 0 k lt p k)
  • ? cim j aip k bkm j

13
Implementing the First part (contd..)
  • Written a Perl script to generate the elements of
    the matrix to be used by the matrix
    multiplication program.
  • Written a shell script to execute the program
    with various combinations loop optimization
    options and different matrix sizes.

14
The Shell script
  • start2
  • end20
  • step10
  • echo "\"CFLAGS\" \"n\" \"p\" \"m\"
    \"time\" \"error\""
  • for cflags in "-clist -o3 -LNOblocking_size4int
    erchangeOFF" \
  • "-LNOblocking_size4interchangeOFF" do
  • uhcc cflags -DCFLAGS"\"cflags\""
    matrix-mul-test.c -o matrix-mul-test
  • for n in seq start step end do
  • for p in seq start step end do
  • for m in seq start step end do
  • ./gen-matrix-mult-test.pl n p m
    ./matrix-mul-test
  • done
  • done
  • done
  • done

15
Compiler optimized the code in the following ways-
  • Changes all the for loops to while loops.
  • Collected all the declarations of variables and
    shifts them to the start.
  • Expands the expression.
  • Changes the ordering of the array indices.

16
Results
17
To be included in the Final report
  • To write a small FORTRAN program to test
    different compiler directives for applying the
    loop transformations.
  • Examples of a few compiler directives-
  • blocking_size, UNROLL n,n2,, etc

18
  • Questions please?
Write a Comment
User Comments (0)
About PowerShow.com