Ross -
I don't see the problem with the use of "allocatable" statements where it
will do the job, which is a lot of the time. Less to screw up, low coding
cost. Use pointers when you need them in fields, etc.
Regards - Bob
----- Original Message -----
From: Ross <mailto:ross.rosswalker.co.uk> Walker
To: amber-developers.scripps.edu
Sent: Wednesday, November 09, 2005 11:09 AM
Subject: RE: amber-developers: Compile AMBER9 on SGI
Dear Xuebin,
I am aware of the problem of alias optimisation but I am not advocating
that we go pointer mad and have say 3 pointers pointing to the same thing.
Simply that we consider their use for simple arrays in place of the
'allocatable' statement since they are more flexible and, for example,
work in structures.
If we stick to just having a single pointer, and thus variable name
identifier, for each array I don't think we will have any problems. If
people want to point multiple pointers at the same location then they
should be certain they know exactly what they are doing and comment it
verbosely in the code. Otherwise debugging will become a nightmare.
All the best
Ross
/\
\/
|\oss Walker
| Department of Molecular Biology TPC15 |
| The Scripps Research Institute |
| Tel: +1 858 784 8889 | EMail:- ross.rosswalker.co.uk |
|
http://www.rosswalker.co.uk <
http://www.rosswalker.co.uk/> | PGP Key
available on request |
Note: Electronic Mail is not secure, has no guarantee of delivery, may not
be read every day, and should not be used for urgent or sensitive issues.
_____
From: owner-amber-developers.scripps.edu
[mailto:owner-amber-developers.scripps.edu] On Behalf Of Xuebin Qiao
Sent: Wednesday, November 09, 2005 03:19
To: amber-developers.scripps.edu
Subject: Re: amber-developers: Compile AMBER9 on SGI
Dear Ross:
Thanks for your comments. I agree with you that allocated pointers and
allocated arrays are same things in C/Fortran. As we all know array is
implemented via pointer by compiler behind the scene. However, what I
addressed is not this. The biggest problem when extensively use pointer in
language (not compiler) may lead to so-called "alias optimization"
problem. If you are interest, I will show you example. :-)
qxb
On 11/9/05, Ross Walker <ross.rosswalker.co.uk> wrote:
Dear Xuebin,
I disagree with the below statement at least in the most general form. I
use pointers all the time in the QMMM code and they are just as quick as
using allocatable arrays. The problem comes if they are used in a c like
fashion which is not what I was advocating.
For single dimension arrays a pointer is fine as the pointer just points
to the beginning of a single linear block of memory that you can traverse
linearly just as you would an allocatable array. Here I see no difference
between a pointer and an allocatable array.
When you move to multidimension arrays things become more complicated
since there are essentially two ways of doing things. The first, and
arguably what you should use, is the fortran way of doing things. This has
a single pointer to a linear block of memory that you can just treat as
being multidimensional by knowing the stride size of all dimensions but
the last one. This still allows linear memory traversal.
The second option is to use the 'c' style which is to allocate a 1 D
array of pointers that contains pointers to the second dimension and so
on. So arrays of pointers. This is a bad idea with regards to optimisation
as it does not guarantee linearity in memory. It also requires the lookup
of an address to get the location of an element in memory.
So, as long as we stick to the fortran approach I don't see any problem.
Somebody please correct me if you have evidence that pointers really are
worse performance wise. To date I have not come across any problems...
With regards to memory errors I always figure exactly the same thing
happens with allocatable arrays. As long as we all program in a concise
fashion - that is avoiding things like ****x etc etc., then there should
not be any problems. This said I recommend running your parts of the code
through memory checkers like valgrind on a regular basis. This can uncover
a lot of potential problems caused by array out of bounds errors etc.
Just my 2c... I don't want to get into a religious c vs fortran war,
suffice to say things can be done the wrong way in both languages...
All the best
Ross
/\
\/
|\oss Walker
| Department of Molecular Biology TPC15 |
| The Scripps Research Institute |
| Tel: +1 858 784 8889 | EMail:- ross.rosswalker.co.uk |
|
http://www.rosswalker.co.uk <
http://www.rosswalker.co.uk/> | PGP Key
available on request |
Note: Electronic Mail is not secure, has no guarantee of delivery, may not
be read every day, and should not be used for urgent or sensitive issues.
--
... there have been two really clean,
consistent models of programming so far:
the C model and the Lisp model.
These two seem points of high ground,
with swampy lowlands between them.
--Paul Graham
Received on Wed Apr 05 2006 - 23:49:50 PDT