Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "MooseInit.h" 11 : #include "ParallelUniqueId.h" 12 : #include "Factory.h" 13 : #include "ActionFactory.h" 14 : #include "Executioner.h" 15 : #include "MooseRandom.h" 16 : 17 : #include "libmesh/petsc_solver_exception.h" 18 : 19 : // PETSc 20 : #include "petscsys.h" 21 : 22 : #ifdef LIBMESH_HAVE_OPENMP 23 : #include <omp.h> 24 : #endif 25 : 26 : #ifdef MOOSE_LIBTORCH_ENABLED 27 : #include <ATen/Parallel.h> 28 : #endif 29 : 30 : #include <unistd.h> 31 : #include <signal.h> 32 : 33 : void 34 32 : SigHandler(int signum) 35 : { 36 32 : Moose::interrupt_signal_number = signum; 37 32 : return; 38 : } 39 : 40 : void 41 55903 : RegisterSigHandler() 42 : { 43 55903 : signal(SIGUSR1, SigHandler); 44 55903 : } 45 : 46 55903 : MooseInit::MooseInit(int argc, char * argv[], MPI_Comm COMM_WORLD_IN) 47 55903 : : LibMeshInit(argc, argv, COMM_WORLD_IN) 48 : { 49 55903 : LibmeshPetscCallA(COMM_WORLD_IN, PetscPopSignalHandler()); // get rid of PETSc error handler 50 : 51 : // Set the number of OpenMP threads to the same as the number of threads libMesh is going to use 52 : #ifdef LIBMESH_HAVE_OPENMP 53 55903 : omp_set_num_threads(libMesh::n_threads()); 54 : #endif 55 : 56 : #ifdef MOOSE_LIBTORCH_ENABLED 57 5815 : at::set_num_threads(libMesh::n_threads()); 58 5815 : at::set_num_interop_threads(libMesh::n_threads()); 59 : #endif 60 : 61 55903 : ParallelUniqueId::initialize(); 62 : 63 : // Make sure that any calls to the global random number generator are consistent among processes 64 55903 : MooseRandom::seed(0); 65 : 66 55903 : RegisterSigHandler(); 67 55903 : }