[petsc-dev] Signal handling

Lisandro Dalcin dalcinl at gmail.com
Thu Mar 5 15:59:21 CST 2020


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:

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:

* If SIGINT or SIGTERM, I dump a restart file and set converged reason to
USER to stop.
* If SIGUSR1, I dump a restart file and continue timestepping.
* if SIGUSR2, I dump a VTK file and continue timestepping.

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.

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.

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 :-).

Regards,

-- 
Lisandro Dalcin
============
Research Scientist
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200306/0a01125e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pseudoexample.c
Type: text/x-csrc
Size: 1041 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200306/0a01125e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: petscsignal.c
Type: text/x-csrc
Size: 3762 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200306/0a01125e/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: petscsignal.h
Type: text/x-chdr
Size: 832 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200306/0a01125e/attachment-0002.bin>


More information about the petsc-dev mailing list