On 24 Jun 2010 11:40:59 -0700, Vivek Rao wrote:
>
> Hello.
>
> If x(:) is your big array, in Fortran 90+ you can define a pointers x1(:), x2
> (:) etc. that refer to sections of it, for example
>
> allocate (x(1000000)
> x1 => x(1:300000)
> x2 => x(300001:1000000)
>
> Vivek Rao
Naomi was specifically asking how to avoid slowdowns due to use of
pointers.
There should be compiler directives you can use to tell the compiler
that pointer memory is contiguous. However this is vendor-dependent
and isn't portable.
Another possibility is the use of Cray Pointers, which are just
another way of emulating equivalence. But support for those is
sketchy and is not portable.
In short, I would recommend simply using equivalence. It may be
obsolescent but there are plenty of codes that still use it and
support for it will probably continue for a long while.
However, I would recommend reexamining those memory allocation
assumptions when the compiler is upgraded. At a minimum, she should
make up a benchmark to test with different allocation scenarios and
encapsulate the implementation so it can be upgraded centrally.
Ted
>
> --- On Thu, 6/24/10, Greenberg, Naomi <[log in to unmask]> wrote:
>
> From: Greenberg, Naomi <[log in to unmask]>
> Subject: Memory management question
> To: [log in to unmask]
> Date: Thursday, June 24, 2010, 10:03 AM
>
> I???m currently working on a very large application where
> efficiency is a big issue. Frequent allocate/deallocates of
> large arrays is very inefficient. To speed up the code, I am
> writing a memory manager which will effectively do a single
> allocate of a huge block of memory at the beginning of the run,
> and will then parcel out blocks of it when needed to arrays that
> come in and out of ???memory???. This will eliminate system
> interrupts and paging. I have a scheme to deal with free and
> used tables that doesn???t use dynamically allocated pointers or
> arrays. My memory manager will effectively return an address
> into the large block that the caller can use for its array
> processing. My problem is how to declare the array in the
> calling program such that it???s ???allocatable??? and then
> associate it with the address in the memory buffer that the
> manager gives it. I don???t want to declare it as a fixed size.
> Equivalence is obsolescent. How do I cleverly associate an
> array with this memory address, similar to the way the compiler
> does it? Any ideas are welcome!
>
> Naomi Greenberg
>
> Member of the Reseearch Staff
>
> RIverside Research Institute
>
> 156 William Street
>
> New York, N.Y. 10038
>
> (212) 502-1718 (phone)
>
> (212) 502-1729 (fax)
>
> [log in to unmask]
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 5225 (20100624) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
--
Frango ut patefaciam -- I break so that I may reveal
|