Re: Improving multi-dimension array access performance
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 28 Nov 2008 09:58:45 -0600
In article <ggo8ld$h12$1@xxxxxxxx>,
Glen Herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:
In cases where it isn't possible, such as matrix multiply, which goes
through arrays in different directions,
I'm not exactly sure what you mean by "isn't possible", but the
following loop structure accomplishes a matrix-matrix product and
steps through all three arrays with the innermost loops
corresponding to the left-most index.
do i = 1, n1
do j = 1, n2
bji = b(j,i)
do k = 1, n3
c(k,i) = c(k,i) + a(k,j) * bji
enddo
enddo
enddo
I think the thing that some people forget about this operation is
that there are three do loops, which results in 6 (=3!) possible
loop structures. In other words, there isn't just one way to do the
operation. On some machines one loop order is best, on other
machines another loop order is best. The above loop structure
treats the operation as a series of matrix-vector products, so it is
one of the conceptually obvious ones. Of course, loop unrolling,
subblocking, strip mining, and all of the other optimization
techniques should still be used to optimize this operation, and when
those options are combined with the 6 possible loop structures,
there are a tremendous number of practical possibilities.
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: Improving multi-dimension array access performance
- From: Glen Herrmannsfeldt
- Re: Improving multi-dimension array access performance
- From: Glen Herrmannsfeldt
- Re: Improving multi-dimension array access performance
- References:
- Improving multi-dimension array access performance
- From: Rajorshi Biswas
- Re: Improving multi-dimension array access performance
- From: Glen Herrmannsfeldt
- Improving multi-dimension array access performance
- Prev by Date: Re: Difficulty with Relatively Simple IF Structure
- Next by Date: Re: Improving multi-dimension array access performance
- Previous by thread: Re: Improving multi-dimension array access performance
- Next by thread: Re: Improving multi-dimension array access performance
- Index(es):
Relevant Pages
|