LCOV - code coverage report
Current view: top level - src/base - MooseInit.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 19 19 100.0 %
Date: 2026-07-23 16:15:30 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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             : #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             : 
      34             : void
      35          22 : SigHandler(int signum)
      36             : {
      37          22 :   Moose::interrupt_signal_number = signum;
      38          22 :   return;
      39             : }
      40             : 
      41             : void
      42       55280 : RegisterSigHandler()
      43             : {
      44       55280 :   signal(SIGUSR1, SigHandler);
      45       55280 : }
      46             : 
      47       55280 : MooseInit::MooseInit(int argc, char * argv[], MPI_Comm COMM_WORLD_IN)
      48       55280 :   : LibMeshInit(argc, argv, COMM_WORLD_IN)
      49             : {
      50       55280 :   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       55280 :   omp_set_num_threads(libMesh::n_threads());
      55             : #endif
      56             : 
      57             : #ifdef MOOSE_LIBTORCH_ENABLED
      58        1770 :   at::set_num_threads(libMesh::n_threads());
      59        1770 :   at::set_num_interop_threads(libMesh::n_threads());
      60             : #endif
      61             : 
      62      110560 :   if (!libMesh::on_command_line("--enable-refcount-printing"))
      63       55280 :     libMesh::ReferenceCounter::disable_print_counter_info();
      64             : 
      65       55280 :   ParallelUniqueId::initialize();
      66             : 
      67             :   // Make sure that any calls to the global random number generator are consistent among processes
      68       55280 :   MooseRandom::seed(0);
      69             : 
      70       55280 :   RegisterSigHandler();
      71             : 
      72             : #ifdef MOOSE_KOKKOS_ENABLED
      73       41104 :   initKokkos();
      74             : #endif
      75       55280 : }

Generated by: LCOV version 1.14