HPhi++
3.1.0
|
MPI wrapper for init, finalize, bcast, etc. More...
#include <mpi.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "wrapperMPI.hpp"
#include <cmath>
#include <complex>
#include "splash.hpp"
#include "global.hpp"
#include "common/setmemory.hpp"
Go to the source code of this file.
Functions | |
void | InitializeMPI (int argc, char *argv[]) |
MPI initialization wrapper Process ID (myrank), Number of processes (nproc), Number of threads (nthreads), and pointer to the standard output (stdoutMPI) are specified here. More... | |
void | FinalizeMPI () |
MPI Finitialization wrapper. More... | |
void | exitMPI (int errorcode) |
MPI Abortation wrapper. More... | |
FILE * | fopenMPI (const char *FileName, const char *mode) |
MPI file I/O (open) wrapper. Only the root node (myrank = 0) should be open/read/write (small) parameter files. More... | |
char * | fgetsMPI (char *InputString, int maxcount, FILE *fp) |
MPI file I/O (get a line, fgets) wrapper. Only the root node (myrank = 0) reads and broadcast string. More... | |
void | BarrierMPI () |
MPI barrier wrapper. More... | |
long int | MaxMPI_li (long int idim) |
MPI wrapper function to obtain maximum unsigned long integer across processes. More... | |
double | MaxMPI_d (double dvalue) |
MPI wrapper function to obtain maximum Double across processes. More... | |
std::complex< double > | SumMPI_dc (std::complex< double > norm) |
MPI wrapper function to obtain sum of Double complex across processes. More... | |
double | SumMPI_d (double norm) |
MPI wrapper function to obtain sum of Double across processes. More... | |
void | SumMPI_dv (int nnorm, double *norm) |
MPI wrapper function to obtain sum of Double array across processes. More... | |
void | SumMPI_cv (int nnorm, std::complex< double > *norm) |
MPI wrapper function to obtain sum of Double array across processes. More... | |
long int | SumMPI_li (long int idim) |
MPI wrapper function to obtain sum of unsigned long integer across processes. More... | |
int | SumMPI_i (int idim) |
MPI wrapper function to obtain sum of integer across processes. More... | |
long int | BcastMPI_li (int root, long int idim) |
MPI wrapper function to broadcast long integer across processes. More... | |
double | NormMPI_dc (long int idim, std::complex< double > *_v1) |
Compute norm of process-distributed vector \(|{\bf v}_1|^2\). More... | |
void | NormMPI_dv (long int ndim, int nstate, std::complex< double > **_v1, double *dnorm) |
Compute norm of process-distributed vector \(|{\bf v}_1|^2\). More... | |
std::complex< double > | VecProdMPI (long int ndim, std::complex< double > *v1, std::complex< double > *v2) |
Compute conjugate scaler product of process-distributed vector \({\bf v}_1^* \cdot {\bf v}_2\). More... | |
void | MultiVecProdMPI (long int ndim, int nstate, std::complex< double > **v1, std::complex< double > **v2, std::complex< double > *prod) |
Compute conjugate scaler product of process-distributed vector \({\bf v}_1^* \cdot {\bf v}_2\). More... | |
void | SendRecv_cv (int origin, long int nMsgS, long int nMsgR, std::complex< double > *vecs, std::complex< double > *vecr) |
Wrapper of MPI_Sendrecv for std::complex<double> number. When we pass a message longer than 2^31-1 (max of int: 2147483647), we need to divide it. More... | |
void | SendRecv_iv (int origin, long int nMsgS, long int nMsgR, long int *vecs, long int *vecr) |
Wrapper of MPI_Sendrecv for long integer number. When we pass a message longer than 2^31-1 (max of int: 2147483647), we need to divide it. More... | |
long int | SendRecv_i (int origin, long int isend) |
Wrapper of MPI_Sendrecv for long integer number. More... | |
MPI wrapper for init, finalize, bcast, etc.
Definition in file wrapperMPI.cpp.
void BarrierMPI | ( | ) |
MPI barrier wrapper.
Definition at line 160 of file wrapperMPI.cpp.
long int BcastMPI_li | ( | int | root, |
long int | idim | ||
) |
MPI wrapper function to broadcast long integer across processes.
[in] | root | The source process of the broadcast |
[in] | idim | Value to be broadcasted |
Definition at line 305 of file wrapperMPI.cpp.
Referenced by Initialize_wave().
void exitMPI | ( | int | errorcode | ) |
MPI Abortation wrapper.
[in] | errorcode | Error-code to be returned as that of this program |
Definition at line 86 of file wrapperMPI.cpp.
Referenced by CalcByLOBPCG(), CalcByTEM(), CalcByTPQ(), CalcSpectrum(), CalcSpectrumByBiCG(), CheckMPI(), CheckMPI_Summary(), dsfmt_chk_init_by_array(), dsfmt_chk_init_gen_rand(), Initialize_wave(), InitializeMPI(), main(), MakeExcitedList(), MaxMPI_d(), MaxMPI_li(), Output_restart(), phys(), Read_sz(), ReadDefFileIdxPara(), SeedSwitch(), SendRecv_cv(), SendRecv_i(), SendRecv_iv(), SumMPI_cv(), SumMPI_d(), SumMPI_dc(), SumMPI_dv(), SumMPI_i(), SumMPI_li(), sz(), and X_GC_child_CisAjt_Hubbard_MPI().
char* fgetsMPI | ( | char * | InputString, |
int | maxcount, | ||
FILE * | fp | ||
) |
MPI file I/O (get a line, fgets) wrapper. Only the root node (myrank = 0) reads and broadcast string.
[out] | InputString | read line. |
[in] | maxcount | Length of string |
[in] | fp | file pointer |
Definition at line 122 of file wrapperMPI.cpp.
References myrank.
Referenced by CalcSpectrumByBiCG(), GetFileName(), inputHam(), Read_sz(), ReadcalcmodFile(), ReadDefFileIdxPara(), ReadDefFileNInt(), and SetOmega().
void FinalizeMPI | ( | ) |
MPI Finitialization wrapper.
Definition at line 74 of file wrapperMPI.cpp.
References myrank, and stdoutMPI.
Referenced by main(), and MakeExcitedList().
FILE* fopenMPI | ( | const char * | FileName, |
const char * | mode | ||
) |
MPI file I/O (open) wrapper. Only the root node (myrank = 0) should be open/read/write (small) parameter files.
[in] | FileName | Input/output file |
[in] | mode | "w", "r", etc. |
Definition at line 105 of file wrapperMPI.cpp.
References myrank.
Referenced by childfopenMPI(), GetFileName(), ReadcalcmodFile(), ReadDefFileIdxPara(), and ReadDefFileNInt().
void InitializeMPI | ( | int | argc, |
char * | argv[] | ||
) |
MPI initialization wrapper Process ID (myrank), Number of processes (nproc), Number of threads (nthreads), and pointer to the standard output (stdoutMPI) are specified here.
Definition at line 44 of file wrapperMPI.cpp.
References exitMPI(), myrank, nproc, nthreads, splash(), and stdoutMPI.
Referenced by main().
double MaxMPI_d | ( | double | dvalue | ) |
MPI wrapper function to obtain maximum Double across processes.
[in] | dvalue | Value to be maximized |
Definition at line 188 of file wrapperMPI.cpp.
References exitMPI().
Referenced by check().
long int MaxMPI_li | ( | long int | idim | ) |
MPI wrapper function to obtain maximum unsigned long integer across processes.
[in] | idim | Value to be maximized |
Definition at line 171 of file wrapperMPI.cpp.
References exitMPI().
Referenced by check(), MakeExcitedList(), and setmem_large().
void MultiVecProdMPI | ( | long int | ndim, |
int | nstate, | ||
std::complex< double > ** | v1, | ||
std::complex< double > ** | v2, | ||
std::complex< double > * | prod | ||
) |
Compute conjugate scaler product of process-distributed vector \({\bf v}_1^* \cdot {\bf v}_2\).
[in] | ndim | Local dimension of vector |
[in] | v1 | [ndim] vector to be producted |
[in] | v2 | [ndim] vector to be producted |
Definition at line 401 of file wrapperMPI.cpp.
References SumMPI_cv().
Referenced by expec_cisajs_Hubbard(), expec_cisajs_HubbardGC(), expec_cisajs_SpinGCGeneral(), expec_cisajs_SpinGCHalf(), expec_cisajs_SpinGeneral(), expec_cisajs_SpinHalf(), expec_cisajscktalt_Hubbard(), expec_cisajscktalt_HubbardGC(), expec_cisajscktalt_SpinGCGeneral(), expec_cisajscktalt_SpinGCHalf(), expec_cisajscktalt_SpinGeneral(), and expec_cisajscktalt_SpinHalf().
double NormMPI_dc | ( | long int | idim, |
std::complex< double > * | _v1 | ||
) |
Compute norm of process-distributed vector \(|{\bf v}_1|^2\).
[in] | idim | Local dimension of vector |
[in] | _v1 | [idim] vector to be producted |
Definition at line 321 of file wrapperMPI.cpp.
References SumMPI_d().
Referenced by CalcSpectrumByBiCG().
void NormMPI_dv | ( | long int | ndim, |
int | nstate, | ||
std::complex< double > ** | _v1, | ||
double * | dnorm | ||
) |
Compute norm of process-distributed vector \(|{\bf v}_1|^2\).
[in] | ndim | Local dimension of vector |
[in] | _v1 | [idim] vector to be producted |
Definition at line 344 of file wrapperMPI.cpp.
References SumMPI_dv().
Referenced by Initialize_wave(), LOBPCG_Main(), and Multiply().
void SendRecv_cv | ( | int | origin, |
long int | nMsgS, | ||
long int | nMsgR, | ||
std::complex< double > * | vecs, | ||
std::complex< double > * | vecr | ||
) |
Wrapper of MPI_Sendrecv for std::complex<double> number. When we pass a message longer than 2^31-1 (max of int: 2147483647), we need to divide it.
Definition at line 424 of file wrapperMPI.cpp.
References exitMPI().
Referenced by X_Ajt_MPI(), X_child_CisAit_GeneralSpin_MPIdouble(), X_child_CisAit_spin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIsingle(), X_child_CisAjt_MPIdouble(), X_child_CisAjt_MPIsingle(), X_child_CisAjtCkuAku_Hubbard_MPI(), X_child_CisAjtCkuAlv_Hubbard_MPI(), X_child_general_hopp_MPIdouble(), X_child_general_hopp_MPIsingle(), X_child_general_int_spin_MPIdouble(), X_child_general_int_spin_MPIsingle(), X_child_general_int_spin_TotalS_MPIdouble(), X_Cis_MPI(), X_GC_Ajt_MPI(), X_GC_child_CisAisCjuAjv_GeneralSpin_MPIdouble(), X_GC_child_CisAisCjuAjv_GeneralSpin_MPIsingle(), X_GC_child_CisAisCjuAjv_spin_MPIdouble(), X_GC_child_CisAisCjuAjv_spin_MPIsingle(), X_GC_child_CisAit_GeneralSpin_MPIdouble(), X_GC_child_CisAit_spin_MPIdouble(), X_GC_child_CisAitCiuAiv_spin_MPIdouble(), X_GC_child_CisAitCiuAiv_spin_MPIsingle(), X_GC_child_CisAitCjuAju_GeneralSpin_MPIdouble(), X_GC_child_CisAitCjuAju_spin_MPIdouble(), X_GC_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), X_GC_child_CisAitCjuAjv_GeneralSpin_MPIsingle(), X_GC_child_CisAjtCkuAku_Hubbard_MPI(), X_GC_child_CisAjtCkuAlv_Hubbard_MPI(), X_GC_child_general_hopp_MPIdouble(), X_GC_child_general_hopp_MPIsingle(), and X_GC_Cis_MPI().
long int SendRecv_i | ( | int | origin, |
long int | isend | ||
) |
Wrapper of MPI_Sendrecv for long integer number.
Definition at line 504 of file wrapperMPI.cpp.
References exitMPI().
Referenced by X_Ajt_MPI(), X_child_CisAit_GeneralSpin_MPIdouble(), X_child_CisAit_spin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIsingle(), X_child_CisAjt_MPIdouble(), X_child_CisAjt_MPIsingle(), X_child_CisAjtCkuAku_Hubbard_MPI(), X_child_CisAjtCkuAlv_Hubbard_MPI(), X_child_general_hopp_MPIdouble(), X_child_general_hopp_MPIsingle(), X_child_general_int_spin_MPIdouble(), X_child_general_int_spin_MPIsingle(), X_child_general_int_spin_TotalS_MPIdouble(), X_Cis_MPI(), X_GC_Ajt_MPI(), X_GC_child_CisAisCjuAjv_spin_MPIdouble(), X_GC_child_CisAisCjuAjv_spin_MPIsingle(), X_GC_child_CisAit_spin_MPIdouble(), X_GC_child_CisAitCiuAiv_spin_MPIdouble(), X_GC_child_CisAitCiuAiv_spin_MPIsingle(), X_GC_child_CisAitCjuAju_spin_MPIdouble(), X_GC_child_CisAjtCkuAku_Hubbard_MPI(), X_GC_child_CisAjtCkuAlv_Hubbard_MPI(), X_GC_child_general_hopp_MPIdouble(), X_GC_child_general_hopp_MPIsingle(), and X_GC_Cis_MPI().
void SendRecv_iv | ( | int | origin, |
long int | nMsgS, | ||
long int | nMsgR, | ||
long int * | vecs, | ||
long int * | vecr | ||
) |
Wrapper of MPI_Sendrecv for long integer number. When we pass a message longer than 2^31-1 (max of int: 2147483647), we need to divide it.
Definition at line 465 of file wrapperMPI.cpp.
References exitMPI().
Referenced by X_Ajt_MPI(), X_child_CisAit_GeneralSpin_MPIdouble(), X_child_CisAit_spin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIsingle(), X_child_CisAjt_MPIdouble(), X_child_CisAjt_MPIsingle(), X_child_CisAjtCkuAku_Hubbard_MPI(), X_child_CisAjtCkuAlv_Hubbard_MPI(), X_child_general_hopp_MPIdouble(), X_child_general_hopp_MPIsingle(), X_child_general_int_spin_MPIdouble(), X_child_general_int_spin_MPIsingle(), X_child_general_int_spin_TotalS_MPIdouble(), and X_Cis_MPI().
void SumMPI_cv | ( | int | nnorm, |
std::complex< double > * | norm | ||
) |
MPI wrapper function to obtain sum of Double array across processes.
[in] | norm | Value to be summed |
Definition at line 254 of file wrapperMPI.cpp.
References exitMPI().
Referenced by LOBPCG_Main(), and MultiVecProdMPI().
double SumMPI_d | ( | double | norm | ) |
MPI wrapper function to obtain sum of Double across processes.
[in] | norm | Value to be summed |
Definition at line 222 of file wrapperMPI.cpp.
References exitMPI().
Referenced by MultiplyForTEM(), and NormMPI_dc().
std::complex<double> SumMPI_dc | ( | std::complex< double > | norm | ) |
MPI wrapper function to obtain sum of Double complex across processes.
[in] | norm | Value to be summed |
Definition at line 205 of file wrapperMPI.cpp.
References exitMPI().
Referenced by VecProdMPI().
void SumMPI_dv | ( | int | nnorm, |
double * | norm | ||
) |
MPI wrapper function to obtain sum of Double array across processes.
[in] | norm | Value to be summed |
Definition at line 238 of file wrapperMPI.cpp.
References exitMPI().
Referenced by expec_energy_flct(), expec_energy_flct_GeneralSpin(), expec_energy_flct_GeneralSpinGC(), expec_energy_flct_HalfSpin(), expec_energy_flct_HalfSpinGC(), expec_energy_flct_Hubbard(), expec_energy_flct_HubbardGC(), LOBPCG_Main(), NormMPI_dv(), totalspin_Hubbard(), totalspin_HubbardGC(), totalspin_Spin(), and totalspin_SpinGC().
int SumMPI_i | ( | int | idim | ) |
MPI wrapper function to obtain sum of integer across processes.
[in] | idim | Value to be summed |
Definition at line 288 of file wrapperMPI.cpp.
References exitMPI().
Referenced by CheckMPI_Summary().
long int SumMPI_li | ( | long int | idim | ) |
MPI wrapper function to obtain sum of unsigned long integer across processes.
[in] | idim | Value to be summed |
Definition at line 271 of file wrapperMPI.cpp.
References exitMPI().
Referenced by CheckMPI_Summary(), and Initialize_wave().
std::complex<double> VecProdMPI | ( | long int | ndim, |
std::complex< double > * | v1, | ||
std::complex< double > * | v2 | ||
) |
Compute conjugate scaler product of process-distributed vector \({\bf v}_1^* \cdot {\bf v}_2\).
[in] | ndim | Local dimension of vector |
[in] | v1 | [ndim] vector to be producted |
[in] | v2 | [ndim] vector to be producted |
Definition at line 367 of file wrapperMPI.cpp.
References nthreads, and SumMPI_dc().
Referenced by CalcSpectrumByBiCG().