123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**********************************************************
-
- This software is part of J.-S. Caux's ABACUS library.
-
- Copyright (c) J.-S. Caux.
-
- -----------------------------------------------------------
-
- File: Heis_DSF_par_Run.cc
-
- 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[])
- {
- char whichDSF;
- DP Delta;
- int N, M, iKmin, iKmax, Max_Secs, supercycle_time, paralevel;
- 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 Heis_DSF_par_Run 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 paralevel" << endl;
- cout << "rank[i], nr_processors[i] \t rank and nr_processors of each earlier paralevels." << 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 Heis_DSF_par_Run z 1 128 64 0 128 [**UPDATE]" << endl << endl;
-
- return(0);
- }
-
- //else { // (argc == 9) correct nr of arguments
- int n = 1;
- whichDSF = *argv[n++];
- Delta = atof(argv[n++]);
- N = atoi(argv[n++]);
- M = atoi(argv[n++]);
- iKmin = atoi(argv[n++]);
- iKmax = atoi(argv[n++]);
- paralevel = atoi(argv[n++]); // paralevel == 1 means that we have one layer of parallelization, so no previous rank and nr_processors to specify
- if (argc != 10 + 2*(paralevel - 1)) ABACUSerror("Wrong nr of arguments in Heis_DSF_par_Run.");
- Vect<int> rank_lower_paralevels(paralevel - 1);
- Vect<int> nr_processors_lower_paralevels(paralevel - 1);
- for (int i = 0; i < paralevel - 1; ++i) {
- rank_lower_paralevels[i] = atoi(argv[n++]);
- nr_processors_lower_paralevels[i] = atoi(argv[n++]);
- }
- Max_Secs = atoi(argv[n++]);
- supercycle_time = atoi(argv[n++]);
-
- if (Max_Secs <= supercycle_time) ABACUSerror("Please allow more time in Heis_DSF_par_Run.");
-
- MPI::Init(argc, argv);
-
- DP tstart = MPI::Wtime();
-
- int rank_here = MPI::COMM_WORLD.Get_rank();
- int nr_processors_here = MPI::COMM_WORLD.Get_size();
-
- Vect<int> rank (paralevel);
- Vect<int> nr_processors (paralevel);
- for (int i = 0; i < paralevel - 1; ++i) {
- rank[i] = rank_lower_paralevels[i];
- nr_processors[i] = nr_processors_lower_paralevels[i];
- }
- rank[paralevel-1] = rank_here;
- nr_processors[paralevel-1] = nr_processors_here;
-
- if (nr_processors_here < 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
-
- // 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, paralevel, rank, nr_processors);
-
- // Another barrier synchronization
- MPI_Barrier (MPI::COMM_WORLD);
-
- // Now that everybody is done, digest data into unique files
-
- // Another barrier synchronization
- MPI_Barrier (MPI::COMM_WORLD);
-
- tnow = MPI::Wtime();
-
- } // while (tnow - tstart...
-
- MPI::Finalize();
-
- return(0);
- }
|