https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MooseInit.C
Go to the documentation of this file.
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#include "libmesh/reference_counter.h"
19
20// PETSc
21#include "petscsys.h"
22
23#ifdef LIBMESH_HAVE_OPENMP
24#include <omp.h>
25#endif
26
27#ifdef MOOSE_LIBTORCH_ENABLED
28#include <ATen/Parallel.h>
29#endif
30
31#include <unistd.h>
32#include <signal.h>
33
34void
35SigHandler(int signum)
36{
38 return;
39}
40
41void
43{
44 signal(SIGUSR1, SigHandler);
45}
46
47MooseInit::MooseInit(int argc, char * argv[], MPI_Comm COMM_WORLD_IN)
48 : LibMeshInit(argc, argv, COMM_WORLD_IN)
49{
50 LibmeshPetscCallA(COMM_WORLD_IN, PetscPopSignalHandler()); // get rid of PETSc error handler
51
52// Set the number of OpenMP threads to the same as the number of threads libMesh is going to use
53#ifdef LIBMESH_HAVE_OPENMP
54 omp_set_num_threads(libMesh::n_threads());
55#endif
56
57#ifdef MOOSE_LIBTORCH_ENABLED
58 at::set_num_threads(libMesh::n_threads());
59 at::set_num_interop_threads(libMesh::n_threads());
60#endif
61
62 if (!libMesh::on_command_line("--enable-refcount-printing"))
64
66
67 // Make sure that any calls to the global random number generator are consistent among processes
69
71
72#ifdef MOOSE_KOKKOS_ENABLED
73 initKokkos();
74#endif
75}
void SigHandler(int signum)
Definition MooseInit.C:35
void RegisterSigHandler()
Definition MooseInit.C:42
MooseInit(int argc, char *argv[], MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD)
Definition MooseInit.C:47
void initKokkos()
static void seed(unsigned int seed)
The method seeds the random number generator.
Definition MooseRandom.h:44
static void initialize()
Must be called by main thread before any threaded computation! Do NOT call in a worker thread!
static void disable_print_counter_info()
volatile std::sig_atomic_t interrupt_signal_number
Used by the signal handler to determine if we should write a checkpoint file out at any point during ...
Definition Moose.C:898
bool on_command_line(std::string arg)
unsigned int n_threads()