Commit 5bc2faa5 authored by frey_m's avatar frey_m

PeakFinder: needs to be allreduce without MPI_IN_PLACE

parent a2dad3de
......@@ -262,7 +262,9 @@ bool Probe::checkProbe(PartBunchBase<double, 3> *bunch, const int turnnumber, co
peakfinder_m->addParticle(probepoint, turnnumber);
flagprobed = true;
}
peakfinder_m->evaluate();
if ( bunch->getTotalNum() > 0)
peakfinder_m->evaluate(tempnum);
}
......
......@@ -16,7 +16,6 @@ PeakFinder::PeakFinder(std::string elem, double min,
, turn_m(0)
, peakRadius_m(0.0)
, registered_m(0)
, peaks_m(0)
, singlemode_m(singlemode)
, first_m(true)
, finished_m(false)
......@@ -56,12 +55,20 @@ void PeakFinder::addParticle(const Vector_t& R, const int& turn) {
}
void PeakFinder::evaluate() {
void PeakFinder::evaluate(const unsigned int& localnum) {
bool globFinished = false;
// a core might have no particles, thus, never set finished_m = true
if ( localnum == 0 )
finished_m = true;
if ( !singlemode_m )
allreduce(finished_m, 1, std::logical_or<bool>());
allreduce(finished_m, globFinished, 1, std::logical_and<bool>());
else
globFinished = finished_m;
if ( finished_m ) {
if ( globFinished ) {
this->computeCentroid_m();
// reset
......@@ -81,7 +88,7 @@ void PeakFinder::save() {
fRegisered_m = registered_m;
this->computeCentroid_m();
if ( findPeaks() ) {
if ( !peaks_m.empty() ) {
// only rank 0 will go in here
fn_m = element_m + std::string(".peaks");
......@@ -105,11 +112,6 @@ void PeakFinder::save() {
}
bool PeakFinder::findPeaks() {
return !peaks_m.empty();
}
void PeakFinder::computeCentroid_m() {
double globPeakRadius = 0.0;
int globRegister = 0;
......
......@@ -40,17 +40,12 @@ public:
void addParticle(const Vector_t& R, const int& turn);
/*!
* Evaluate the centroid of a turn
* Evaluate the centroid of a turn.
*/
void evaluate();
void evaluate(const unsigned int& localnum);
void save();
/**
* Single particle peak finder.
*/
bool findPeaks();
private:
// compute global histogram, involves some inter-node communication
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment