mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-13 06:30:34 +05:00
multithreaded mpi
This commit is contained in:
parent
edd41fbf68
commit
4bd7ba5550
@ -72,8 +72,13 @@
|
|||||||
{
|
{
|
||||||
bool parthread = netgen::mparam.parthread;
|
bool parthread = netgen::mparam.parthread;
|
||||||
|
|
||||||
// if (netgen::id > 0) parthread = true;
|
#ifdef PARALLEL
|
||||||
if (netgen::ntasks > 1) parthread = false;
|
int provided;
|
||||||
|
MPI_Query_thread(&provided);
|
||||||
|
if (provided < 3)
|
||||||
|
if (netgen::ntasks > 1) parthread = false;
|
||||||
|
cout << "runparallel = " << parthread << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (parthread)
|
if (parthread)
|
||||||
{
|
{
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,253 +142,204 @@ void ParallelRun()
|
|||||||
}
|
}
|
||||||
(*NGS_ParallelRun) (message);
|
(*NGS_ParallelRun) (message);
|
||||||
}
|
}
|
||||||
else
|
else if ( message == "mesh" )
|
||||||
|
{
|
||||||
|
VT_USER_START ("Mesh::ReceiveParallelMesh");
|
||||||
|
mesh.Reset( new netgen::Mesh);
|
||||||
|
mesh->SendRecvMesh();
|
||||||
|
VT_USER_END ("Mesh::ReceiveParallelMesh");
|
||||||
|
}
|
||||||
|
|
||||||
if ( message == "mesh" )
|
else if ( message == "overlap++" )
|
||||||
{
|
{
|
||||||
VT_USER_START ("Mesh::ReceiveParallelMesh");
|
PrintMessage (1, "overlap++++++");
|
||||||
mesh.Reset( new netgen::Mesh);
|
mesh -> UpdateOverlap();
|
||||||
// mesh->ReceiveParallelMesh();
|
}
|
||||||
mesh->SendRecvMesh();
|
|
||||||
VT_USER_END ("Mesh::ReceiveParallelMesh");
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ( message == "overlap++" )
|
else if ( message == "visualize" )
|
||||||
{
|
{
|
||||||
PrintMessage (1, "overlap++++++");
|
cout << "parallel message visualize depreciated" << endl;
|
||||||
mesh -> UpdateOverlap();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else if ( message == "visualize" )
|
else if ( message == "bcastparthread" )
|
||||||
{
|
{
|
||||||
cout << "p" << id << ": ACHTUNG - alles wieder zumachen, sonst geht nix mehr :)" << endl;
|
MyMPI_Bcast (mparam.parthread);
|
||||||
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";
|
|
||||||
|
|
||||||
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;
|
|
||||||
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);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PARALLELGL
|
#ifdef PARALLELGL
|
||||||
|
|
||||||
else if ( message == "redraw" )
|
else if ( message == "redraw" )
|
||||||
{
|
{
|
||||||
// draw into the same GLX - drawing context
|
// draw into the same GLX - drawing context
|
||||||
// works on parallel machine, but
|
// works on parallel machine, but
|
||||||
// did not manage to get glXImportContextEXT working on Laptop (JS)
|
// did not manage to get glXImportContextEXT working on Laptop (JS)
|
||||||
|
|
||||||
string redraw_cmd;
|
string redraw_cmd;
|
||||||
// MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS);
|
// MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS);
|
||||||
redraw_cmd = MyMPI_RecvCmd();
|
redraw_cmd = MyMPI_RecvCmd();
|
||||||
|
|
||||||
// PrintMessage (1, "Redraw - ", redraw_cmd);
|
// PrintMessage (1, "Redraw - ", redraw_cmd);
|
||||||
|
|
||||||
static string displname;
|
static string displname;
|
||||||
static int curDrawable, contextid;
|
static int curDrawable, contextid;
|
||||||
|
|
||||||
static Display * display = NULL;
|
static Display * display = NULL;
|
||||||
static GLXContext context;
|
static GLXContext context;
|
||||||
static XVisualInfo * visinfo = 0;
|
static XVisualInfo * visinfo = 0;
|
||||||
|
|
||||||
// if (!display)
|
// if (!display)
|
||||||
if (redraw_cmd == "init")
|
if (redraw_cmd == "init")
|
||||||
{
|
{
|
||||||
MyMPI_Recv (displname, 0, MPI_TAG_VIS);
|
MyMPI_Recv (displname, 0, MPI_TAG_VIS);
|
||||||
MyMPI_Recv (curDrawable, 0, MPI_TAG_VIS);
|
MyMPI_Recv (curDrawable, 0, MPI_TAG_VIS);
|
||||||
MyMPI_Recv (contextid, 0, MPI_TAG_VIS);
|
MyMPI_Recv (contextid, 0, MPI_TAG_VIS);
|
||||||
|
|
||||||
|
|
||||||
display = XOpenDisplay (displname.c_str());
|
display = XOpenDisplay (displname.c_str());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PrintMessage (3, "displ - name = ", displname);
|
PrintMessage (3, "displ - name = ", displname);
|
||||||
PrintMessage (3, "display = ", display,
|
PrintMessage (3, "display = ", display,
|
||||||
" display props: ",
|
" display props: ",
|
||||||
" screen w = ", XDisplayWidth (display, 0),
|
" screen w = ", XDisplayWidth (display, 0),
|
||||||
" , h = ", XDisplayHeight (display, 0));
|
" , h = ", XDisplayHeight (display, 0));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Window win;
|
Window win;
|
||||||
int wx, wy;
|
int wx, wy;
|
||||||
unsigned int ww, wh, bw, depth;
|
unsigned int ww, wh, bw, depth;
|
||||||
// cout << "got drawable: " << curDrawable << endl;
|
// cout << "got drawable: " << curDrawable << endl;
|
||||||
|
|
||||||
XGetGeometry(display, curDrawable, &win,
|
XGetGeometry(display, curDrawable, &win,
|
||||||
&wx, &wy, &ww, &wh,
|
&wx, &wy, &ww, &wh,
|
||||||
&bw, &depth);
|
&bw, &depth);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
cout << "P" << id << ": window-props: x = " << wx << ", y = " << wy
|
cout << "P" << id << ": window-props: x = " << wx << ", y = " << wy
|
||||||
<< ", w = " << ww << ", h = " << wh << ", depth = " << depth << endl;
|
<< ", w = " << ww << ", h = " << wh << ", depth = " << depth << endl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VISUAL
|
#define VISUAL
|
||||||
#ifdef VISUAL
|
#ifdef VISUAL
|
||||||
|
|
||||||
// make a new GLXContext
|
// make a new GLXContext
|
||||||
// first, generate a visual (copied from togl)
|
// first, generate a visual (copied from togl)
|
||||||
|
|
||||||
int attrib_list[1000];
|
int attrib_list[1000];
|
||||||
|
|
||||||
# define MAX_ATTEMPTS 12
|
# define MAX_ATTEMPTS 12
|
||||||
static int ci_depths[MAX_ATTEMPTS] = {
|
static int ci_depths[MAX_ATTEMPTS] = {
|
||||||
8, 4, 2, 1, 12, 16, 8, 4, 2, 1, 12, 16
|
8, 4, 2, 1, 12, 16, 8, 4, 2, 1, 12, 16
|
||||||
};
|
};
|
||||||
static int dbl_flags[MAX_ATTEMPTS] = {
|
static int dbl_flags[MAX_ATTEMPTS] = {
|
||||||
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1
|
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* It may take a few tries to get a visual */
|
/* It may take a few tries to get a visual */
|
||||||
|
|
||||||
for (int attempt = 0; attempt < MAX_ATTEMPTS; attempt++)
|
for (int attempt = 0; attempt < MAX_ATTEMPTS; attempt++)
|
||||||
{
|
{
|
||||||
int attrib_count = 0;
|
int attrib_count = 0;
|
||||||
attrib_list[attrib_count++] = GLX_USE_GL;
|
attrib_list[attrib_count++] = GLX_USE_GL;
|
||||||
|
|
||||||
|
|
||||||
/* RGB[A] mode */
|
/* RGB[A] mode */
|
||||||
attrib_list[attrib_count++] = GLX_RGBA;
|
attrib_list[attrib_count++] = GLX_RGBA;
|
||||||
attrib_list[attrib_count++] = GLX_RED_SIZE;
|
attrib_list[attrib_count++] = GLX_RED_SIZE;
|
||||||
attrib_list[attrib_count++] = 1;
|
attrib_list[attrib_count++] = 1;
|
||||||
attrib_list[attrib_count++] = GLX_GREEN_SIZE;
|
attrib_list[attrib_count++] = GLX_GREEN_SIZE;
|
||||||
attrib_list[attrib_count++] = 1;
|
attrib_list[attrib_count++] = 1;
|
||||||
attrib_list[attrib_count++] = GLX_BLUE_SIZE;
|
attrib_list[attrib_count++] = GLX_BLUE_SIZE;
|
||||||
attrib_list[attrib_count++] = 1;
|
attrib_list[attrib_count++] = 1;
|
||||||
// attrib_list[attrib_count++] = GLX_ALPHA_SIZE;
|
// attrib_list[attrib_count++] = GLX_ALPHA_SIZE;
|
||||||
// attrib_list[attrib_count++] = 1;
|
// attrib_list[attrib_count++] = 1;
|
||||||
|
|
||||||
attrib_list[attrib_count++] = GLX_DEPTH_SIZE;
|
attrib_list[attrib_count++] = GLX_DEPTH_SIZE;
|
||||||
attrib_list[attrib_count++] = 1;
|
attrib_list[attrib_count++] = 1;
|
||||||
|
|
||||||
attrib_list[attrib_count++] = GLX_DOUBLEBUFFER;
|
attrib_list[attrib_count++] = GLX_DOUBLEBUFFER;
|
||||||
|
|
||||||
attrib_list[attrib_count++] = None;
|
attrib_list[attrib_count++] = None;
|
||||||
|
|
||||||
visinfo = glXChooseVisual(display, 0,
|
visinfo = glXChooseVisual(display, 0,
|
||||||
attrib_list);
|
attrib_list);
|
||||||
if (visinfo) {
|
if (visinfo) {
|
||||||
/* found a GLX visual! */
|
/* found a GLX visual! */
|
||||||
// cout << "found VISINFO !!!" << endl;
|
// cout << "found VISINFO !!!" << endl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int hi = 0;
|
int hi = 0;
|
||||||
std::cout << "attribs = ";
|
std::cout << "attribs = ";
|
||||||
while (attrib_list[hi] != None)
|
while (attrib_list[hi] != None)
|
||||||
std::cout << attrib_list[hi++] << " ";
|
std::cout << attrib_list[hi++] << " ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!visinfo)
|
}
|
||||||
cerr << "no VISINFO found" << endl;
|
if (!visinfo)
|
||||||
|
cerr << "no VISINFO found" << endl;
|
||||||
|
|
||||||
// context = glXCreateContext( display, visinfo, 0, /* curContext, */ False );
|
// context = glXCreateContext( display, visinfo, 0, /* curContext, */ False );
|
||||||
context = glXCreateContext( display, visinfo, glXImportContextEXT ( display, contextid ), False);
|
context = glXCreateContext( display, visinfo, glXImportContextEXT ( display, contextid ), False);
|
||||||
// cout << "context = " << context << endl;
|
// cout << "context = " << context << endl;
|
||||||
|
|
||||||
glXMakeCurrent (display, curDrawable, context);
|
glXMakeCurrent (display, curDrawable, context);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// try to get GLXcontext from the master.
|
// try to get GLXcontext from the master.
|
||||||
// this needs an indirect context (BUT DOES NOT WORK ????)
|
// this needs an indirect context (BUT DOES NOT WORK ????)
|
||||||
|
|
||||||
context = glXImportContextEXT ( display, contextid );
|
context = glXImportContextEXT ( display, contextid );
|
||||||
|
|
||||||
|
|
||||||
PrintMessage (1, "GLX-contextid = " , contextid,
|
PrintMessage (1, "GLX-contextid = " , contextid,
|
||||||
" imported context ", context);
|
" imported context ", context);
|
||||||
|
|
||||||
|
|
||||||
glXMakeCurrent (display, curDrawable, context);
|
glXMakeCurrent (display, curDrawable, context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PrintMessage (1, "redraw - init complete");
|
// PrintMessage (1, "redraw - init complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw_cmd == "broadcast")
|
if (redraw_cmd == "broadcast")
|
||||||
{
|
{
|
||||||
vsmesh.Broadcast ();
|
vsmesh.Broadcast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw_cmd == "linelist")
|
if (redraw_cmd == "linelist")
|
||||||
{
|
{
|
||||||
// glXMakeCurrent (display, curDrawable, context);
|
// glXMakeCurrent (display, curDrawable, context);
|
||||||
vsmesh.BuildLineList();
|
vsmesh.BuildLineList();
|
||||||
// glXMakeCurrent (display, None, NULL);
|
// glXMakeCurrent (display, None, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw_cmd == "filledlist")
|
if (redraw_cmd == "filledlist")
|
||||||
{
|
{
|
||||||
vsmesh.BuildFilledList (false);
|
vsmesh.BuildFilledList (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (redraw_cmd == "solsurfellist")
|
if (redraw_cmd == "solsurfellist")
|
||||||
{
|
{
|
||||||
vssolution.DrawSurfaceElements();
|
vssolution.DrawSurfaceElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw_cmd == "clipplanetrigs")
|
if (redraw_cmd == "clipplanetrigs")
|
||||||
{
|
{
|
||||||
vssolution.DrawClipPlaneTrigs();
|
vssolution.DrawClipPlaneTrigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw_cmd == "getminmax")
|
if (redraw_cmd == "getminmax")
|
||||||
{
|
{
|
||||||
double hmin, hmax;
|
double hmin, hmax;
|
||||||
vssolution.GetMinMax (-1, -1, hmin, hmax);
|
vssolution.GetMinMax (-1, -1, hmin, hmax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -396,27 +347,25 @@ void ParallelRun()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
else if ( message == "end" )
|
else if ( message == "end" )
|
||||||
{
|
{
|
||||||
// PrintMessage (1, "EXIT");
|
test = false;
|
||||||
test = false;
|
Ng_Exit();
|
||||||
// end netgen
|
}
|
||||||
Ng_Exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PrintMessage ( 1, "received unidentified message '" + message + "'\n");
|
PrintMessage ( 1, "received unidentified message '" + message + "'\n");
|
||||||
|
|
||||||
test = false;
|
test = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user