[lammps-users] n00b - speed up lammps code?

Hi,

At this time I'm using lammps code for only two weeks. But some general questions already arised to me:

(1) Why do you use constructs like: x[i][2] instead of one dimensional arrays? Do you keep track in every loop that you use contiguous memory segments? For my own code I always used 1d arrays combined wit pointer arithmetics in order to avoid these difficulties.
(2) Why are there different makefiles for different architectures? Wouldn't it be better to use one makefile with different switches?
(3) Why don't you use compiler optimizations like "-O3" or "-funroll-loops" etc?

Is there already a CVS tree of lammps for development?

Best regards:

Gerolf

(1) Why do you use constructs like: x[i][2] instead of one

dimensional >arrays? Do you keep track in every loop that you use
contiguous memory >segments? For my own code I always used 1d arrays
combined wit pointer >arithmetics in order to avoid these
difficulties.

I think x[i][2] is more clear than x[i*n+2] or the pointer equivalent.
And when I did some early testing, the speed difference wasn't
significant. The 3*N values are stored contigously (for cache
performance), so if you write your own chunk of code, you
can access them however you wish.

(2) Why are there different makefiles for different architectures?

Wouldn't it >be better to use one makefile with different switches?

I think 25 small Makefiles is simpler than one big Makefile. The
user typically just needs to worry about one of them. And
the two-level scheme is nice when you are building LAMMPS for
multiple platforms, which we do a lot.

(3) Why don't you use compiler optimizations like "-O3" or

"-funroll-loops" >etc?

I haven't played much with compiler options since they are so
compiler and machine dependent and I haven't seen much impact
on run time. But that's why the Makefiles are simple, so you can
change whatever you want. If you find options that make the code run
faster and you think they are generally useful, send back a Makefile.foo
and we'll add it to the distribution.

Is there already a CVS tree of lammps for development?

We use Subversion internally, but the server is inside our firewall,
so users can't currently get to it.