Skip to content

Commit

Permalink
Replace 'master-slave' pattern names by 'root-worker' [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Mar 26, 2024
1 parent b5df7cc commit 6439c42
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 48 deletions.
22 changes: 11 additions & 11 deletions exputil/localmpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
//
// MPI variables
//
MPI_Comm MPI_COMM_SLAVE;
MPI_Group world_group, slave_group;
int numprocs=1, slaves, myid=0, proc_namelen;
MPI_Comm MPI_COMM_WORKER;
MPI_Group world_group, worker_group;
int numprocs=1, workers, myid=0, proc_namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
std::ofstream mpi_debug;

Expand All @@ -29,18 +29,18 @@ void local_init_mpi(int argc, char **argv)
MPI_Get_processor_name(processor_name, &proc_namelen);

//=========================
// Make SLAVE communicator
// Make WORKER communicator
//=========================

slaves = numprocs - 1;
workers = numprocs - 1;

if (slaves) {
if (workers) {
MPI_Comm_group(MPI_COMM_WORLD, &world_group);
std::vector<int> nslaves (slaves);
std::vector<int> nworkers (workers);

for (int n=1; n<numprocs; n++) nslaves[n-1] = n;
MPI_Group_incl(world_group, slaves, &nslaves[0], &slave_group);
MPI_Comm_create(MPI_COMM_WORLD, slave_group, &MPI_COMM_SLAVE);
for (int n=1; n<numprocs; n++) nworkers[n-1] = n;
MPI_Group_incl(world_group, workers, &nworkers[0], &worker_group);
MPI_Comm_create(MPI_COMM_WORLD, worker_group, &MPI_COMM_WORKER);
}

//=========================
Expand Down Expand Up @@ -68,7 +68,7 @@ void local_init_mpi(int argc, char **argv)
<< " | " << std::setw(8) << getpid();

if (n) {
int m; MPI_Group_rank ( slave_group, &m );
int m; MPI_Group_rank ( worker_group, &m );
std::cout << " | " << std::setw(10) << "WORKER " << m << std::endl;
} else {
std::cout << " | " << std::setw(10) << "ROOT" << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions include/localmpi.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <iomanip>
#include <string>

extern MPI_Comm MPI_COMM_SLAVE;
extern MPI_Group world_group, slave_group;
extern int numprocs, slaves, myid, proc_namelen;
extern MPI_Comm MPI_COMM_WORKER;
extern MPI_Group world_group, worker_group;
extern int numprocs, workers, myid, proc_namelen;
extern char processor_name[MPI_MAX_PROCESSOR_NAME];
extern std::ofstream mpi_debug;

Expand Down
12 changes: 6 additions & 6 deletions src/Component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ void Component::read_bodies_and_distribute_binary_spl(istream *in)
in->read((char*)&number, sizeof(int));
} catch (...) {
std::ostringstream sout;
sout << "Error reading magic info and file count from master";
sout << "Error reading magic info and file count from root";
throw GenericError(sout.str(), __FILE__, __LINE__, 1010, true);
}

Expand Down Expand Up @@ -2116,7 +2116,7 @@ PartPtr * Component::get_particles(int* number)
for (auto it=itb; it!=ite; it++) pbuf[icount++] = it->second;

#ifdef DEBUG
std::cout << "get_particles: master loaded "
std::cout << "get_particles: root loaded "
<< icount << " of its own particles"
<< ", beg=" << beg << ", iend=" << end
<< ", dist=" << std::distance(itb, ite)
Expand All @@ -2133,7 +2133,7 @@ PartPtr * Component::get_particles(int* number)
while (PartPtr part=pf->RecvParticle()) pbuf[icount++] = part;
#ifdef DEBUG
std::cout << "Process " << myid
<< ": received " << icount << " particles from Slave " << node
<< ": received " << icount << " particles from Worker " << node
<< ", expected " << number << ", total=" << totals[node]
<< std::endl << std::flush;
#endif
Expand All @@ -2145,7 +2145,7 @@ PartPtr * Component::get_particles(int* number)
curcount++;
counter++;
}
// Nodes send particles to master
// Nodes send particles to root
} else if (myid == node) {

auto itb = particles.begin();
Expand All @@ -2163,7 +2163,7 @@ PartPtr * Component::get_particles(int* number)

#ifdef DEBUG
std::cout << "Process " << myid
<< ": sent " << icount << " particles from Slave " << node
<< ": sent " << icount << " particles from Worker " << node
<< std::endl << std::flush;
#endif
}
Expand Down Expand Up @@ -3353,7 +3353,7 @@ int Component::round_up(double dnumb)

void Component::setup_distribution(void)
{
// Needed for both master and slaves
// Needed for both root and workers
nbodies_index = vector<unsigned int>(numprocs);
nbodies_table = vector<unsigned int>(numprocs);

Expand Down
12 changes: 6 additions & 6 deletions src/Orient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Orient::Orient(int n, int nwant, unsigned Oflg, unsigned Cflg,
int in_ok;
std::vector<double> in1(4), in2(4);

if (myid==0) { // Master does the reading
if (myid==0) { // Root does the reading

ifstream in(logfile.c_str());

Expand Down Expand Up @@ -115,7 +115,7 @@ Orient::Orient(int n, int nwant, unsigned Oflg, unsigned Cflg,
double time;
int tused;

in_ok = 1; // Signal slave: OK
in_ok = 1; // Signal worker: OK

MPI_Bcast(&in_ok, 1, MPI_INT, 0, MPI_COMM_WORLD);

Expand Down Expand Up @@ -176,12 +176,12 @@ Orient::Orient(int n, int nwant, unsigned Oflg, unsigned Cflg,
if (restart)
cout << " -- Orient: cached time=" << time << " Ecurr= " << Ecurr << endl;

cout << " -- Orient: axis master (cache size=" << sumsA.size() << "): "
cout << " -- Orient: axis root (cache size=" << sumsA.size() << "): "
<< axis[0] << ", "
<< axis[1] << ", "
<< axis[2] << endl;

cout << " -- Orient: center master (cache size=" << sumsC.size() << "): "
cout << " -- Orient: center root (cache size=" << sumsC.size() << "): "
<< center[0] << ", "
<< center[1] << ", "
<< center[2] << endl;
Expand Down Expand Up @@ -212,7 +212,7 @@ Orient::Orient(int n, int nwant, unsigned Oflg, unsigned Cflg,

} else {

in_ok = 0; // Signal slave: NO VALUES
in_ok = 0; // Signal worker: NO VALUES

MPI_Bcast(&in_ok, 1, MPI_INT, 0, MPI_COMM_WORLD);

Expand Down Expand Up @@ -261,7 +261,7 @@ Orient::Orient(int n, int nwant, unsigned Oflg, unsigned Cflg,

} else {

// Get state from Master
// Get state from Root

MPI_Bcast(&in_ok, 1, MPI_INT, 0, MPI_COMM_WORLD);

Expand Down
4 changes: 2 additions & 2 deletions src/end.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ void clean_up(void)
<< "Process " << setw(4) << right << myid
<< " on " << processor_name
<< " pid=" << getpid()
<< " MASTER NODE\t Exiting EXP\n";
<< " ROOT NODE\t Exiting EXP\n";
MPI_Barrier(MPI_COMM_WORLD);
for (int j=1; j<numprocs; j++) {
if (myid==j) cerr << "Process " << setw(4) << right << myid
<< " on " << processor_name
<< " pid=" << getpid()
<< " rank in SLAVE: " << j << "\t Exiting EXP\n";
<< " rank in WORKER: " << j << "\t Exiting EXP\n";
MPI_Barrier(MPI_COMM_WORLD);
}

Expand Down
28 changes: 14 additions & 14 deletions src/expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ main(int argc, char** argv)
char hdbuffer[hdbufsize];
bool final_cmd = false;

int *nslaves, n, retdir, retdir0;
MPI_Group world_group, slave_group;
int *nworkers, n, retdir, retdir0;
MPI_Group world_group, worker_group;
MPI_Errhandler errhandler;

//===================
Expand All @@ -192,23 +192,23 @@ main(int argc, char** argv)
MPI_Comm_set_errhandler(MPI_COMM_WORLD, errhandler);
}

// Make SLAVE group
#ifdef SLAVE_GROUP
slaves = numprocs - 1;
// Make WORKER group
#ifdef WORKER_GROUP
workers = numprocs - 1;
MPI_Comm_group(MPI_COMM_WORLD, &world_group);
nslaves = new int [slaves];
if (!nslaves) {
cerr << "main: problem allocating <nslaves>\n";
nworkers = new int [workers];
if (!nworkers) {
cerr << "main: problem allocating <nworkers>\n";
MPI_Finalize();
exit(10);
}
for (n=1; n<numprocs; n++) nslaves[n-1] = n;
MPI_Group_incl(world_group, slaves, nslaves, &slave_group);
MPI_Comm_create(MPI_COMM_WORLD, slave_group, &MPI_COMM_SLAVE);
delete [] nslaves;
for (n=1; n<numprocs; n++) nworkers[n-1] = n;
MPI_Group_incl(world_group, workers, nworkers, &worker_group);
MPI_Comm_create(MPI_COMM_WORLD, worker_group, &MPI_COMM_WORKER);
delete [] nworkers;

// Debug id
MPI_Group_rank ( slave_group, &n );
MPI_Group_rank ( worker_group, &n );
if (myid==0) cerr << setfill('-') << setw(70) << "-" << endl
<< setfill(' ')
<< "Process " << setw(4) << right << myid
Expand All @@ -222,7 +222,7 @@ main(int argc, char** argv)
if (myid==j) cerr << "Process " << setw(4) << right << myid
<< " on " << processor_name
<< " pid=" << getpid()
<< " rank in SLAVE: " << j << "\t Ready to go!\n";
<< " rank in WORKER: " << j << "\t Ready to go!\n";
MPI_Barrier(MPI_COMM_WORLD);
}
if (myid==0) cerr << setfill('-') << setw(70) << "-" << endl
Expand Down
4 changes: 2 additions & 2 deletions src/global.H
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ extern int dump_signal0;
//! Used to flag separate behavior on inintialization (unused)
extern int is_init;

//! Internally defined slave communicator
extern MPI_Comm MPI_COMM_SLAVE;
//! Internally defined worker communicator
extern MPI_Comm MPI_COMM_WORKER;

//! List of host names and ranks
extern std::map<std::string, std::vector<int> > nameMap;
Expand Down
2 changes: 1 addition & 1 deletion utils/SL/cyltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int main(int argc, char** argv)
// |
// Turn on diagnostic output in SL creation---------------------------+

// Slaves exit
// Workers exit
if (use_mpi && myid>0) {
MPI_Finalize();
exit(0);
Expand Down
2 changes: 1 addition & 1 deletion utils/SL/qtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main(int argc, char** argv)
// |
// Turn on diagnostic output in SL creation---------------------------------+

// Slaves exit
// Workers exit
if (use_mpi && myid>0) {
MPI_Finalize();
exit(0);
Expand Down
2 changes: 1 addition & 1 deletion utils/SL/slcheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int main(int argc, char** argv)
}
bad = true;
}
// Slaves exit
// Workers exit
if (use_mpi && myid>0) {
MPI_Finalize();
exit(0);
Expand Down
2 changes: 1 addition & 1 deletion utils/Test/test_barrier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char **argv)
// MPI preliminaries
//--------------------------------------------------

int numprocs, slaves, myid, proc_namelen;
int numprocs, myid, proc_namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];

MPI_Init(&argc, &argv);
Expand Down

0 comments on commit 6439c42

Please sign in to comment.