@@ -71,6 +71,9 @@ DSRG_MRPT3::DSRG_MRPT3(std::shared_ptr<RDMs> rdms, std::shared_ptr<SCFInfo> scf_
71
71
DSRG_MRPT3::~DSRG_MRPT3 () { cleanup (); }
72
72
73
73
void DSRG_MRPT3::startup () {
74
+ enforce_batching_ = foptions_->get_bool (" DSRG_MRPT3_BATCHED" );
75
+ ignore_memory_errors_ = foptions_->get_bool (" IGNORE_MEMORY_ERRORS" );
76
+
74
77
// lambda to print memory in good-looking unit
75
78
auto to_XB = [](size_t nele, size_t type_size) {
76
79
auto p = to_xb (nele, type_size);
@@ -92,10 +95,6 @@ void DSRG_MRPT3::startup() {
92
95
// memory usage
93
96
mem_total_ = static_cast <int64_t >(0.98 * psi::Process::environment.get_memory ());
94
97
95
- if (foptions_->get_bool (" DSRG_MRPT3_BATCHED" )) {
96
- mem_total_ = 0 ;
97
- }
98
-
99
98
std::vector<std::pair<std::string, std::string>> mem_info{
100
99
{" Memory asigned" , to_XB (mem_total_, 1 )}};
101
100
@@ -110,11 +109,6 @@ void DSRG_MRPT3::startup() {
110
109
B_ = BTF_->build (tensor_type_, " B 3-idx" , {" Lgg" , " LGG" });
111
110
fill_three_index_ints (B_);
112
111
113
- // / B_.iterate([&](const std::vector<size_t>& i, const std::vector<SpinType>&,
114
- // / double& value) {
115
- // // value = ints_->three_integral(i[0], i[1], i[2]);
116
- // });
117
-
118
112
size_t sL = aux_mos_.size ();
119
113
nelement += sL * sg * sg;
120
114
mem_info.push_back ({" Memory used before DSRG" , to_XB (nelement, sizeof (double ))});
@@ -232,22 +226,23 @@ void DSRG_MRPT3::startup() {
232
226
outfile->Printf (" \n %-40s %15s" , str_dim.first .c_str (), str_dim.second .c_str ());
233
227
}
234
228
235
- if (mem_total_ < static_cast <int64_t >(nele_larger * sizeof (double )) and
236
- (not foptions_->get_bool (" IGNORE_MEMORY_WARNINGS" ))) {
229
+ if (mem_total_ < static_cast <int64_t >(nele_larger * sizeof (double ))) {
237
230
outfile->Printf (" \n\n Error: Not enough memory to compute DSRG-MRPT3 energy." );
238
231
outfile->Printf (" \n Minimum memory required: %s\n " ,
239
232
to_XB (nele_larger, sizeof (double )).c_str ());
240
- throw psi::PSIEXCEPTION (" Not enough memory to compute DSRG-MRPT3 energy." );
233
+ if (!ignore_memory_errors_)
234
+ throw psi::PSIEXCEPTION (" Not enough memory to compute DSRG-MRPT3 energy." );
241
235
}
242
236
243
237
// Check memory for dipole moment
244
238
size_t shp = sh * sp;
245
239
size_t saa = sa * sa;
246
240
int64_t mem_dipole = sizeof (double ) * (6 * (sg * sg) + 9 * (shp * shp - saa * saa));
247
- if (mem_total_ < mem_dipole && do_dm_) {
241
+ if (mem_total_ < mem_dipole and do_dm_) {
248
242
outfile->Printf (" \n\n Error: Not enough memory to compute DSRG-MRPT3 dipole." );
249
243
outfile->Printf (" \n Minimum memory required: %s\n " , to_XB (mem_dipole, 1 ).c_str ());
250
- throw psi::PSIEXCEPTION (" Not enough memory to compute DSRG-MRPT3 dipole." );
244
+ if (!ignore_memory_errors_)
245
+ throw psi::PSIEXCEPTION (" Not enough memory to compute DSRG-MRPT3 dipole." );
251
246
}
252
247
}
253
248
@@ -592,7 +587,7 @@ double DSRG_MRPT3::compute_energy_pt3_1() {
592
587
int64_t mem_max = sizeof (double ) * (6 * (shp - saa) + 9 * (shp * shp - saa * saa));
593
588
int64_t mem_min = sizeof (double ) * (6 * (shp - saa) + 3 * (shp * shp - saa * saa));
594
589
595
- if (mem_total_ < mem_min and ( not foptions_-> get_bool ( " IGNORE_MEMORY_WARNINGS " )) ) {
590
+ if (mem_total_ < mem_min and !ignore_memory_errors_ ) {
596
591
throw psi::PSIEXCEPTION (" Not enough memory for compute_energy_pt3_1 in DSRG-MRPT3." );
597
592
} else if (mem_total_ >= mem_max) {
598
593
@@ -2492,8 +2487,8 @@ void DSRG_MRPT3::V_T2_C2_DF(BlockedTensor& B, BlockedTensor& T2, const double& a
2492
2487
sizeof (double ) *
2493
2488
(2 * (p * h - a * a) + 3 * (p * p * h * h - a * a * a * a)); // local memory used in pt3_2
2494
2489
if (mem_total_ < 0 or static_cast <size_t >(mem_total_) < v * v * sizeof (double )) {
2495
- if ( not foptions_-> get_bool ( " IGNORE_MEMORY_WARNINGS " )) {
2496
- outfile-> Printf ( " \n Not enough memory for batching. " );
2490
+ outfile-> Printf ( " \n Not enough memory for batching. " );
2491
+ if (!ignore_memory_errors_) {
2497
2492
throw psi::PSIEXCEPTION (" Not enough memory for batching at DSRG-MRPT3 V_T2_C2_DF." );
2498
2493
}
2499
2494
}
@@ -2645,7 +2640,7 @@ void DSRG_MRPT3::V_T2_C2_DF(BlockedTensor& B, BlockedTensor& T2, const double& a
2645
2640
}
2646
2641
2647
2642
// particle-particle contractions
2648
- if (static_cast <int64_t >(nele_pp_max * sizeof (double )) < mem_total_) {
2643
+ if (static_cast <int64_t >(nele_pp_max * sizeof (double )) < mem_total_ and !enforce_batching_ ) {
2649
2644
2650
2645
// set timer
2651
2646
start_ = std::chrono::system_clock::now ();
@@ -2938,7 +2933,7 @@ void DSRG_MRPT3::V_T2_C2_DF(BlockedTensor& B, BlockedTensor& T2, const double& a
2938
2933
}
2939
2934
2940
2935
// compute exchange part
2941
- if (static_cast <int64_t >(nele_ph_max * sizeof (double )) < mem_total_) {
2936
+ if (static_cast <int64_t >(nele_ph_max * sizeof (double )) < mem_total_ and !enforce_batching_ ) {
2942
2937
start_ = std::chrono::system_clock::now ();
2943
2938
tt1_ = std::chrono::system_clock::to_time_t (start_);
2944
2939
if (profile_print_) {
@@ -3551,8 +3546,9 @@ void DSRG_MRPT3::V_T2_C2_DF_VV(BlockedTensor& B, BlockedTensor& T2, const double
3551
3546
outfile->Printf (" \n Not enough memory for batching tensor "
3552
3547
" H2(%zu * %zu * %zu * %zu)." ,
3553
3548
sh0, sh1, sv, sv);
3554
- throw psi::PSIEXCEPTION (" Not enough memory for batching at "
3555
- " DSRG-MRPT3 V_T2_C2_DF_VV." );
3549
+ if (!ignore_memory_errors_)
3550
+ throw psi::PSIEXCEPTION (" Not enough memory for batching at "
3551
+ " DSRG-MRPT3 V_T2_C2_DF_VV." );
3556
3552
}
3557
3553
3558
3554
// 1st virtual index
@@ -3933,8 +3929,9 @@ void DSRG_MRPT3::V_T2_C2_DF_VC_EX(BlockedTensor& B, BlockedTensor& T2, const dou
3933
3929
outfile->Printf (" \n Not enough memory for batching tensor "
3934
3930
" H2(%zu * %zu * %zu * %zu)." ,
3935
3931
sq, ss, sc, sv);
3936
- throw psi::PSIEXCEPTION (" Not enough memory for batching at DSRG-MRPT3 "
3937
- " V_T2_C2_DF_VC_EX." );
3932
+ if (!ignore_memory_errors_)
3933
+ throw psi::PSIEXCEPTION (" Not enough memory for batching at DSRG-MRPT3 "
3934
+ " V_T2_C2_DF_VC_EX." );
3938
3935
}
3939
3936
3940
3937
// fill the indices of sub virtuals
@@ -4261,8 +4258,9 @@ void DSRG_MRPT3::V_T2_C2_DF_VA_EX(BlockedTensor& B, BlockedTensor& T2, const dou
4261
4258
outfile->Printf (" \n Not enough memory for batching tensor "
4262
4259
" H2(%zu * %zu * %zu * %zu)." ,
4263
4260
sq, ss, sa, sv);
4264
- throw psi::PSIEXCEPTION (" Not enough memory for batching at DSRG-MRPT3 "
4265
- " V_T2_C2_DF_VA_EX." );
4261
+ if (!ignore_memory_errors_)
4262
+ throw psi::PSIEXCEPTION (" Not enough memory for batching at DSRG-MRPT3 "
4263
+ " V_T2_C2_DF_VA_EX." );
4266
4264
}
4267
4265
4268
4266
// fill the indices of sub virtuals
0 commit comments