Hello All:

I am proposing the inter-procedural Loop fusion. Generally the Loops adjacent 
to each other and the conformable
Candidates of loop fusions are done with respect to intra-procedural loops. The 
whole program analysis needs to
Be done with array sections analysis across the procedure calls to fuse the 
loops across the procedure calls. 

In the example given in Fig(1) the doubly nested loops in routine sub1 will be 
a candidates of fusing the doubly
Nested loops in routine sub2 in Fig(2). The main calls routine sub1 and sub2 
and the loops in routine sub1 and sub2
Can be fused. The array section analysis and dependence analysis is done on the 
regions across the procedure calls
For loops in sub1 and sub2. 

Here is the proposal for loop fusion across the procedure calls. Normally loop 
peeling is done to make the candidate
For Loop fusion and the sub2 function the loops can also be peeled. 

In the examples given below the array A and array B are global variables in 
order to happen the loops fusion across
the procedure calls.

The below examples are extracted from the articles on the following.

"Inter-procedure loop fusion, array compaction and rotation" by John Ng et.al

Examples:

program main
common /s/ A(N),B(N) 
call sub1() 
call sub2()
 end 
Subroutine sub1() common /s/ A(N),B(N) 
do j=1,N 
  do i=1,N 
     A(i+1, j) = j -i 
    enddo 
enddo
do i=1,N 
A(1,i) = i * 2
enddo
 do i=1,N
A(i+1,n+1) = A(i+1,1)
 enddo
end /* sub1 */

Fig (1)

 Subroutine sub2() common /s/ A(N),B(N)
 do j=1,N
    do i=1,N
       B(i,j) = A(i+1,j+1) +A(i,j+1) + A(i,j) +A(i+1,j) 
     enddo
enddo
 end 

Fig (2).

Thoughts Please?

Thanks & Regards
Ajit

Reply via email to