From 3b402e976b759db9ffa7e72f0b6563b6428689f0 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Wed, 16 Feb 2011 10:12:41 +0100 Subject: [PATCH] MPI: disable/rename processings if they are in conflict --- FDTD/openems_fdtd_mpi.cpp | 59 +++++++++++++++++++++++++++++++++++++++ FDTD/openems_fdtd_mpi.h | 2 ++ openems.h | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/FDTD/openems_fdtd_mpi.cpp b/FDTD/openems_fdtd_mpi.cpp index 92b0b1a..362f6f0 100644 --- a/FDTD/openems_fdtd_mpi.cpp +++ b/FDTD/openems_fdtd_mpi.cpp @@ -20,6 +20,7 @@ #include "FDTD/operator_mpi.h" #include "FDTD/engine_mpi.h" #include "Common/processfields.h" +#include "Common/processintegral.h" #include #include #include @@ -146,6 +147,61 @@ double openEMS_FDTD_MPI::CalcEnergy() return energy; } +bool openEMS_FDTD_MPI::SetupProcessing() +{ + bool ret = openEMS::SetupProcessing(); + + //search for active processings in different processes + size_t numProc = PA->GetNumberOfProcessings(); + int active=0; + bool deactivate = false; + bool rename = false; + for (size_t n=0;nGetProcessing(n); + int isActive = (int)proc->GetEnable(); + //sum of all active processings + MPI_Reduce(&isActive, &active, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + deactivate = false; + rename = false; + if ((m_MyID==0) && (active>1)) //more than one active processing... + { + deactivate = true; //default + if (dynamic_cast(proc)!=NULL) + { + //type is integral processing --> disable! Needs to be fixed! + cerr << "openEMS_FDTD_MPI::SetupProcessing(): Warning: Processing: " << proc->GetName() << " occures multiple times and is being deactivated..." << endl; + deactivate = true; + rename = false; + } + if (dynamic_cast(proc)!=NULL) + { + //type is field processing --> renameing! Needs to be fixed! + cerr << "openEMS_FDTD_MPI::SetupProcessing(): Warning: Processing: " << proc->GetName() << " occures multiple times and is being renamed..." << endl; + deactivate = false; + rename = true; + } + } + //broadcast informations to all + MPI_Bcast(&deactivate, 1, MPI::BOOL, 0, MPI_COMM_WORLD); + MPI_Bcast(&rename, 1, MPI::BOOL, 0, MPI_COMM_WORLD); + if (deactivate) + proc->SetEnable(false); + if (rename) + { + ProcessFields* ProcField = dynamic_cast(proc); + if (ProcField) + { + stringstream name_ss; + name_ss << "ID" << m_MyID << "_" << ProcField->GetName(); + ProcField->SetName(name_ss.str()); + ProcField->SetFilePattern(name_ss.str()); + ProcField->SetFileName(name_ss.str()); + } + } + } +} + void openEMS_FDTD_MPI::RunFDTD() { if (m_engine != EngineType_MPI) @@ -162,6 +218,9 @@ void openEMS_FDTD_MPI::RunFDTD() m_ProcField = new ProcessFields(new Engine_Interface_FDTD(FDTD_Op,FDTD_Eng)); PA->AddProcessing(m_ProcField); + //init processings + PA->InitAll(); + double currE=0; //add all timesteps to end-crit field processing with max excite amplitude diff --git a/FDTD/openems_fdtd_mpi.h b/FDTD/openems_fdtd_mpi.h index 5cfac8d..f59d365 100644 --- a/FDTD/openems_fdtd_mpi.h +++ b/FDTD/openems_fdtd_mpi.h @@ -49,6 +49,8 @@ protected: bool CheckEnergyCalc(); //! Calc energy in all processes and add up double CalcEnergy(); + + virtual bool SetupProcessing(); }; #endif // OPENEMS_FDTD_MPI_H diff --git a/openems.h b/openems.h index dddfe8b..746ec20 100644 --- a/openems.h +++ b/openems.h @@ -101,7 +101,7 @@ protected: bool SetupMaterialStorages(); //! Setup all processings. - bool SetupProcessing(); + virtual bool SetupProcessing(); }; #endif // OPENEMS_H