Skip to content

Commit

Permalink
Merge pull request #5165 from ye-luo/remove-unused
Browse files Browse the repository at this point in the history
Remove unused code and write code more compact
  • Loading branch information
prckent authored Sep 13, 2024
2 parents 52b684c + d3e5682 commit ef7f291
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/QMCDrivers/WFOpt/QMCCostFunctionBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ void QMCCostFunctionBatched::checkConfigurations(EngineHandle& handle)

for (int inb = 0; inb < num_batches; inb++)
{
int current_batch_size = walkers_per_crowd[crowd_id];
if (inb == num_batches - 1)
current_batch_size = final_batch_size;
const int current_batch_size = inb == num_batches - 1 ? final_batch_size : walkers_per_crowd[crowd_id];

const int base_sample_index = inb * walkers_per_crowd[crowd_id] + samples_per_crowd_offsets[crowd_id];

Expand Down Expand Up @@ -487,9 +485,7 @@ void QMCCostFunctionBatched::checkConfigurationsSR(EngineHandle& handle)

for (int inb = 0; inb < num_batches; inb++)
{
int current_batch_size = walkers_per_crowd[crowd_id];
if (inb == num_batches - 1)
current_batch_size = final_batch_size;
const int current_batch_size = inb == num_batches - 1 ? final_batch_size : walkers_per_crowd[crowd_id];

const int base_sample_index = inb * walkers_per_crowd[crowd_id] + samples_per_crowd_offsets[crowd_id];

Expand Down Expand Up @@ -660,8 +656,7 @@ QMCCostFunctionBatched::EffectiveWeight QMCCostFunctionBatched::correlatedSampli
}

//Return_rt wgt_node = 0.0, wgt_node2 = 0.0;
Return_rt wgt_tot = 0.0;
Return_rt wgt_tot2 = 0.0;
Return_rt wgt_tot = 0.0;

// Ensure number of samples did not change after getConfiguration
assert(rank_local_num_samples_ == samples_.getNumSamples());
Expand Down Expand Up @@ -698,11 +693,7 @@ QMCCostFunctionBatched::EffectiveWeight QMCCostFunctionBatched::correlatedSampli

for (int inb = 0; inb < num_batches; inb++)
{
int current_batch_size = walkers_per_crowd[crowd_id];
if (inb == num_batches - 1)
{
current_batch_size = final_batch_size;
}
const int current_batch_size = inb == num_batches - 1 ? final_batch_size : walkers_per_crowd[crowd_id];

const int base_sample_index = inb * walkers_per_crowd[crowd_id] + samples_per_crowd_offsets[crowd_id];

Expand Down Expand Up @@ -820,17 +811,12 @@ QMCCostFunctionBatched::EffectiveWeight QMCCostFunctionBatched::correlatedSampli
compute_all_from_scratch, vmc_or_dmc, needGrad);
// Sum weights over crowds
for (int i = 0; i < opt_eval.size(); i++)
{
wgt_tot += opt_eval[i]->get_wgt();
wgt_tot2 += opt_eval[i]->get_wgt2();
}

//this is MPI barrier
OHMMS::Controller->barrier();
//collect the total weight for normalization and apply maximum weight
myComm->allreduce(wgt_tot);
myComm->allreduce(wgt_tot2);
// app_log()<<"Before Purge"<<wgt_tot<<" "<<wgt_tot2<< std::endl;
Return_rt wgtnorm = (wgt_tot == 0) ? 0 : wgt_tot;
wgt_tot = 0.0;
{
Expand All @@ -843,7 +829,7 @@ QMCCostFunctionBatched::EffectiveWeight QMCCostFunctionBatched::correlatedSampli
}
}
myComm->allreduce(wgt_tot);
// app_log()<<"During Purge"<<wgt_tot<<" "<< std::endl;

wgtnorm = (wgt_tot == 0) ? 1 : 1.0 / wgt_tot;
wgt_tot = 0.0;
{
Expand Down Expand Up @@ -1038,8 +1024,7 @@ QMCCostFunctionBatched::Return_rt QMCCostFunctionBatched::fillHamVec(std::vector
return 1.0;
}

void QMCCostFunctionBatched::calcOvlParmVec(const std::vector<Return_rt>& parm,
std::vector<Return_rt>& ovlParmVec)
void QMCCostFunctionBatched::calcOvlParmVec(const std::vector<Return_rt>& parm, std::vector<Return_rt>& ovlParmVec)
{
ScopedTimer tmp_timer(fill_timer_);

Expand All @@ -1066,7 +1051,7 @@ void QMCCostFunctionBatched::calcOvlParmVec(const std::vector<Return_rt>& parm,
Return_rt weight = saved[REWEIGHT] * wgtinv;
const Return_t* Dsaved = DerivRecords_[iw];
for (int pm = 0; pm < getNumParams(); pm++)
prod[iw] += (Dsaved[pm] - D_avg[pm]) * parm[pm];
prod[iw] += (Dsaved[pm] - D_avg[pm]) * parm[pm];
}


Expand Down

0 comments on commit ef7f291

Please sign in to comment.