New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clearing state after claw.run() completes #70
Comments
Where is |
The memory sharing issue is happening in the Fortran kernels, which are not thread-safe and share context. There are a few ways to mitigate this, depending on what you're trying to do. There is definitely a potential bug here on PyClaw side. |
@ahmadia What state do you think is being stored in the Fortran code that might be causing this? I was thinking that perhaps a state was not being copied correctly and was being carried over although I think your suggestion that the solver is at fault is more probable. |
Obviously depends on the solver, but anything in the common blocks is shared memory and not thread-safe. |
Ah, that's true. @dansteingart what solver are you using with this? |
I've tried to dig around and clear the fortran memory with little luck, @ahmadia do you have workaround I could use? Effectively I just want to revert back to "clean slatE" between each run, I don't need to keep any variables from the last run? |
@mandli classic I think, will double check |
What about the Riemann solver? |
I would suggest writing a second script to spawn Python subprocesses per job, but this is a pretty poor workaround. |
Unfortunately, the Fortran kernels are all "stateful", so fixing this, at minimum, would require exposing a Fortran routine for your solver that clears any common data. |
@ahmadia @mandli I'm using the riemann.vc_acoustics_2D solver. I've used the spawn approach in the past and it works with one caveat -> if I read/write to a file (e.g. read parameters from a file) from the subprocess I see the same effect. So having a handle on what's happening in fortran would be really helpful. |
Are the advection speeds changing in time in your case? If that is the case how are you implementing the change in velocities? |
@mandli I am not changing the velocities (modeling acoustics through solids). |
@dansteingart I suggest that you post the full script. Without knowing where your state and solver are coming from, there are a lot of things that could potentially be wrong. If things are the way I think they are, the easiest fix is to create a new solver object each time. Is there some reason you need to reuse it? Also, if you are reusing state you will run into problems simply because it has already been advanced to the final time. |
V5.4.0 fvmbook
Within a python script, using PyClaw/ClawPack Often times I can run two simulations within ~1 seconds of each other (the same simulation), and completely different results are obtained. One is completely non-physical, so it's relatively easy to discard the poor result.
I think there's a memory sharing issue, but I cannot figure out how to completely clear the claw class from memory within a python script, e.g:
This def runs fine if I call it once, but if I call it again it I often get a different, unphysical result.
The text was updated successfully, but these errors were encountered: