// // compute_a_gebc_abs1.cc // // Copyright (C) 2004 Edward Valeev // // Author: Edward Valeev // Maintainer: EV // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace sc; #define PRINT_R12_INTERMED 0 void R12IntEval::abs1_contrib_to_VXB_gebc_() { if (evaluated_) return; LinearR12::ABSMethod abs_method = r12info_->abs_method(); Ref msg = r12info_->msg(); Ref mem = r12info_->mem(); Ref thr = r12info_->thr(); const int num_te_types = 4; enum te_types {eri=0, r12=1, r12t1=2, r12t2=3}; tim_enter("mp2-r12a intermeds"); int me = msg->me(); int nproc = msg->n(); ExEnv::out0() << endl << indent << "Entered ABS A (GEBC) intermediates evaluator" << endl; ExEnv::out0() << incindent; // Do the AO->MO transform Ref tfactory = r12info_->tfactory(); tfactory->set_spaces(r12info_->act_occ_space(),r12info_->occ_space(), r12info_->act_occ_space(),r12info_->ribs_space()); Ref ikjy_tform = tfactory->twobody_transform_13("(ik|jy)"); ikjy_tform->set_num_te_types(num_te_types); ikjy_tform->compute(); Ref ijky_acc = ikjy_tform->ints_acc(); if (num_te_types != ijky_acc->num_te_types()) throw std::runtime_error("R12IntEval::obs_contrib_to_VXB_gebc() -- number of MO integral types is wrong"); const int nocc = r12info_->nocc(); const int noso_ri = r12info_->ribs_space()->rank(); /*-------------------------------- Compute MP2-R12/A intermediates and collect on node0 --------------------------------*/ ExEnv::out0() << indent << "Begin computation of intermediates" << endl; tim_enter("intermediates"); SpatialMOPairIter_eq ij_iter(r12info_->act_occ_space()); SpatialMOPairIter_eq kl_iter(r12info_->act_occ_space()); int naa = ij_iter.nij_aa(); // Number of alpha-alpha pairs (i > j) int nab = ij_iter.nij_ab(); // Number of alpha-beta pairs if (debug_) { ExEnv::out0() << indent << "naa = " << naa << endl; ExEnv::out0() << indent << "nab = " << nab << endl; } // Compute intermediates if (debug_) ExEnv::out0() << indent << "Ready to compute MP2-R12/A (GEBC) intermediates" << endl; // Compute the number of tasks that have full access to the integrals // and split the work among them vector proc_with_ints; int nproc_with_ints = tasks_with_ints_(ijky_acc,proc_with_ints); ////////////////////////////////////////////////////////////// // // Evaluation of the intermediates proceeds as follows: // // loop over batches of kl, k >= l, 0<=k,l=j, 0<=i,jhas_access(me)) { for(kl_iter.start();int(kl_iter);kl_iter.next()) { const int kl = kl_iter.ij(); // Figure out if this task will handle this kl int kl_proc = kl%nproc_with_ints; if (kl_proc != proc_with_ints[me]) continue; const int k = kl_iter.i(); const int l = kl_iter.j(); const int kl_aa = kl_iter.ij_aa(); const int kl_ab = kl_iter.ij_ab(); const int lk_ab = kl_iter.ij_ba(); if (debug_) ExEnv::outn() << indent << "task " << me << ": working on (k,l) = " << k << "," << l << " " << endl; // Get (|1/r12|), (|r12|), (|[r12,T1]|), and (|[r12,T2]|) integrals tim_enter("MO ints retrieve"); double *klox_buf_eri = ijky_acc->retrieve_pair_block(k,l,R12IntsAcc::eri); double *klox_buf_r12 = ijky_acc->retrieve_pair_block(k,l,R12IntsAcc::r12); double *klox_buf_r12t1 = ijky_acc->retrieve_pair_block(k,l,R12IntsAcc::r12t1); double *klox_buf_r12t2 = ijky_acc->retrieve_pair_block(k,l,R12IntsAcc::r12t2); double *lkox_buf_eri = ijky_acc->retrieve_pair_block(l,k,R12IntsAcc::eri); double *lkox_buf_r12 = ijky_acc->retrieve_pair_block(l,k,R12IntsAcc::r12); double *lkox_buf_r12t1 = ijky_acc->retrieve_pair_block(l,k,R12IntsAcc::r12t1); double *lkox_buf_r12t2 = ijky_acc->retrieve_pair_block(l,k,R12IntsAcc::r12t2); tim_exit("MO ints retrieve"); if (debug_) ExEnv::outn() << indent << "task " << me << ": obtained kl blocks" << endl; // to avoid every task hitting same ij at the same time, stagger ij-accesses, i.e. each kl task will start with ij=kl+1 for(ij_iter.start(kl+1);int(ij_iter);ij_iter.next()) { const int i = ij_iter.i(); const int j = ij_iter.j(); const int ij_aa = ij_iter.ij_aa(); const int ij_ab = ij_iter.ij_ab(); const int ji_ab = ij_iter.ij_ba(); if (debug_) ExEnv::outn() << indent << "task " << me << ": (k,l) = " << k << "," << l << ": (i,j) = " << i << "," << j << endl; tim_enter("MO ints retrieve"); double *ijox_buf_r12 = ijky_acc->retrieve_pair_block(i,j,R12IntsAcc::r12); double *jiox_buf_r12 = ijky_acc->retrieve_pair_block(j,i,R12IntsAcc::r12); tim_exit("MO ints retrieve"); if (debug_) ExEnv::outn() << indent << "task " << me << ": obtained ij blocks" << endl; tim_enter("MO ints contraction"); double Vaa_ijkl, Vab_ijkl, Vab_jikl, Vab_ijlk, Vab_jilk; double Xaa_ijkl, Xab_ijkl, Xab_jikl, Xab_ijlk, Xab_jilk; double Taa_ijkl, Tab_ijkl, Tab_jikl, Tab_ijlk, Tab_jilk; Vaa_ijkl = Vab_ijkl = Vab_jikl = Vab_ijlk = Vab_jilk = 0.0; Xaa_ijkl = Xab_ijkl = Xab_jikl = Xab_ijlk = Xab_jilk = 0.0; Taa_ijkl = Tab_ijkl = Tab_jikl = Tab_ijlk = Tab_jilk = 0.0; for(int o=0;orelease_pair_block(i,j,R12IntsAcc::r12); ijky_acc->release_pair_block(j,i,R12IntsAcc::r12); } ijky_acc->release_pair_block(k,l,R12IntsAcc::eri); ijky_acc->release_pair_block(k,l,R12IntsAcc::r12); ijky_acc->release_pair_block(k,l,R12IntsAcc::r12t1); ijky_acc->release_pair_block(k,l,R12IntsAcc::r12t2); ijky_acc->release_pair_block(l,k,R12IntsAcc::eri); ijky_acc->release_pair_block(l,k,R12IntsAcc::r12); ijky_acc->release_pair_block(l,k,R12IntsAcc::r12t1); ijky_acc->release_pair_block(l,k,R12IntsAcc::r12t2); } } // Tasks that don't do any work here still need to create these timers tim_enter("MO ints retrieve"); tim_exit("MO ints retrieve"); tim_enter("MO ints contraction"); tim_exit("MO ints contraction"); tim_exit("intermediates"); ExEnv::out0() << indent << "End of computation of intermediates" << endl; ijky_acc->deactivate(); // Symmetrize B intermediate for(int ij=0;ijget_element(ij,kl) + Baa_->get_element(kl,ij)); Baa_->set_element(ij,kl,belem); Baa_->set_element(kl,ij,belem); } for(int ij=0;ijget_element(ij,kl) + Bab_->get_element(kl,ij)); Bab_->set_element(ij,kl,belem); Bab_->set_element(kl,ij,belem); } globally_sum_intermeds_(); ExEnv::out0() << decindent; ExEnv::out0() << indent << "Exited ABS A (GEBC) intermediates evaluator" << endl; tim_exit("mp2-r12a intermeds"); checkpoint_(); } //////////////////////////////////////////////////////////////////////////// // Local Variables: // mode: c++ // c-file-style: "CLJ-CONDENSED" // End: