Wrote rebalance_load for MPI_Bcast

However, now need 4 configurations for IPhreeqc Debug/Release USE_MPI.



git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@7036 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2012-10-26 00:39:14 +00:00
parent ed73e17fd8
commit d4721e493e
31 changed files with 112 additions and 31 deletions

View File

@ -406,7 +406,7 @@ cxxExchComp::multiply(LDBLE extensive)
this->phase_proportion *= extensive;
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxExchComp::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -106,7 +106,7 @@ class cxxExchComp: public PHRQ_base
void multiply(LDBLE extensive);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -375,7 +375,7 @@ cxxExchange::add(const cxxExchange & addee, LDBLE extensive)
}
this->pitzer_exchange_gammas = addee.pitzer_exchange_gammas;
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
/* ---------------------------------------------------------------------- */
void
cxxExchange::mpi_pack(std::vector < int >&ints,

View File

@ -47,7 +47,7 @@ public:
const cxxNameDouble & Get_totals() const;
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -520,7 +520,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxGasPhase::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -33,7 +33,7 @@ class cxxGasPhase:public cxxNumKeyword
void read_raw(CParser & parser, bool check = true);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -282,7 +282,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxKineticsComp::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -52,7 +52,7 @@ public:
const std::vector < LDBLE > &Get_d_params(void)const {return d_params;};
std::vector < std::string > &Get_c_params(void) {return c_params;};
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
#endif

View File

@ -589,7 +589,7 @@ cxxNameDouble::sort_second(void)
return myvec;
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxNameDouble::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -54,10 +54,11 @@ class cxxNameDouble:public
{
(*this)[str] = d;
}
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_pack(int *ints, int *ii, LDBLE *doubles, int *dd);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif
enum ND_TYPE type;

View File

@ -234,7 +234,7 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
/* ---------------------------------------------------------------------- */
void
cxxPPassemblage::mpi_pack(std::vector < int >&ints,

View File

@ -49,7 +49,7 @@ class cxxPPassemblage:public cxxNumKeyword
void Set_new_def(bool tf) {this->new_def = tf;}
cxxPPassemblageComp *Find(const std::string name);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -312,7 +312,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxPPassemblageComp::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -62,7 +62,7 @@ class cxxPPassemblageComp: public PHRQ_base
void add(const cxxPPassemblageComp & comp, LDBLE extensive);
void multiply(LDBLE extensive);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

2
SS.cxx
View File

@ -443,7 +443,7 @@ cxxSS::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxSS::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

2
SS.h
View File

@ -58,7 +58,7 @@ class cxxSS: public PHRQ_base
return (this->totals);
};
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -223,7 +223,7 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
break;
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
/* ---------------------------------------------------------------------- */
void
cxxSSassemblage::mpi_pack(std::vector < int >&ints,

View File

@ -32,7 +32,7 @@ public:
void read_raw(CParser & parser, bool check = true);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -247,7 +247,7 @@ cxxSScomp::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxSScomp::mpi_pack(std::vector < int >&ints,
std::vector < double >&doubles)

View File

@ -45,7 +45,7 @@ class cxxSScomp: public PHRQ_base
void multiply(double extensive);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif

View File

@ -1326,7 +1326,7 @@ cxxSolution::Get_master_activity(char *string) const
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
/* ---------------------------------------------------------------------- */
void
cxxSolution::mpi_pack(std::vector < int >&ints,

View File

@ -106,7 +106,7 @@ class cxxSolution:public cxxNumKeyword
void Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, const cxxNameDouble &nd);
void Update_activities(const cxxNameDouble &original_tot);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
void mpi_send(int task_number);

View File

@ -998,7 +998,7 @@ cxxStorageBin::cxxStorageBin2system(Phreeqc * phreeqc_ptr, int n)
}
#endif
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxStorageBin::mpi_send(int n, int task_number)
{
@ -1581,3 +1581,83 @@ cxxStorageBin::Set_System(int i)
this->system.Set_Pressure(Utilities::Rxn_find(this->Pressures, i));
}
}
#ifdef USE_MPI
void
cxxStorageBin::mpi_send(int n, int task_number)
{
//
// Send data for system n to task_number
//
std::ostringstream raw_stream;
// Solution
if (this->Get_Solution(n) != NULL)
{
this->Get_Solution(n)->dump_raw(raw_stream, 0);
}
// Exchanger
if (this->Get_Exchange(n) != NULL)
{
this->Get_Exchange(n)->dump_raw(raw_stream, 0);
}
// GasPhase
if (this->Get_GasPhase(n) != NULL)
{
this->Get_GasPhase(n)->dump_raw(raw_stream, 0);
}
// Kinetics
if (this->Get_Kinetics(n) != NULL)
{
this->Get_Kinetics(n)->dump_raw(raw_stream, 0);
}
// PPassemblages
if (this->Get_PPassemblage(n) != NULL)
{
this->Get_PPassemblage(n)->dump_raw(raw_stream, 0);
}
// SSassemblages
if (this->Get_SSassemblage(n) != NULL)
{
this->Get_SSassemblage(n)->dump_raw(raw_stream, 0);
}
// Surfaces
if (this->Get_Surface(n) != NULL)
{
this->Get_Surface(n)->dump_raw(raw_stream, 0);
}
// Send string
int size = raw_stream.str().size();
MPI_Send(&size, 1, MPI_INT, task_number, 0, MPI_COMM_WORLD);
MPI_Send((void *) raw_stream.str().c_str(), size, MPI_CHARACTER, task_number, 0, MPI_COMM_WORLD);
}
void
cxxStorageBin::mpi_recv(int task_number)
{
//
// Recieve raw data from task_number
//
MPI_Status mpi_status;
int size;
MPI_Recv(&size, 1, MPI_INT, task_number, 0, MPI_COMM_WORLD, &mpi_status);
std::vector<char> raw_buffer;
raw_buffer.resize(size + 1);
MPI_Recv((void *) raw_buffer.data(), size, MPI_CHARACTER, task_number, 0, MPI_COMM_WORLD, &mpi_status);
raw_buffer[size] = '\0';
std::istringstream raw_stream(raw_buffer.data());
CParser parser(raw_stream);
parser.set_echo_file(CParser::EO_NONE);
parser.set_echo_stream(CParser::EO_NONE);
this->read_raw(parser);
}
#endif

View File

@ -584,7 +584,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->Sort_comps();
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
/* ---------------------------------------------------------------------- */
void
cxxSurface::mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles)

View File

@ -39,7 +39,7 @@ public:
const cxxSurfaceCharge *Find_charge(const std::string str)const;
void Sort_comps();
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -374,7 +374,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxSurfaceCharge::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -75,7 +75,7 @@ public:
void add(const cxxSurfaceCharge & comp, LDBLE extensive);
void multiply(LDBLE extensive);
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -356,7 +356,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxSurfaceComp::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -47,7 +47,7 @@ public:
const std::string &Get_master_element() const {return this->master_element;}
void Set_master_element(const char * f) {this->master_element = f ? f : "";}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
#endif

View File

@ -447,7 +447,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
}
}
}
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void
cxxKinetics::mpi_pack(std::vector < int >&ints,
std::vector < LDBLE >&doubles)

View File

@ -53,7 +53,7 @@ class cxxKinetics:public cxxNumKeyword
cxxKineticsComp * Find(const std::string &str);
LDBLE Current_step(const bool incremental_reactions, const int reaction_step) const;
#ifdef USE_MPI
#ifdef USE_MPI_SKIP
void mpi_unpack(int *ints, int *ii, LDBLE *doubles, int *dd);
void mpi_pack(std::vector < int >&ints, std::vector < LDBLE >&doubles);
#endif