Skip to content
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

Sigint #56

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Sigint #56

wants to merge 2 commits into from

Conversation

Joroks
Copy link
Collaborator

@Joroks Joroks commented Jul 3, 2024

This is my attempt to make it possible to interupt LAMMPS during a long running simulation. I'm not sure if this is the best way to solve this problem
This only works when running julia with at least two threads.

I've tested it using this script:

LMP() do lmp
    command(lmp, """
         region cell block 0 3 0 3 0 3
         create_box 1 cell
         lattice sc 1
         create_atoms 1 region cell
         mass 1 1
         run 100000000000
     """)
end

end
try
if cmd isa String
task = @async API.lammps_commands_string(lmp, cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a task? Can't we just catch the InterruptException?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll have to look into this in more detail. For my toy-example, interupting the lammps instance seems to actually work without any modifications to the code. However, when I try to interupt my real simulation, it doesn't work.

I don't know why that would be the case.

@vchuravy
Copy link
Member

vchuravy commented Jul 3, 2024

@jpsamaroo might have some thoughts here as well, in particular how this would play with JuliaLang/julia#49541

@jpsamaroo
Copy link

If that Julia PR were merged (once finished, it's not yet ready), then we could:

  • Stick with the approach in this PR (spawning a new task for running LAMMPS)
  • Spawn a new task to wait for interrupts, and register it as a handler with Julia
  • Both tasks can signal the main task with a Base.Event or some other mechanism
  • When the signal is triggered, the main task will force a LAMMPS timeout

@vchuravy vchuravy marked this pull request as draft July 15, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants