Merge branch 'par_fixes' into 'master'

Par fixes

- Increased buffer size in send/recv command (needed for sending python files, see ngsolve merge request)
- Fixed mpi-parallel visualization
- Added warning if using direct rendering + mpi (which probably breaks in most cases)

See merge request !10
This commit is contained in:
Joachim Schöberl 2016-11-10 11:55:03 +01:00
commit c6196dcb91
3 changed files with 56 additions and 33 deletions

View File

@ -16,17 +16,17 @@ namespace netgen
void MyMPI_SendCmd (const char * cmd) void MyMPI_SendCmd (const char * cmd)
{ {
char buf[100]; char buf[10000];
strcpy (buf, cmd); strcpy (buf, cmd);
// MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD); // MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD);
for (int dest = 1; dest < ntasks; dest++) for (int dest = 1; dest < ntasks; dest++)
MPI_Bsend( &buf, 100, MPI_CHAR, dest, MPI_TAG_CMD, MPI_COMM_WORLD); MPI_Send( &buf, 10000, MPI_CHAR, dest, MPI_TAG_CMD, MPI_COMM_WORLD);
} }
string MyMPI_RecvCmd () string MyMPI_RecvCmd ()
{ {
char buf[100]; char buf[10000];
// MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD); // MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD);
// VT_OFF(); // VT_OFF();
@ -44,7 +44,7 @@ namespace netgen
while (!flag); while (!flag);
// VT_ON(); // VT_ON();
MPI_Recv( &buf, 100, MPI_CHAR, 0, MPI_TAG_CMD, MPI_COMM_WORLD, &status); MPI_Recv( &buf, 10000, MPI_CHAR, 0, MPI_TAG_CMD, MPI_COMM_WORLD, &status);
return string(buf); return string(buf);
} }

View File

@ -776,13 +776,16 @@ namespace netgen
{ {
string displname; string displname;
// Display * dpy = glXGetCurrentDisplay(); Display * dpy = glXGetCurrentDisplay();
GLXDrawable drawable = glXGetCurrentDrawable(); GLXDrawable drawable = glXGetCurrentDrawable();
GLXContext ctx = glXGetCurrentContext(); GLXContext ctx = glXGetCurrentContext();
GLXContextID xid = glXGetContextIDEXT (ctx); GLXContextID xid = glXGetContextIDEXT (ctx);
displname = XDisplayName (0); displname = XDisplayName (0);
if( glXIsDirect ( dpy, ctx ) )
cout << "WARNING: direct rendering enabled; this might break mpi-parallel netgen (especially if X-forwarding is used! (to disable, change -indirect to true in ng/drawing.tcl)" << endl;
/* /*
cout << "Init Parallel GL" << endl; cout << "Init Parallel GL" << endl;
cout << "DisplayName = " << displname << endl; cout << "DisplayName = " << displname << endl;

View File

@ -138,7 +138,7 @@ void ParallelRun()
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;
@ -147,17 +147,17 @@ void ParallelRun()
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,
@ -166,23 +166,27 @@ void ParallelRun()
" , h = ", XDisplayHeight (display, 0)); " , h = ", XDisplayHeight (display, 0));
*/ */
Window win;
int wx, wy;
unsigned int ww, wh, bw, depth;
// cout << "got drawable: " << curDrawable << endl;
XGetGeometry(display, curDrawable, &win,
&wx, &wy, &ww, &wh,
&bw, &depth);
/* /*
Window win;
int wx, wy;
unsigned int ww, wh, bw, depth;
cout << "got drawable: " << curDrawable << ", contextid: " << contextid << endl;
cout << "get geometriy..." << endl;
XGetGeometry(display, curDrawable, &win,
&wx, &wy, &ww, &wh,
&bw, &depth);
cout << "have!" << endl;
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
#ifdef VISINFO_OLD
//this does not seem to work anymore (but might still be with togl1.7?)
// make a new GLXContext // make a new GLXContext
// first, generate a visual (copied from togl) // first, generate a visual (copied from togl)
@ -221,51 +225,68 @@ void ParallelRun()
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);
cout << "have vis?" << endl;
if (visinfo) { if (visinfo) {
/* found a GLX visual! */ /* found a GLX visual! */
// cout << "found VISINFO !!!" << endl; // 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) if (!visinfo)
cerr << "no VISINFO found" << endl; cerr << "no VISINFO found" << endl;
#else
//get all possible confs
int nconfs;
auto cptr = glXGetFBConfigs (display,0, &nconfs);
Array<int> conf_ids(nconfs);
for(int k=0;k<nconfs;k++)
glXGetFBConfigAttrib(display, cptr[k], GLX_FBCONFIG_ID, &(conf_ids[k]));
//get drawable->FBConfig->visual
unsigned int d_fbc_id;
glXQueryDrawable( display, curDrawable, GLX_FBCONFIG_ID, &d_fbc_id);
GLXFBConfig d_fbc;
for(int k=0;k<nconfs;k++)
if(d_fbc_id==conf_ids[k])
d_fbc = cptr[k];
visinfo = glXGetVisualFromFBConfig(display,d_fbc);
#endif
// 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;
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 ();
@ -283,7 +304,6 @@ void ParallelRun()
vsmesh.BuildFilledList (false); vsmesh.BuildFilledList (false);
} }
if (redraw_cmd == "solsurfellist") if (redraw_cmd == "solsurfellist")
{ {
vssolution.DrawSurfaceElements(); vssolution.DrawSurfaceElements();