Re: Optimization in gfortran



On 2005-07-05 10:36:44 +0200, "FX" <coudert@xxxxxxxxxxxxx> said:

So I tried with -O3, it compiles but at a certain  point while the
program is running, it hungs and I must do a forced exit with (CTRL-C
to stop the execution).

Does anyone know why?

How can I solve that problem (obviosly with -O instead of -O3, but why
that?).

As someone else already mentionned, this could be a compiler bug (wrong optimisation leading to an infinite loop) but this could be a bug in your code too. Writing robust floating-point code can be very hard.

I'll try to reduce it. By now I have compiled a second program version that I have done. The first (the one for which doesn't work -O3) Is a "parallel" simulation the second is "serial". I explain myself:


I must do a simulation of a multiplescale flow using Langevin equation. All the subroutine (Random number generator, gaussian, Stochastic 4 order Runge-Kutta, the diffusion, velocity, etc..) are the same in the two codes. What change is the way I do the mean for the correlation function, mean displacement, diffusion, etc.

In the first case I put 10^5 particles in a 2pi x 2pi sqare (the flow is periodic) with a costant mesure, I wait they reach the asyntotic mesure and the I pass throw the integrator all the particle at the same time: for t=1 I integrate all the particle to t=1.01 and so on. For every time step I compute all the macroscopic variable and store it in a .txt file.

In the secondo I put a single particle, store the relevant quantity in an array, every x time I do a cut and I recall the particle as the second particle and so on. While I have performed 10^5 simulation. I compute the macroscopic quantity for every time via the stored array (really it is a matrix(n,t)).

Phisically speaking the first method makes an ensemble mean, the second a time mean.

The code is the same for about 98%

What really changes is the inversion of "time" and "particle number" do loop, and the change from a "continuous" I/O call to write the .txt file and an array storage with a finale file write.

Does anyone have any tips?

Thank to all, David.

.



Relevant Pages

  • Re: Representing structures for simulations
    ... multidimensional array. ... cartesian grid; the grid can be distorted in various ways (e.g., ... Because the adjacency information is precomputed ... One simple method is storing, with each particle, a list of all of the ...
    (comp.lang.fortran)
  • Re: question on list comprehensions
    ... > I am simulating diffraction from an array of particles. ... > a complex array for each particle, add up all these arrays, and square the ... blog: http://rascunhosrotos.blogspot.com ...
    (comp.lang.python)
  • Re: question on list comprehensions
    ... >> I am simulating diffraction from an array of particles. ... > each particle? ... the overhead in the for loop can be ... The list comprehension wants to create a new list instead. ...
    (comp.lang.python)