| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************/ | ||
| 2 | /* Copyright 2009-2026 Barcelona Supercomputing Center */ | ||
| 3 | /* */ | ||
| 4 | /* This file is part of the DLB library. */ | ||
| 5 | /* */ | ||
| 6 | /* DLB is free software: you can redistribute it and/or modify */ | ||
| 7 | /* it under the terms of the GNU Lesser General Public License as published by */ | ||
| 8 | /* the Free Software Foundation, either version 3 of the License, or */ | ||
| 9 | /* (at your option) any later version. */ | ||
| 10 | /* */ | ||
| 11 | /* DLB is distributed in the hope that it will be useful, */ | ||
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
| 14 | /* GNU Lesser General Public License for more details. */ | ||
| 15 | /* */ | ||
| 16 | /* You should have received a copy of the GNU Lesser General Public License */ | ||
| 17 | /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */ | ||
| 18 | /*********************************************************************************/ | ||
| 19 | |||
| 20 | #include "LB_core/fork_handler.h" | ||
| 21 | |||
| 22 | #include "LB_comm/shmem_async.h" | ||
| 23 | #include "LB_comm/shmem_barrier.h" | ||
| 24 | #include "LB_comm/shmem_cpuinfo.h" | ||
| 25 | #include "LB_comm/shmem_lewi_async.h" | ||
| 26 | #include "LB_comm/shmem_lewi_light.h" | ||
| 27 | #include "LB_comm/shmem_mngo.h" | ||
| 28 | #include "LB_comm/shmem_procinfo.h" | ||
| 29 | #include "LB_comm/shmem_talp.h" | ||
| 30 | #include "LB_core/node_barrier.h" | ||
| 31 | #include "LB_core/spd.h" | ||
| 32 | #include "LB_core/thread_ctx.h" | ||
| 33 | #include "support/tracing.h" | ||
| 34 | |||
| 35 | #ifdef MPI_LIB | ||
| 36 | #include "mpi/mpi_core.h" | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #include <pthread.h> | ||
| 40 | |||
| 41 | 19 | static void dlb_atfork_prepare(void) { | |
| 42 | 19 | shmem_async__atfork_prepare(); | |
| 43 | 19 | shmem_cpuinfo__atfork_prepare(); | |
| 44 | 19 | shmem_lewi_async__atfork_prepare(); | |
| 45 | 19 | shmem_lewi_light__atfork_prepare(); | |
| 46 | 19 | shmem_mngo__atfork_prepare(); | |
| 47 | 19 | shmem_procinfo__atfork_prepare(); | |
| 48 | 19 | shmem_talp__atfork_prepare(); | |
| 49 | 19 | node_barrier__atfork_prepare(); | |
| 50 | 19 | spd_atfork_prepare(); | |
| 51 | 19 | } | |
| 52 | |||
| 53 | 19 | static void dlb_atfork_parent(void) { | |
| 54 | 19 | shmem_async__atfork_parent(); | |
| 55 | 19 | shmem_cpuinfo__atfork_parent(); | |
| 56 | 19 | shmem_lewi_async__atfork_parent(); | |
| 57 | 19 | shmem_lewi_light__atfork_parent(); | |
| 58 | 19 | shmem_mngo__atfork_parent(); | |
| 59 | 19 | shmem_procinfo__atfork_parent(); | |
| 60 | 19 | shmem_talp__atfork_parent(); | |
| 61 | 19 | node_barrier__atfork_parent(); | |
| 62 | 19 | spd_atfork_parent(); | |
| 63 | 19 | } | |
| 64 | |||
| 65 | ✗ | static void dlb_atfork_child(void) { | |
| 66 | ✗ | shmem_async__atfork_child(); | |
| 67 | ✗ | shmem_cpuinfo__atfork_child(); | |
| 68 | ✗ | shmem_lewi_async__atfork_child(); | |
| 69 | ✗ | shmem_lewi_light__atfork_child(); | |
| 70 | ✗ | shmem_mngo__atfork_child(); | |
| 71 | ✗ | shmem_procinfo__atfork_child(); | |
| 72 | ✗ | shmem_talp__atfork_child(); | |
| 73 | ✗ | node_barrier__atfork_child(); | |
| 74 | ✗ | spd_atfork_child(); | |
| 75 | |||
| 76 | ✗ | shmem_barrier__reset_after_fork(); | |
| 77 | instrument_reset_after_fork(); | ||
| 78 | ✗ | thread_ctx_reset_after_fork(); | |
| 79 | #if MPI_LIB | ||
| 80 | mpi_core_reset_after_fork(); | ||
| 81 | #endif | ||
| 82 | } | ||
| 83 | |||
| 84 | static pthread_once_t once = PTHREAD_ONCE_INIT; | ||
| 85 | |||
| 86 | 38 | static void do_register(void) { | |
| 87 | 38 | pthread_atfork(dlb_atfork_prepare, dlb_atfork_parent, dlb_atfork_child); | |
| 88 | 38 | } | |
| 89 | |||
| 90 | 117 | void fork_handler_init(void) { | |
| 91 | 117 | pthread_once(&once, do_register); | |
| 92 | 117 | } | |
| 93 |