<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">Hi, Lisandro,<div> It is very cool to see you can make petsc dance with slurm. From you pseudo example, my comments are:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>* Do we need a type PetscSigSet instead of explicit  int?</div>* Why do PetscSignalBegin/End() have different argument types? Many petsc XxxBegin/End() routines have the same arguments. It is easier to remember for users.<br>* Why do you need PetscSigMask in public header?  Can user do PetscSignalClear(PETSC_SIGUSR1) instead of PetscSignalClear(PetscSigMask(PETSC_SIGUSR1))?</blockquote><div> I like fewer and simpler public APIs.  Just my two cents.</div><div><br><div>Thanks.<br><div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 5, 2020 at 4:00 PM Lisandro Dalcin <<a href="mailto:dalcinl@gmail.com">dalcinl@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I've implemented some lightweight signal handling facilities. See the attached header and implementation files for a taste of the current API, and the pseudo-example code showing how to use it, briefly described below:<div><br></div><div>Right now I'm using it to interact with the job scheduler during (explicit) timestepping. I have being/end signal handling calls around TSSolve(). A PostStep() routine catches signals and handles them this way:</div><div><br><div><div>* If SIGINT or SIGTERM, I dump a restart file and set converged reason to  USER to stop.<br></div><div>* If SIGUSR1, I dump a restart file and continue timestepping.</div><div>* if SIGUSR2, I dump a VTK file and continue timestepping.<br><div><br></div><div>I can send signals to the job with `scancel -s SIG<NAME>`. When the job time allocation  is about to expire, SLURM fist sends SIGTERM and waits some time before SIGKILL. That time is enough to get a restart file from the last step, stop timestepping and finalize gracefully.</div><div></div><div><br></div><div>I'm not 100% happy with the API, maybe I should make it easier to use. For example, I could define each PETSC_SIGXXX so that I do need the macro PetscSigMask(). That would complicate a bit the mapping signal enum -> name string, though. I could also implement PetscSignalRaise(), it may be useful, but I'm not sure.</div><div><div><br></div><div>Do you think this may be of some value for core PETSc? I'm asking before submitting a MR because that would require writing some docs, I don't want to do the doc work before knowing your opinion first :-).</div><div><br></div><div>Regards,</div><div><br></div><div>-- <br><div dir="ltr"><div dir="ltr"><div>Lisandro Dalcin<br>============<br>Research Scientist<br>Extreme Computing Research Center (ECRC)<br>King Abdullah University of Science and Technology (KAUST)<br><a href="http://ecrc.kaust.edu.sa/" target="_blank">http://ecrc.kaust.edu.sa/</a><br></div></div></div></div></div></div></div></div></div>
</blockquote></div>