From: Peter Bismuti <[log in to unmask]>
Date: Wed, 29 Oct 1997 15:44:25 -0500 (EST)
X-Mailer: ELM [version 2.4 PL21]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-List: [log in to unmask]
X-Unsub: To leave, send text 'leave comp-fortran-90' to [log in to unmask]
Reply-To: Peter Bismuti <[log in to unmask]>
Sender: [log in to unmask]
Precedence: list
I have a situation like this
DO i = 1,100
C(:,:,i) = MATMUL(B(:,:,i),A(:,:))
ENDDO
In other words I have a matrix multiplication that is repeated many
times where one of the matrices stays constant. If possible, I
would like to coerce the data from matrix A into cache (assume it all
fits) and have it stay there for the entire calculation.
Is there any hope of this when programming only in a high-level
language such as F90? Under what conditions could I reasonably
expect that this can be accomplished, if any?
Depends on the sizes of A, B and C. If the dimensions are small then
A should stay resident in cache. It is not automatically evicted,
only if the cache space is needed for other data.
If the dimensions are large then what you may want to do is load a
piece of A into cache, use it for all iterations i=1,100, then move
onto another piece. To get that to happen you will probably need to
write your own matrix multiple, do your own blocking and reorder the
loops manually. Some compilers can do a decent job, but not likely as
well as you can do by hand.
This is not much of a language issue. F90 is as good as any language,
although once you've done blocking, strip mining, loop reordering and
handled tails properly your code won't look much like a loop over
MATMULs.
-robert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|