multithreaded mpi

This commit is contained in:
Joachim Schoeberl 2011-07-21 20:52:45 +00:00
parent edd41fbf68
commit 4bd7ba5550
4 changed files with 168 additions and 209 deletions

View File

@ -72,8 +72,13 @@
{ {
bool parthread = netgen::mparam.parthread; bool parthread = netgen::mparam.parthread;
// if (netgen::id > 0) parthread = true; #ifdef PARALLEL
int provided;
MPI_Query_thread(&provided);
if (provided < 3)
if (netgen::ntasks > 1) parthread = false; if (netgen::ntasks > 1) parthread = false;
cout << "runparallel = " << parthread << endl;
#endif
if (parthread) if (parthread)
{ {

View File

@ -65,7 +65,7 @@ int main(int argc, char ** argv)
#ifdef PARALLEL #ifdef PARALLEL
// MPI_Init(&argc, &argv); // MPI_Init(&argc, &argv);
int required = 0; // MPI_THREAD_MULTIPLE; int required = MPI_THREAD_MULTIPLE;
int provided; int provided;
MPI_Init_thread(&argc, &argv, required, &provided); MPI_Init_thread(&argc, &argv, required, &provided);

View File

@ -1148,6 +1148,11 @@ namespace netgen
mesh->SetMinimalH (mparam.minh); mesh->SetMinimalH (mparam.minh);
} }
#ifdef PARALLEL
MyMPI_SendCmd ("bcastparthread");
MyMPI_Bcast (mparam.parthread);
#endif
return TCL_OK; return TCL_OK;
} }

View File

@ -142,13 +142,10 @@ void ParallelRun()
} }
(*NGS_ParallelRun) (message); (*NGS_ParallelRun) (message);
} }
else else if ( message == "mesh" )
if ( message == "mesh" )
{ {
VT_USER_START ("Mesh::ReceiveParallelMesh"); VT_USER_START ("Mesh::ReceiveParallelMesh");
mesh.Reset( new netgen::Mesh); mesh.Reset( new netgen::Mesh);
// mesh->ReceiveParallelMesh();
mesh->SendRecvMesh(); mesh->SendRecvMesh();
VT_USER_END ("Mesh::ReceiveParallelMesh"); VT_USER_END ("Mesh::ReceiveParallelMesh");
} }
@ -161,58 +158,12 @@ void ParallelRun()
else if ( message == "visualize" ) else if ( message == "visualize" )
{ {
cout << "p" << id << ": ACHTUNG - alles wieder zumachen, sonst geht nix mehr :)" << endl; cout << "parallel message visualize depreciated" << endl;
cout << "Tcl-disabled" << endl;
/*
// initialize application
Tcl_Interp * myinterp = Tcl_CreateInterp ();
if (Tcl_AppInit (myinterp) == TCL_ERROR)
{
cerr << "Exit Netgen due to initialization problem" << endl;
exit (1);
} }
string startfile = ngdir + "/libsrc/parallel/ng_parallel.tcl"; else if ( message == "bcastparthread" )
if (verbose)
cout << "Load Tcl-script from " << startfile << endl;
int errcode = Tcl_EvalFile (myinterp, (char*)startfile.c_str());
if (errcode)
{ {
cout << "Error in Tcl-Script:" << endl; MyMPI_Bcast (mparam.parthread);
cout << "result = " << myinterp->result << endl;
cout << "in line " << myinterp->errorLine << endl;
if (myinterp->errorLine == 1)
cout << "\nMake sure to set environment variable NETGENDIR" << endl;
exit (1);
}
// lookup user file formats and insert into format list:
ARRAY<const char*> userformats;
RegisterUserFormats (userformats);
ostringstream fstr;
for (int i = 1; i <= userformats.Size(); i++)
fstr << ".ngmenu.file.filetype add radio -label \""
<< userformats.Get(i) << "\" -variable exportfiletype\n";
Tcl_Eval (myinterp, (char*)fstr.str().c_str());
Tcl_SetVar (myinterp, "exportfiletype", "Neutral Format", 0);
Tk_MainLoop();
Tcl_DeleteInterp (myinterp);
*/
} }
@ -398,9 +349,7 @@ void ParallelRun()
else if ( message == "end" ) else if ( message == "end" )
{ {
// PrintMessage (1, "EXIT");
test = false; test = false;
// end netgen
Ng_Exit(); Ng_Exit();
} }