Re: Efficient way to pass different shaped arrays?
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 28 Jun 2006 17:28:52 -0700
Peter wrote:
(snip)
Efficiency is paramount here, because B is called millions of times. So
I am reluctant to use any method which adds execution time. I guess
that for an assumed-shape array, the address computations are more
time-consuming, since the dimensions are not compile-time constants,
but run-time variables.
For an assumed shape array the rank must match, but (3,0:0) isn't
that much more work. For assumed size it is something like second
subscript times 28 plus first subscript plus some constant.
For assumed shape it has to do two multiplies, as the array could
be in non-contiguous storage, loading the multipliers from the
descriptor. As Richard indicates, that may or may not make a big
difference. If you make the first subscript constant and 32, it
might be able to use a shift instead of a multiply, but it will
also take somewhat more memory, and not as much of the array will
stay in the cache. Most likely that doesn't help.
The bounds of the array are being passed as separate arguments now.
If the bounds are being passed, use either the passed bounds or
a * (or 0:*) for the second subscript. With assumed size, even
without a constant first subscript you might still do a little
better than assumed shape.
Or keep it the first at 28 and pass a 28 element array.
I agree with Richard that the only way to be sure is to time it.
-- glen
.
- References:
- Efficient way to pass different shaped arrays?
- From: Peter
- Re: Efficient way to pass different shaped arrays?
- From: Michael Metcalf
- Re: Efficient way to pass different shaped arrays?
- From: Peter
- Efficient way to pass different shaped arrays?
- Prev by Date: Re: Efficient way to pass different shaped arrays?
- Next by Date: Re: Efficient way to pass different shaped arrays?
- Previous by thread: Re: Efficient way to pass different shaped arrays?
- Next by thread: Re: Efficient way to pass different shaped arrays?
- Index(es):
Relevant Pages
|