void SpinBlock::addAdditionalCompOps() { #ifndef SERIAL boost::mpi::communicator world; if (world.size() == 1) return; //there is no need to have additional compops int length = dmrginp.last_site(); int dotopindex = (sites[0] == 0) ? complementary_sites[0] : complementary_sites[complementary_sites.size()-1]; if (!ops[CRE]->is_local()) { for(int i=0; i<get_sites().size(); i++) { if (ops[CRE]->has(sites[i])) { if (processorindex(sites[i]) != mpigetrank()) ops[CRE]->add_local_indices(sites[i]); mpi::broadcast(world, *(ops[CRE]->get_element(sites[i])[0]), processorindex(sites[i])); } } } for (int i=0; i<complementary_sites.size(); i++) { int compsite = complementary_sites[i]; if (compsite == dotopindex) continue; int I = (compsite > dotopindex) ? compsite : dotopindex; int J = (compsite > dotopindex) ? dotopindex : compsite; if (processorindex(compsite) == processorindex(trimap(I, J, length))) continue; if (processorindex(compsite) == mpigetrank()) { bool other_proc_has_ops = true; world.recv(processorindex(trimap(I, J, length)), 0, other_proc_has_ops); //this will potentially receive some ops if (other_proc_has_ops) { ops[CRE_DESCOMP]->add_local_indices(I, J); recvcompOps(*ops[CRE_DESCOMP], I, J, CRE_DESCOMP); ops[DES_DESCOMP]->add_local_indices(I, J); recvcompOps(*ops[DES_DESCOMP], I, J, DES_DESCOMP); } } else { //this will potentially send some ops if (processorindex(trimap(I, J, length)) == mpigetrank()) { bool this_proc_has_ops = ops[CRE_DESCOMP]->has_local_index(I, J); world.send(processorindex(compsite), 0, this_proc_has_ops); if (this_proc_has_ops) { sendcompOps(*ops[CRE_DESCOMP], I, J, CRE_DESCOMP, compsite); sendcompOps(*ops[DES_DESCOMP], I, J, DES_DESCOMP, compsite); } } else continue; } //dmrginp.datatransfer.stop(); //dmrginp.datatransfer -> stop(); //ROA } #endif }
void SpinBlock::addAdditionalCompOps() { #ifndef SERIAL boost::mpi::communicator world; if (world.size() == 1) return; //there is no need to have additional compops int length = dmrginp.last_site(); if (!ops[CRE]->is_local()) { for(int i=0; i<get_sites().size(); i++) { if (ops[CRE]->has(sites[i])) { if (processorindex(sites[i]) != mpigetrank()) ops[CRE]->add_local_indices(sites[i]); ops[CRE]->set_local() = true; mpi::broadcast(world, *(ops[CRE]->get_element(sites[i])[0]), processorindex(sites[i])); } } } if (has(DES)) { if (!ops[DES]->is_local()) { for(int i=0; i<get_sites().size(); i++) { if (ops[DES]->has(sites[i])) { if (processorindex(sites[i]) != mpigetrank()) ops[DES]->add_local_indices(sites[i]); ops[DES]->set_local() = true; mpi::broadcast(world, *(ops[DES]->get_element(sites[i])[0]), processorindex(sites[i])); } } } } if(dmrginp.calc_type() == MPS_NEVPT) { // if ( has(CDD_CRE_DESCOMP)) // if (!ops[CDD_CRE_DESCOMP]->is_local) { // for(int i=0; i<get_sites().size(); i++) { // if (ops[CDD_CRE_DESCOMP]->has(sites[i])) { // if (processorindex(sites[i]) != mpigetrank()) ops[CDD_CRE_DESCOMP]->add_local_indices(sites[i]); // ops[CDD_CRE_DESCOMP]->set_local() = true; // mpi::broadcast(world, *(ops[CDD_CRE_DESCOMP]->get_element(sites[i])[0]), processorindex(sites[i])); // } // } // } return ; } vector<int> dotindice; dotindice.push_back((sites[0] == 0) ? complementary_sites[0] : complementary_sites[complementary_sites.size()-1]); if (!dmrginp.spinAdapted()) { // when non-spinadapted, sites are spin orbitals dotindice.push_back((sites[0] == 0) ? complementary_sites[1] : complementary_sites[complementary_sites.size()-2]); } for (int idx = 0; idx < dotindice.size(); ++idx) { int dotopindex = dotindice[idx]; for (int i=0; i<complementary_sites.size(); i++) { int compsite = complementary_sites[i]; if (std::find(dotindice.begin(), dotindice.end(), compsite) != dotindice.end()) continue; int I = (compsite > dotopindex) ? compsite : dotopindex; int J = (compsite > dotopindex) ? dotopindex : compsite; if (processorindex(compsite) == processorindex(trimap_2d(I, J, length))) continue; if (processorindex(compsite) == mpigetrank()) { //this will potentially receive some ops bool other_proc_has_ops = true; world.recv(processorindex(trimap_2d(I, J, length)), 0, other_proc_has_ops); if (other_proc_has_ops) { ops[CRE_DESCOMP]->add_local_indices(I, J); recvcompOps(*ops[CRE_DESCOMP], I, J, CRE_DESCOMP); } other_proc_has_ops = true; world.recv(processorindex(trimap_2d(I, J, length)), 0, other_proc_has_ops); if (other_proc_has_ops) { ops[DES_DESCOMP]->add_local_indices(I, J); recvcompOps(*ops[DES_DESCOMP], I, J, DES_DESCOMP); } if (has(DES)) { other_proc_has_ops = true; world.recv(processorindex(trimap_2d(I, J, length)), 0, other_proc_has_ops); if (other_proc_has_ops) { ops[CRE_CRECOMP]->add_local_indices(I, J); recvcompOps(*ops[CRE_CRECOMP], I, J, CRE_CRECOMP); } other_proc_has_ops = true; world.recv(processorindex(trimap_2d(I, J, length)), 0, other_proc_has_ops); if (other_proc_has_ops) { ops[DES_CRECOMP]->add_local_indices(I, J); recvcompOps(*ops[DES_CRECOMP], I, J, DES_CRECOMP); } } } else { //this will potentially send some ops if (processorindex(trimap_2d(I, J, length)) == mpigetrank()) { bool this_proc_has_ops = ops[CRE_DESCOMP]->has_local_index(I, J); world.send(processorindex(compsite), 0, this_proc_has_ops); if (this_proc_has_ops) { sendcompOps(*ops[CRE_DESCOMP], I, J, CRE_DESCOMP, compsite); } this_proc_has_ops = ops[DES_DESCOMP]->has_local_index(I, J); world.send(processorindex(compsite), 0, this_proc_has_ops); if (this_proc_has_ops) { sendcompOps(*ops[DES_DESCOMP], I, J, DES_DESCOMP, compsite); } if (has(DES)) { this_proc_has_ops = ops[CRE_CRECOMP]->has_local_index(I, J); world.send(processorindex(compsite), 0, this_proc_has_ops); if (this_proc_has_ops) { sendcompOps(*ops[CRE_CRECOMP], I, J, CRE_CRECOMP, compsite); } this_proc_has_ops = ops[DES_CRECOMP]->has_local_index(I, J); world.send(processorindex(compsite), 0, this_proc_has_ops); if (this_proc_has_ops) { sendcompOps(*ops[DES_CRECOMP], I, J, DES_CRECOMP, compsite); } } } else continue; } } } #endif }