PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
parallelUtil.h
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2024 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#pragma once
12
13#include <mpi.h>
14#include <string>
15#include <vector>
16#include <thread>
17
18namespace util {
19
21 namespace parallel {
23 struct MpiStatus {
24
27
30
33
35 MPI_Comm d_comm;
36
38 MpiStatus();
39
47 std::string printStr(int nt = 0, int lvl = 0) const;
48 };
49
56 void initMpi(int argc = 0, char *argv[] = nullptr);
57
59 void initMpiStatus();
60
66 bool isMpiEnabled();
67
73 int mpiSize();
74
80 int mpiRank();
81
87 MPI_Comm mpiComm();
88
94 const MpiStatus *getMpiStatus();
95
101 void initNThreads(
102 unsigned int nThreads = std::thread::hardware_concurrency());
103
109 unsigned int getNThreads();
110 } // namespace parallel
111} // namespace util
bool isMpiEnabled()
Function to check if MPI is enabled.
void initMpiStatus()
Initializes MpiStatus struct.
unsigned int getNThreads()
Get number of threads to be used by taskflow.
void initNThreads(unsigned int nThreads=std::thread::hardware_concurrency())
Initializes MpiStatus struct.
const MpiStatus * getMpiStatus()
Returns pointer to MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
int mpiSize()
Get size (number) of processors.
int mpiRank()
get rank (id) of this processor
MPI_Comm mpiComm()
Get MPI comm.
Collection of methods useful in simulation.
Struct that stores MPI-related information.
int d_mpiRank
Rank (id) of this processor.
bool d_mpiEnabled
Specifies if MPI is enabled (yes if code executed with more than one processor)
int d_mpiSize
Size (number) of processors.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
MPI_Comm d_comm
MPI comm.