Re: INTENT(WORKSPACE) as a new Fortran feature?
From: Ron Shepard (ron-shepard_at_NOSPAM.comcast.net)
Date: 02/18/05
- Next message: Alfredo Buttari: "reshape problem"
- Previous message: Richard E Maine: "Re: Word-processing benchmark anyone?"
- In reply to: Jan Vorbrüggen: "Re: INTENT(WORKSPACE) as a new Fortran feature?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 18 Feb 2005 10:51:08 -0600
In article <37mf48F5e539eU1@individual.net>,
Jan Vorbrüggen <jvorbrueggen-not@mediasec.de> wrote:
> > If the subroutine is called many times, it may be faster to allocate
> > the array once in the caller than each time within the subroutine.
>
> No, this doesn't make sense. If the array is small, it will be allocated
> on the stack, and this costs exactly 0 instructions in addition (because
> the stack pointer is being changed to allocate local variables in any
> case); if it's larger, any allocation from the heap will be dwarfed by
> the time required to access its contents - unless you're allocating but
> not using a large array, in which case not the language but your code is
> in urgent need of modification.
I don't think the cost of stack or heap allocation can be known
ahead of time. If garbage collection is required in order to
allocate the space repeatedly, then the time required could be
significant and the associated effort could be nonuniform between
calls. In any case, it is certainly not 0 instructions, especially
for heap allocation. Also, in the small array case, it might result
in the entire array being stored in registers or cache and the
"actual" memory would never be touched at all.
If, on a particular machine, the compiler knows that it would be
faster to allocate local memory rather than the alternatives (copy
in, and/or copy out, or address the memory of the actual argument),
then the compiler could do so as an optimization that it could not
have done before. NUMA memory structures result in some odd memory
optimizations these days, and INTENT(WORKSPACE) gives the compiler
more flexibility and seems to fit into this situation fairly well.
> My summary: don't pollute the language for such infinitesimal gain.
You may be correct here. That's why it is worth discussing. Are
multilevel caches a current fad in computer design, or are they with
us for the foreseeable future? Should the language be adapted to
accommodate them and other NUMA features (such as local and remote
memory address spaces in parallel machines), or should they be
hidden from the high-level language programmer?
$.02 -Ron Shepard
- Next message: Alfredo Buttari: "reshape problem"
- Previous message: Richard E Maine: "Re: Word-processing benchmark anyone?"
- In reply to: Jan Vorbrüggen: "Re: INTENT(WORKSPACE) as a new Fortran feature?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]