Repair all MPI-driven parallel executables

This commit is contained in:
J.-S. Caux
2021-08-24 15:20:32 +02:00
parent 4af687fb03
commit 287107f7e1
17 changed files with 25 additions and 0 deletions
-113
View File
@@ -1,113 +0,0 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: Heis_DSF_par.cc
Purpose: Parallel version of ABACUS using MPICH.
***********************************************************/
#include "ABACUS.h"
#include "mpi.h"
using namespace ABACUS;
int main(int argc, char *argv[])
{
char whichDSF;
DP Delta;
int N, M, iKneeded, iKmin, iKmax, Max_Secs;
DP target_sumrule = 1.0e+6; // effectively deactivated here
bool refine;
if (argc != 8) { // provide some info
cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
cout << endl << "Usage of Heis_DSF_par executable: " << endl;
cout << endl << "This function runs ABACUS in parallel mode, starting from a preexisting "
"serial run (obtained using the Heis_DSF executable) using the same model parameters." << endl;
cout << endl << "Provide the following arguments:" << endl << endl;
cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: "
"m for S- S+, z for Sz Sz, p for S+ S-." << endl;
cout << "DP Delta \t\t Value of the anisotropy: use positive real values only" << endl;
cout << "int N \t\t\t Length (number of sites) of the system: use positive even integer values only" << endl;
cout << "int M \t\t\t Number of down spins: use positive integer values between 1 and N/2" << endl;
cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: "
"recommended values: 0 and N" << endl;
cout << "int Max_Secs \t\t Allowed computational time: (in seconds)" << endl;
cout << endl << "EXAMPLE: " << endl << endl;
cout << "mpiexec -np 8 Heis_DSF_par z 1.0 100 40 0 100 600" << endl << endl;
return(0);
}
else { // (argc == 8) correct nr of arguments
whichDSF = *argv[1];
Delta = atof(argv[2]);
N = atoi(argv[3]);
M = atoi(argv[4]);
iKmin = atoi(argv[5]);
iKmax = atoi(argv[6]);
Max_Secs = atoi(argv[7]);
}
DP supercycle_time = 600.0; // allotted time per supercycle
if (Max_Secs <= supercycle_time + 300) ABACUSerror("Please allow more time in Heis_DSF_par.");
MPI::Init(argc, argv);
DP tstart = MPI::Wtime();
int rank = MPI::COMM_WORLD.Get_rank();
int nr_processors = MPI::COMM_WORLD.Get_size();
if (nr_processors < 2) ABACUSerror("Give at least 2 processors to ABACUS parallel !");
refine = true;
// ASSUMPTION: preexisting files (raw, thr, ...) exist for the run.
// IMPORTANT PRECONDITION: no flags are being raised in General_Scan in parallel mode, so
// the preinitializing serial run must be extensive enough to have flagged all base/type s necessary.
DP tnow = MPI::Wtime();
while (tnow - tstart < Max_Secs - supercycle_time - 300) { // space for one more supercycle, + 5 minutes safety
if (rank == 0)
// Split up thread list into chunks, one per processor
Prepare_Parallel_Scan_Heis (whichDSF, Delta, N, M, iKmin, iKmax, nr_processors);
// Barrier synchronization, to make sure other processes wait for process of rank 0
// to have finished splitting up the thr file into pieces before starting:
MPI_Barrier (MPI::COMM_WORLD);
// then everybody gets going on their own chunk !
Scan_Heis (whichDSF, Delta, N, M, iKmin, iKmax,
supercycle_time, target_sumrule, refine, rank, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
// Now that everybody is done, digest data into unique files
if (rank == 0)
Wrapup_Parallel_Scan_Heis (whichDSF, Delta, N, M, iKmin, iKmax, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
tnow = MPI::Wtime();
} // while (tnow - tstart...
MPI::Finalize();
return(0);
}
+1
View File
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
+1
View File
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
#include "mpi.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
+1
View File
@@ -14,6 +14,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
#include "mpi.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
-135
View File
@@ -1,135 +0,0 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: LiebLin_DSF_par.cc
Purpose: Parallel version of ABACUS using MPICH.
***********************************************************/
#include "ABACUS.h"
#include "mpi.h"
using namespace ABACUS;
int main(int argc, char *argv[])
{
char whichDSF;
DP c_int, L;
int N, Nl, DIl, DIr, iKmin, iKmax, Max_Secs, supercycle_time;
DP target_sumrule = 1.0e+6; // effectively deactivated here
bool refine = true; // always true for parallel mode
DP kBT = 0.0; // dummy
if (argc != 12) { // provide some info
cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
cout << endl << "Usage of LiebLin_DSF_MosesState_par executable: " << endl;
cout << endl << "This function runs ABACUS in parallel mode, starting from a preexisting "
"serial run (obtained using the LiebLin_DSF executable) using the same model parameters." << endl;
cout << endl << "Provide the following arguments:" << endl << endl;
cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: "
"d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
cout << "DP c_int \t\t Value of the interaction parameter: use positive real values only" << endl;
cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
cout << "int Nl \t\t\t Number of particles in left Fermi sea (Nr is then N - Nl)" << endl;
cout << "int DIl \t\t shift of left sea as compared to its ground state position" << endl;
cout << "int DIr \t\t shift of right sea as compared to its ground state position" << endl;
cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: "
"recommended values: -2*N and 2*N" << endl;
cout << "int Max_Secs \t\t Allowed computational time: (in seconds)" << endl;
cout << "int supercycle_time \t\t time for one supercycle (in seconds)" << endl;
cout << endl << "EXAMPLE: " << endl << endl;
cout << "mpiexec -np 8 LiebLin_DSF_MosesState_par d 1.0 100.0 100 50 -30 20 -400 400 3600 600" << endl << endl;
return(0);
}
else { // (argc == 11) correct nr of arguments
whichDSF = *argv[1];
c_int = atof(argv[2]);
L = atof(argv[3]);
N = atoi(argv[4]);
Nl = atoi(argv[5]);
DIl = atoi(argv[6]);
DIr = atoi(argv[7]);
iKmin = atoi(argv[8]);
iKmax = atoi(argv[9]);
Max_Secs = atoi(argv[10]);
supercycle_time = atoi(argv[11]);
}
if (Max_Secs <= supercycle_time) ABACUSerror("Please allow more time in LiebLin_DSF_par.");
MPI::Init(argc, argv);
DP tstart = MPI::Wtime();
int rank = MPI::COMM_WORLD.Get_rank();
int nr_processors = MPI::COMM_WORLD.Get_size();
if (nr_processors < 2) ABACUSerror("Give at least 2 processors to ABACUS parallel !");
refine = true;
// ASSUMPTION: preexisting files (raw, thr, ...) exist for the run.
DP tnow = MPI::Wtime();
// Define the Moses state:
LiebLin_Bethe_State MosesState (c_int, L, N);
// Split the sea:
for (int i = 0; i < Nl; ++i) MosesState.Ix2[i] += 2 * DIl;
for (int i = Nl; i < N; ++i) MosesState.Ix2[i] += 2 * DIr;
MosesState.Compute_All (true);
// Handy default name:
stringstream defaultScanStatename_strstream;
defaultScanStatename_strstream << "Moses_Nl_" << Nl << "_DIl_" << DIl << "_DIr_" << DIr;
string defaultScanStatename = defaultScanStatename_strstream.str();
MPI_Barrier (MPI::COMM_WORLD);
while (tnow - tstart < Max_Secs - supercycle_time - 120) { // space for one more supercycle, + 2 minutes safety
if (rank == 0)
// Split up thread list into chunks, one per processor
Prepare_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
// Barrier synchronization, to make sure other processes wait for process of rank 0
// to have finished splitting up the thr file into pieces before starting:
MPI_Barrier (MPI::COMM_WORLD);
// then everybody gets going on their own chunk !
Scan_LiebLin (whichDSF, MosesState, defaultScanStatename, iKmin, iKmax, supercycle_time,
target_sumrule, refine, rank, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
// Now that everybody is done, digest data into unique files
if (rank == 0)
Wrapup_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
tnow = MPI::Wtime();
} // while (tnow - tstart...
MPI::Finalize();
return(0);
}
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
#include "mpi.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
-158
View File
@@ -1,158 +0,0 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: LiebLin_DSF_over_Ensemble_par.cc
Purpose: main function for ABACUS for LiebLin gas, averaging over an Ensemble, parallel implementation.
***********************************************************/
#include "ABACUS.h"
#include "mpi.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char* argv[])
{
if (argc != 10) { // provide some info
cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
cout << endl << "Usage of LiebLin_DSF_Tgt0 executable: " << endl;
cout << endl << "Provide the following arguments:" << endl << endl;
cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: "
"d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
cout << "DP c_int \t\t Value of the interaction parameter: use positive real values only" << endl;
cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: "
"recommended values: -2*N and 2*N" << endl;
cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
cout << "int Max_Secs \t\t Allowed computational time: (in seconds)" << endl;
cout << "bool refine \t\t Is this a refinement of earlier calculations ? (0 == false, 1 == true)" << endl;
cout << endl << "EXAMPLE: " << endl << endl;
cout << "LiebLin_DSF_over_Ensemble d 1.0 100.0 100 0 200 0.56 10 600 0" << endl << endl;
}
else { // (argc == 10), correct nr of arguments
char whichDSF = *argv[1];
DP c_int = atof(argv[2]);
DP L = atof(argv[3]);
int N = atoi(argv[4]);
int iKmin = atoi(argv[5]);
int iKmax = atoi(argv[6]);
DP kBT = atof(argv[7]);
int Max_Secs = atoi(argv[8]);
bool refine = (atoi(argv[9]) == 1);
if (refine == false) ABACUSerror("Please run the serial version of LiebLin_DSF_over_Ensemble first.");
MPI::Init(argc, argv);
DP tstart = MPI::Wtime();
int rank = MPI::COMM_WORLD.Get_rank();
int nr_processors = MPI::COMM_WORLD.Get_size();
if (nr_processors < 2) ABACUSerror("Give at least 2 processors to ABACUS parallel !");
// Start by constructing (or loading) the state ensemble.
LiebLin_Diagonal_State_Ensemble ensemble;
stringstream ensfilestrstream;
ensfilestrstream << "LiebLin_c_int_" << c_int << "_L_" << L << "_N_" << N << "_kBT_" << kBT << ".ens";
string ensfilestr = ensfilestrstream.str();
const char* ensfile_Cstr = ensfilestr.c_str();
if (!refine) { // Construct the state ensemble
ensemble = LiebLin_Thermal_Saddle_Point_Ensemble (c_int, L, N, kBT);
ensemble.Save(ensfile_Cstr); // Save the ensemble
}
else { // load the ensemble data
ensemble.Load(c_int, L, N, ensfile_Cstr);
}
MPI_Barrier (MPI::COMM_WORLD);
// Now perform the DSF calculation over each state in the ensemble
int Max_Secs_used = Max_Secs/ensemble.nstates;
DP supercycle_time = 600.0; // allotted time per supercycle
if (Max_Secs_used <= supercycle_time) ABACUSerror("Please allow more time in LiebLin_DSF_par.");
// Main loop over ensemble:
for (int ns = 0; ns < ensemble.nstates; ++ns) {
tstart = MPI::Wtime();
DP tnow = MPI::Wtime();
string defaultScanStatename = ensemble.state[ns].label;
while (tnow - tstart < Max_Secs_used - supercycle_time) { // space for one more supercycle
if (rank == 0)
// Split up thread list into chunks, one per processor
Prepare_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
// Barrier synchronization, to make sure other processes wait for process of rank 0
// to have finished splitting up the thr file into pieces before starting:
MPI_Barrier (MPI::COMM_WORLD);
// then everybody gets going on their own chunk !
Scan_LiebLin (whichDSF, ensemble.state[ns], ensemble.state[ns].label, iKmin, iKmax, supercycle_time, 1.0e+6, refine, rank, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
// Now that everybody is done, digest data into unique files
if (rank == 0)
Wrapup_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
tnow = MPI::Wtime();
} // while (tnow - tstart...
} // for ns
MPI_Barrier (MPI::COMM_WORLD);
// Final wrapup of the data
if (rank == 0) {
// Evaluate the f-sumrule
stringstream FSR_stringstream; string FSR_string;
Data_File_Name (FSR_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
FSR_stringstream << "_ns_" << ensemble.nstates << ".fsr";
FSR_string = FSR_stringstream.str(); const char* FSR_Cstr = FSR_string.c_str();
DP Chem_Pot = 0.0;
Evaluate_F_Sumrule (whichDSF, c_int, L, N, kBT, ensemble.nstates, Chem_Pot, iKmin, iKmax, FSR_Cstr);
}
MPI_Barrier (MPI::COMM_WORLD);
} // correct nr of arguments
MPI::Finalize();
return(0);
}
-115
View File
@@ -1,115 +0,0 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: LiebLin_DSF_par.cc
Purpose: Parallel version of ABACUS using MPICH.
***********************************************************/
#include "ABACUS.h"
#include "mpi.h"
using namespace ABACUS;
int main(int argc, char *argv[])
{
char whichDSF;
DP c_int, L, kBT;
int N, iKmin, iKmax, Max_Secs, supercycle_time;
DP target_sumrule = 1.0e+6; // effectively deactivated here
bool refine = true; // always true for parallel mode
if (argc != 10) { // provide some info
cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
cout << endl << "Usage of LiebLin_DSF_par executable: " << endl;
cout << endl << "This function runs ABACUS in parallel mode, starting from a preexisting "
"serial run (obtained using the LiebLin_DSF executable) using the same model parameters." << endl;
cout << endl << "Provide the following arguments:" << endl << endl;
cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: "
"d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
cout << "DP c_int \t\t Value of the interaction parameter: use positive real values only" << endl;
cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: "
"recommended values: -2*N and 2*N" << endl;
cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
cout << "int Max_Secs \t\t Allowed computational time: (in seconds)" << endl;
cout << "int supercycle_time \t\t time for one supercycle (in seconds)" << endl;
cout << endl << "EXAMPLE: " << endl << endl;
cout << "mpiexec -np 8 LiebLin_DSF_MosesState_par d 1.0 100.0 100 -400 400 0.0 3600 600" << endl << endl;
return(0);
}
else { // (argc == 9) correct nr of arguments
whichDSF = *argv[1];
c_int = atof(argv[2]);
L = atof(argv[3]);
N = atoi(argv[4]);
iKmin = atoi(argv[5]);
iKmax = atoi(argv[6]);
kBT = atof(argv[7]);
Max_Secs = atoi(argv[8]);
supercycle_time = atoi(argv[9]);
}
if (Max_Secs <= supercycle_time) ABACUSerror("Please allow more time in LiebLin_DSF_par.");
MPI::Init(argc, argv);
DP tstart = MPI::Wtime();
int rank = MPI::COMM_WORLD.Get_rank();
int nr_processors = MPI::COMM_WORLD.Get_size();
if (nr_processors < 2) ABACUSerror("Give at least 2 processors to ABACUS parallel !");
refine = true;
// ASSUMPTION: preexisting files (raw, thr, ...) exist for the run.
DP tnow = MPI::Wtime();
string defaultScanStatename = "";
while (tnow - tstart < Max_Secs - supercycle_time - 120) { // space for one more supercycle, + 2 minutes safety
if (rank == 0)
// Split up thread list into chunks, one per processor
Prepare_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
// Barrier synchronization, to make sure other processes wait for process of rank 0
// to have finished splitting up the thr file into pieces before starting:
MPI_Barrier (MPI::COMM_WORLD);
// then everybody gets going on their own chunk !
Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT,
supercycle_time, target_sumrule, refine, rank, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
// Now that everybody is done, digest data into unique files
if (rank == 0)
Wrapup_Parallel_Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, defaultScanStatename, nr_processors);
// Another barrier synchronization
MPI_Barrier (MPI::COMM_WORLD);
tnow = MPI::Wtime();
} // while (tnow - tstart...
MPI::Finalize();
return(0);
}
+1
View File
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
+1
View File
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
#include "mpi.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])
+1
View File
@@ -15,6 +15,7 @@ Purpose: Parallel version of ABACUS using MPICH.
#include "ABACUS.h"
//#include "mpi.h" // not needed for Prepare or Wrapup
using namespace std;
using namespace ABACUS;
int main(int argc, char *argv[])