Skip to content

Commit 9696e4d

Browse files
author
Jun Yang
committed
add total cpu timings across processors; add docs sections and fixes.
1 parent add65f3 commit 9696e4d

19 files changed

+120
-61
lines changed

dmrg.C

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void license() {
7474

7575
namespace SpinAdapted{
7676
Timer globaltimer(false);
77+
double tcpu,twall,ecpu,ewall;
7778
bool DEBUGWAIT = false;
7879
bool DEBUG_MEMORY = false;
7980
bool restartwarm = false;
@@ -398,8 +399,10 @@ int calldmrg(char* input, char* output)
398399
}
399400

400401
cout.rdbuf(backup);
401-
pout << setprecision(3) <<"\n\n\t\t\t BLOCK CPU Time (seconds): " << globaltimer.totalcputime() << endl;
402-
pout << setprecision(3) <<"\t\t\t BLOCK Wall Time (seconds): " << globaltimer.totalwalltime() << endl;
402+
403+
tcpu=globaltimer.totalcputime();twall=globaltimer.totalwalltime();
404+
pout << setprecision(3) <<"\n\n\t\t\t BLOCK CPU Time (seconds): " << tcpu << endl;
405+
pout << setprecision(3) <<"\t\t\t BLOCK Wall Time (seconds): " << twall << endl;
403406

404407
return 0;
405408
}

docs/source/examples.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,4 +672,20 @@ Energy extrapolation:
672672

673673
Starting from *M=500*, use the largest discarded weights and associated sweep energies in the last sweep iteration of each *M* to make linear regression (see the figure above). The extrapolated DMRG sweep energy is -75.728557 a.u.
674674

675+
Further Reading
676+
===============
677+
678+
Some practical questions are often asked such as,
679+
680+
* what sort of molecules can the DMRG be practically applied to?
681+
* what sort of accuracies can be obtained and at what cost? What are the typical sizes of systems (e.g. number
682+
of active orbitals) that can be treated with practical computational resources?
683+
* how do we reason about the accuracy of DMRG calculations for dirent molecules?
684+
* how is a DMRG calculation best specified (e.g. in terms of starting orbitals and their order)?
685+
686+
We provide answers in the following paper from both theoretical reasoning and numerical calculation by applying the DMRG
687+
to a representative set of molecules.
688+
The calculations we describe therein are all run in a completely black-box fashion using the default settings of our ``Block`` code.
689+
690+
* R. Olivares-Amaya, W. Hu, N. Nakatani, S. Sharma, J. Yang and G. K.-L. Chan, J. Chem. Phys. 142, 034102 (2015).
675691

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Welcome to BLOCK's documentation!
1111

1212
`BLOCK` implements the density matrix renormalization group (DMRG) algorithm for quantum chemistry.
1313
The DMRG is a variational wavefunction method. Compared to other quantum chemical methods,
14-
it executionciently describes strong, multi-reference correlation in a large number of active orbitals (occupancies far from 0 or 2).
14+
it efficiently describes strong, multi-reference correlation in a large number of active orbitals (occupancies far from 0 or 2).
1515
The method is also provably optimal for correlation with a one-dimensional topology, that is,
1616
where orbitals are arranged with a chain- or ring-like connectivity.
1717
However, with the possible exception of small molecules, for correlation that is dynamic in character,
@@ -20,7 +20,7 @@ such as coupled cluster theory or multireference configuration interaction.
2020
We recommend the use of the DMRG in problems requiring active spaces too large for
2121
standard complete active space (CAS) techniques. Thus, if you are interested in:
2222

23-
* a CAS-like treatment of low-lying eigenstates in problems with 16-40 active orbitals,
23+
* a CAS-like treatment of low-lying eigenstates in real problems with more than 50 active orbitals,
2424
* or, one-dimensional orbital topologies with up to 100 active orbitals,
2525
* and, standard chemical accuracy (1 kcal/mol in energy differences),
2626

docs/source/overview.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Features
1010
* one-, two-, three- and four-particle density matrices,
1111
* one- and two-particle transition density matrices between two states,
1212
* perturbation methods including NEVPT2 and MPSPT,
13-
* interfaces to the Molpro, ORCA, Q-Chem and Molcas program packages.
13+
* DMRG-SCF and/or DMRG-NEVPT2 interfaces to the Molpro, ORCA, Q-Chem and Molcas program packages.
1414

1515
Calling `Block` as an external function
1616
=======================================
@@ -34,8 +34,9 @@ use of `Block`:
3434
* G. K.-L. Chan and M. Head-Gordon, J. Chem. Phys. 116, 4462 (2002),
3535
* G. K.-L. Chan, J. Chem. Phys. 120, 3172 (2004),
3636
* D. Ghosh, J. Hachmann, T. Yanai, and G. K.-L. Chan, J. Chem. Phys., 128, 144117 (2008),
37-
* S. Sharma and G. K-.L. Chan, J. Chem. Phys. 136, 124121 (2012).
37+
* S. Sharma and G. K-.L. Chan, J. Chem. Phys. 136, 124121 (2012),
38+
* R. Olivares-Amaya, W. Hu, N. Nakatani, S. Sharma, J. Yang and G. K.-L. Chan, J. Chem. Phys. 142, 034102 (2015).
3839

3940
In addition, a useful list of DMRG references relevant to quantum chemistry can be found
40-
in the article above by Sharma and Chan.
41+
in the article above by Sharma and Chan.
4142

global.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ extern bool NonabelianSym;
7373
extern std::vector<int> NPROP;
7474
extern int PROPBITLEN;
7575
extern double NUMERICAL_ZERO;
76+
extern double tcpu,twall,ecpu,ewall;
7677
//extern ifstream* coutbuf;
7778
}
7879
#endif

modules/generate_blocks/sweep.C

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ double SweepGenblock::do_one(SweepParams &sweepParams, const bool &warmUp, const
182182

183183
++sweepParams.set_sweep_iter();
184184

185-
pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << sweeptimer.elapsedcputime() << endl;
186-
pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << sweeptimer.elapsedwalltime() << endl;
185+
ecpu = sweeptimer.elapsedcputime(); ewall = sweeptimer.elapsedwalltime();
186+
pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl;
187+
pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl;
187188

188189
return finalEnergy[0];
189190
}
@@ -252,8 +253,9 @@ void SweepGenblock::do_one(SweepParams &sweepParams, const bool &forward, int st
252253

253254
++sweepParams.set_sweep_iter();
254255

255-
pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << sweeptimer.elapsedcputime() << endl;
256-
pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << sweeptimer.elapsedwalltime() << endl;
256+
ecpu = sweeptimer.elapsedcputime(); ewall = sweeptimer.elapsedwalltime();
257+
pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl;
258+
pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl;
257259

258260
}
259261

modules/npdm/fourpdm_container.C

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ void Fourpdm_container::save_npdms(const int& i, const int& j)
7474
#ifndef SERIAL
7575
world.barrier();
7676
#endif
77-
p3out << "4PDM save full array time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
77+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
78+
p3out << "4PDM save full array time " << ewall << " " << ecpu << endl;
7879

7980
}
8081

@@ -283,18 +284,21 @@ void Fourpdm_container::save_spatial_npdm_binary(const int &i, const int &j)
283284
Sortpdm::partition_data<Sortpdm::index_element>((long)pow(dmrginp.last_site(),8),file,tmpfile);
284285
Sortpdm::externalsort<Sortpdm::index_element>(tmpfile,sortedfile,(long)pow(dmrginp.last_site(),8));
285286
world.barrier();
286-
p3out << "4PDM parallel external sort time " << timer1.elapsedwalltime() << " " << timer1.elapsedcputime() << endl;
287+
ecpu = timer1.elapsedcputime(); ewall = timer1.elapsedwalltime();
288+
p3out << "4PDM parallel external sort time " << ewall << " " << ecpu << endl;
287289
Timer timer;
288290
Sortpdm::mergefile(sortedfile);
289291
world.barrier();
290292
if(mpigetrank()==0) boost::filesystem::rename(sortedfile,finalfile);
291293
boost::filesystem::remove(tmpfile);
292-
p3out << "4PDM merge sorted file time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
294+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
295+
p3out << "4PDM merge sorted file time " << ewall << " " << ecpu << endl;
293296
#else
294297
Timer timer2;
295298
Sortpdm::externalsort<Sortpdm::index_element> (file,finalfile,(long)pow(dmrginp.last_site(),8));
296299
boost::filesystem::remove(file);
297-
p3out << "4PDM external sort time " << timer2.elapsedwalltime() << " " << timer2.elapsedcputime() << endl;
300+
ecpu = timer2.elapsedcputime();ewall=timer2.elapsedwalltime();
301+
p3out << "4PDM external sort time " << ewall << " " << ecpu << endl;
298302
#endif
299303
}
300304
}

modules/npdm/npdm.C

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ void npdm_block_and_decimate( Npdm_driver_base& npdm_driver, SweepParams &sweepP
195195
}
196196

197197
//newSystem.transform_operators(rotateMatrix,rotateMatrixB);
198-
p3out << "NPDM block and decimate and compute elements " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
198+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
199+
p3out << "NPDM block and decimate and compute elements " << ewall << " " << ecpu << endl;
199200

200201
}
201202

@@ -287,7 +288,8 @@ double npdm_do_one_sweep(Npdm_driver_base &npdm_driver, SweepParams &sweepParams
287288
++sweepParams.set_block_iter();
288289
//sweepParams.savestate(forward, system.get_sites().size());
289290

290-
p3out << "NPDM do one site time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
291+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
292+
p3out << "NPDM do one site time " << ewall << " " << ecpu << endl;
291293
}
292294

293295
//for(int j=0;j<nroots;++j)
@@ -308,8 +310,9 @@ double npdm_do_one_sweep(Npdm_driver_base &npdm_driver, SweepParams &sweepParams
308310
// Update the static number of iterations
309311
++sweepParams.set_sweep_iter();
310312

311-
pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << sweeptimer.elapsedcputime() << endl;
312-
pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << sweeptimer.elapsedwalltime() << endl;
313+
ecpu = sweeptimer.elapsedcputime();ewall=sweeptimer.elapsedwalltime();
314+
pout << "\t\t\t Elapsed Sweep CPU Time (seconds): " << setprecision(3) << ecpu << endl;
315+
pout << "\t\t\t Elapsed Sweep Wall Time (seconds): " << setprecision(3) << ewall << endl;
313316

314317
return finalEnergy[0];
315318

@@ -400,7 +403,8 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
400403
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, dmrginp.specificpdm()[0], dmrginp.specificpdm()[1]); //this will generate the cd operators
401404
else abort();
402405
dmrginp.npdm_generate() = false;
403-
p3out << "\t\t\t NPDM SweepGenblock time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
406+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
407+
p3out << "\t\t\t NPDM SweepGenblock time " << ewall << " " << ecpu << endl;
404408
dmrginp.set_fullrestart() = false;
405409

406410
sweepParams = sweep_copy; direction = direction_copy; restartsize = restartsize_copy;
@@ -411,7 +415,8 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
411415
else if (dmrginp.specificpdm().size()==2)
412416
npdm_do_one_sweep(*npdm_driver, sweepParams, false, direction, false, 0,dmrginp.specificpdm()[0],dmrginp.specificpdm()[1]);
413417
else abort();
414-
p3out << "\t\t\t NPDM sweep time " << timerX.elapsedwalltime() << " " << timerX.elapsedcputime() << endl;
418+
ecpu = timerX.elapsedcputime();ewall=timerX.elapsedwalltime();
419+
p3out << "\t\t\t NPDM sweep time " << ewall << " " << ecpu << endl;
415420
return;
416421
}
417422

@@ -427,14 +432,16 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
427432
dmrginp.npdm_generate() = true;
428433
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, state, stateB); //this will generate the cd operators
429434
dmrginp.npdm_generate() = false;
430-
p3out << "\t\t\t NPDM SweepGenblock time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
435+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
436+
p3out << "\t\t\t NPDM SweepGenblock time " << ewall << " " << ecpu << endl;
431437
dmrginp.set_fullrestart() = false;
432438

433439
sweepParams = sweep_copy; direction = direction_copy; restartsize = restartsize_copy;
434440
Timer timerX;
435441
npdm_driver->clear();
436442
npdm_do_one_sweep(*npdm_driver, sweepParams, false, direction, false, 0, state,stateB);
437-
p3out << "\t\t\t NPDM sweep time " << timerX.elapsedwalltime() << " " << timerX.elapsedcputime() << endl;
443+
ecpu = timerX.elapsedcputime();ewall=timerX.elapsedwalltime();
444+
p3out << "\t\t\t NPDM sweep time " << ewall << " " << ecpu << endl;
438445
}
439446
}
440447
}
@@ -446,7 +453,8 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
446453
sweepParams = sweep_copy; direction = direction_copy; restartsize = restartsize_copy;
447454
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, -1, -1); //this will generate the cd operators
448455
dmrginp.npdm_generate() = false;
449-
p3out << "\t\t\t NPDM SweepGenblock time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
456+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
457+
p3out << "\t\t\t NPDM SweepGenblock time " << ewall << " " << ecpu << endl;
450458
dmrginp.set_fullrestart() = false;
451459

452460

@@ -460,7 +468,8 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
460468
Timer timerX;
461469
npdm_driver->clear();
462470
npdm_do_one_sweep(*npdm_driver, sweepParams, false, direction, false, 0, state,stateB);
463-
p3out << "\t\t\t NPDM sweep time " << timerX.elapsedwalltime() << " " << timerX.elapsedcputime() << endl;
471+
ecpu = timerX.elapsedcputime();ewall=timerX.elapsedwalltime();
472+
p3out << "\t\t\t NPDM sweep time " << ewall << " " << ecpu << endl;
464473
}
465474
}
466475

@@ -472,7 +481,8 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
472481
Timer timerX;
473482
npdm_driver->clear();
474483
npdm_do_one_sweep(*npdm_driver, sweepParams, false, direction, false, 0, state,state);
475-
p3out << "\t\t\t NPDM sweep time " << timerX.elapsedwalltime() << " " << timerX.elapsedcputime() << endl;
484+
ecpu = timerX.elapsedcputime();ewall=timerX.elapsedwalltime();
485+
p3out << "\t\t\t NPDM sweep time " << ewall << " " << ecpu << endl;
476486
}
477487
else{
478488
if (npdm_order == NPDM_ONEPDM) SweepOnepdm::do_one(sweepParams, false, direction, false, 0, state);
@@ -516,13 +526,15 @@ void npdm(NpdmOrder npdm_order, bool restartpdm, bool transitionpdm)
516526
SweepGenblock::do_one(sweepParams, false, !direction, false, 0, state, stateB); //this will generate the cd operators
517527
dmrginp.npdm_generate() = false;
518528
dmrginp.set_fullrestart() = false;
519-
p3out << "\t\t\t NPDM SweepGenblock time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
529+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
530+
p3out << "\t\t\t NPDM SweepGenblock time " << ewall << " " << ecpu << endl;
520531

521532
Timer timerX;
522533
npdm_driver->clear();
523534
sweepParams = sweep_copy; direction = direction_copy; restartsize = restartsize_copy;
524535
npdm_do_one_sweep(*npdm_driver, sweepParams, false, direction, false, 0, state,stateB);
525-
p3out << "\t\t\t NPDM sweep time " << timerX.elapsedwalltime() << " " << timerX.elapsedcputime() << endl;
536+
ecpu = timerX.elapsedcputime();ewall=timerX.elapsedwalltime();
537+
p3out << "\t\t\t NPDM sweep time " << ewall << " " << ecpu << endl;
526538
}
527539
}
528540
}

modules/npdm/npdm_driver.C

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ void Npdm_driver::compute_npdm_elements(std::vector<Wavefunction> & wavefunction
719719
loop_over_operator_patterns_store( npdm_patterns, npdm_expectations, big );
720720
#ifndef SERIAL
721721
world.barrier();
722-
p3out << " prepare intermediate time"<< timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
722+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
723+
p3out << " prepare intermediate time"<< ewall << " " << ecpu << endl;
723724
#endif
724725
}
725726

@@ -772,15 +773,9 @@ void Npdm_driver::compute_npdm_elements(std::vector<Wavefunction> & wavefunction
772773
} else {
773774
reduce(world, write_intermediate_time, std::plus<double>(), 0);
774775
}
775-
if (mpigetrank() == 0) {
776-
double sum, sum2;
777-
reduce(world, timer.elapsedwalltime(), sum2, std::plus<double>(), 0);
778-
reduce(world, timer.elapsedcputime(), sum, std::plus<double>(), 0);
779-
p3out << "NPDM compute elements time " << sum << " "<< sum2 << endl;
780-
} else {
781-
reduce(world, timer.elapsedwalltime(), std::plus<double>(), 0);
782-
reduce(world, timer.elapsedcputime(), std::plus<double>(), 0);
783-
}
776+
777+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
778+
p3out << "NPDM compute elements time " << ewall << " "<< ecpu << endl;
784779
#else
785780
p3out << "NPDM compute elements time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
786781
#endif

modules/npdm/onepdm_container.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ void Onepdm_container::save_npdms(const int& i, const int& j)
5252
#ifndef SERIAL
5353
world.barrier();
5454
#endif
55-
p3out << "1PDM save full array time " << timer.elapsedwalltime() << " " << timer.elapsedcputime() << endl;
55+
ecpu = timer.elapsedcputime();ewall=timer.elapsedwalltime();
56+
p3out << "1PDM save full array time " << ewall << " " << ecpu << endl;
5657
}
5758

5859
//-----------------------------------------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)