From 49aa2861d6cc1a07925b6b4b0cec4cff9855d3fc Mon Sep 17 00:00:00 2001 From: Lukas Kogler Date: Mon, 7 Nov 2016 17:48:23 +0100 Subject: [PATCH 1/4] changed buffer size in send/recv cmd (for sending entire python files) --- libsrc/general/mpi_interface.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libsrc/general/mpi_interface.cpp b/libsrc/general/mpi_interface.cpp index 57d69ab9..fea0d8a0 100644 --- a/libsrc/general/mpi_interface.cpp +++ b/libsrc/general/mpi_interface.cpp @@ -16,17 +16,18 @@ namespace netgen void MyMPI_SendCmd (const char * cmd) { - char buf[100]; + char buf[10000]; strcpy (buf, cmd); + // MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD); 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 () { - char buf[100]; + char buf[10000]; // MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD); // VT_OFF(); @@ -44,7 +45,7 @@ namespace netgen while (!flag); // 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); } From d778d9dcef5a6538025c84573ae05f6cddba7fbb Mon Sep 17 00:00:00 2001 From: Lukas Kogler Date: Mon, 7 Nov 2016 17:49:38 +0100 Subject: [PATCH 2/4] fixed mpi-parallel visualization; added warning in mvdraw if running in parallel and direct rendering is enabled (which probably breaks parallel visualization) --- libsrc/visualization/mvdraw.cpp | 5 +- ng/parallelfunc.cpp | 97 ++++++++++++++++++++------------- 2 files changed, 63 insertions(+), 39 deletions(-) diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 06e8b7e8..04d98e6c 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -776,13 +776,16 @@ namespace netgen { string displname; - // Display * dpy = glXGetCurrentDisplay(); + Display * dpy = glXGetCurrentDisplay(); GLXDrawable drawable = glXGetCurrentDrawable(); GLXContext ctx = glXGetCurrentContext(); GLXContextID xid = glXGetContextIDEXT (ctx); 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 << "DisplayName = " << displname << endl; diff --git a/ng/parallelfunc.cpp b/ng/parallelfunc.cpp index 2efb0259..48bcbf5d 100644 --- a/ng/parallelfunc.cpp +++ b/ng/parallelfunc.cpp @@ -77,7 +77,6 @@ void ParallelRun() while ( true ) { message = MyMPI_RecvCmd(); - if ( message.compare(0, 3, "ngs") == 0 ) { // PrintMessage ( 1, "Starting NgSolve routine ", message ) ; @@ -138,7 +137,7 @@ void ParallelRun() string redraw_cmd; // MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS); redraw_cmd = MyMPI_RecvCmd(); - + // PrintMessage (1, "Redraw - ", redraw_cmd); static string displname; @@ -147,17 +146,15 @@ void ParallelRun() static Display * display = NULL; static GLXContext context; static XVisualInfo * visinfo = 0; - + // if (!display) if (redraw_cmd == "init") { MyMPI_Recv (displname, 0, MPI_TAG_VIS); MyMPI_Recv (curDrawable, 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, "display = ", display, @@ -166,23 +163,26 @@ void ParallelRun() " , h = ", XDisplayHeight (display, 0)); */ - Window win; - int wx, wy; - unsigned int ww, wh, bw, depth; - // cout << "got drawable: " << curDrawable << endl; + // Window win; + // int wx, wy; + // unsigned int ww, wh, bw, depth; + // cout << "got drawable: " << curDrawable << ", contextid: " << contextid << endl; - XGetGeometry(display, curDrawable, &win, - &wx, &wy, &ww, &wh, - &bw, &depth); - - /* - cout << "P" << id << ": window-props: x = " << wx << ", y = " << wy - << ", w = " << ww << ", h = " << wh << ", depth = " << depth << 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 + // << ", w = " << ww << ", h = " << wh << ", depth = " << depth << endl; + #define VISUAL #ifdef VISUAL - + +#ifdef VISINFO_OLD + //this does not seem to work anymore (but might still be with togl1.7?) // make a new GLXContext // first, generate a visual (copied from togl) @@ -221,44 +221,66 @@ void ParallelRun() attrib_list[attrib_count++] = GLX_DOUBLEBUFFER; attrib_list[attrib_count++] = None; - + + { + int hi = 0; + std::cout << "min attribs = "; + while (attrib_list[hi] != None) + std::cout << attrib_list[hi++] << " "; + std::cout << std::endl; + } + + cout << "choose visual!!" << endl; + visinfo = NULL; visinfo = glXChooseVisual(display, 0, attrib_list); + cout << "have vis?" << endl; if (visinfo) { /* found a GLX visual! */ - // cout << "found VISINFO !!!" << endl; + cout << "found VISINFO !!!" << endl; - /* - int hi = 0; - std::cout << "attribs = "; - while (attrib_list[hi] != None) + int hi = 0; + std::cout << "attribs = "; + while (attrib_list[hi] != None) std::cout << attrib_list[hi++] << " "; - std::cout << std::endl; - */ - + std::cout << std::endl; + break; } } if (!visinfo) cerr << "no VISINFO found" << endl; + +#else + //get all confs + int nconfs; + auto cptr = glXGetFBConfigs (display,0, &nconfs); + cout << "found " << nconfs << " valid confs " << endl; + Array conf_ids(nconfs); + for(int k=0;kFBConfig->visual and try with that + unsigned int d_fbc_id; + glXQueryDrawable( display, curDrawable, GLX_FBCONFIG_ID, &d_fbc_id); + GLXFBConfig d_fbc; + for(int k=0;k Date: Tue, 8 Nov 2016 12:57:59 +0100 Subject: [PATCH 3/4] removed some comments. formatting --- libsrc/general/mpi_interface.cpp | 1 - ng/drawing.tcl | 4 +-- ng/parallelfunc.cpp | 54 +++++++++++++++----------------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/libsrc/general/mpi_interface.cpp b/libsrc/general/mpi_interface.cpp index fea0d8a0..36df5542 100644 --- a/libsrc/general/mpi_interface.cpp +++ b/libsrc/general/mpi_interface.cpp @@ -18,7 +18,6 @@ namespace netgen { char buf[10000]; strcpy (buf, cmd); - // MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD); for (int dest = 1; dest < ntasks; dest++) diff --git a/ng/drawing.tcl b/ng/drawing.tcl index a19b1c8e..a0fcb102 100644 --- a/ng/drawing.tcl +++ b/ng/drawing.tcl @@ -21,7 +21,7 @@ puts "togl-version : $toglversion" set toglok 0 if { [Ng_GetToglVersion] == 2 } { # Togl 2.x - if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } { + if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true -create init -display draw -reshape reshape }] } { puts "no OpenGL" } { # puts "have Togl 2.1" @@ -29,7 +29,7 @@ if { [Ng_GetToglVersion] == 2 } { } } { # Togl 1.7 - if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } { + if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true }] } { puts "no OpenGL" } { # puts "have Togl 1.7" diff --git a/ng/parallelfunc.cpp b/ng/parallelfunc.cpp index 48bcbf5d..2985f0d0 100644 --- a/ng/parallelfunc.cpp +++ b/ng/parallelfunc.cpp @@ -77,6 +77,7 @@ void ParallelRun() while ( true ) { message = MyMPI_RecvCmd(); + if ( message.compare(0, 3, "ngs") == 0 ) { // PrintMessage ( 1, "Starting NgSolve routine ", message ) ; @@ -137,7 +138,7 @@ void ParallelRun() string redraw_cmd; // MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS); redraw_cmd = MyMPI_RecvCmd(); - + // PrintMessage (1, "Redraw - ", redraw_cmd); static string displname; @@ -155,6 +156,7 @@ void ParallelRun() MyMPI_Recv (contextid, 0, MPI_TAG_VIS); display = XOpenDisplay (displname.c_str()); + /* PrintMessage (3, "displ - name = ", displname); PrintMessage (3, "display = ", display, @@ -163,20 +165,21 @@ void ParallelRun() " , h = ", XDisplayHeight (display, 0)); */ - // Window win; - // int wx, wy; - // unsigned int ww, wh, bw, depth; - // cout << "got drawable: " << curDrawable << ", contextid: " << contextid << endl; + /* + 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 - // << ", w = " << ww << ", h = " << wh << ", depth = " << depth << 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 + << ", w = " << ww << ", h = " << wh << ", depth = " << depth << endl; + */ #define VISUAL #ifdef VISUAL @@ -221,29 +224,23 @@ void ParallelRun() attrib_list[attrib_count++] = GLX_DOUBLEBUFFER; attrib_list[attrib_count++] = None; - - { - int hi = 0; - std::cout << "min attribs = "; - while (attrib_list[hi] != None) - std::cout << attrib_list[hi++] << " "; - std::cout << std::endl; - } - - cout << "choose visual!!" << endl; - visinfo = NULL; + visinfo = glXChooseVisual(display, 0, attrib_list); cout << "have vis?" << endl; + if (visinfo) { /* found a GLX visual! */ + // cout << "found VISINFO !!!" << endl; cout << "found VISINFO !!!" << endl; + /* int hi = 0; std::cout << "attribs = "; while (attrib_list[hi] != None) std::cout << attrib_list[hi++] << " "; std::cout << std::endl; + */ break; } @@ -251,17 +248,15 @@ void ParallelRun() if (!visinfo) cerr << "no VISINFO found" << endl; - #else - //get all confs + //get all possible confs int nconfs; auto cptr = glXGetFBConfigs (display,0, &nconfs); - cout << "found " << nconfs << " valid confs " << endl; Array conf_ids(nconfs); for(int k=0;kFBConfig->visual and try with that + //get drawable->FBConfig->visual unsigned int d_fbc_id; glXQueryDrawable( display, curDrawable, GLX_FBCONFIG_ID, &d_fbc_id); GLXFBConfig d_fbc; @@ -287,7 +282,8 @@ void ParallelRun() // PrintMessage (1, "redraw - init complete"); } - + + if (redraw_cmd == "broadcast") { vsmesh.Broadcast (); From 9890e7442943f7e2ae5642ad7d74c23b0d9e0300 Mon Sep 17 00:00:00 2001 From: Lukas Kogler Date: Tue, 8 Nov 2016 13:01:40 +0100 Subject: [PATCH 4/4] accidentally changed to indirect rendering - reverted that. formatting --- ng/drawing.tcl | 4 ++-- ng/parallelfunc.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ng/drawing.tcl b/ng/drawing.tcl index a0fcb102..a19b1c8e 100644 --- a/ng/drawing.tcl +++ b/ng/drawing.tcl @@ -21,7 +21,7 @@ puts "togl-version : $toglversion" set toglok 0 if { [Ng_GetToglVersion] == 2 } { # Togl 2.x - if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true -create init -display draw -reshape reshape }] } { + if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } { puts "no OpenGL" } { # puts "have Togl 2.1" @@ -29,7 +29,7 @@ if { [Ng_GetToglVersion] == 2 } { } } { # Togl 1.7 - if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true }] } { + if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } { puts "no OpenGL" } { # puts "have Togl 1.7" diff --git a/ng/parallelfunc.cpp b/ng/parallelfunc.cpp index 2985f0d0..d3e6d7d7 100644 --- a/ng/parallelfunc.cpp +++ b/ng/parallelfunc.cpp @@ -138,7 +138,7 @@ void ParallelRun() string redraw_cmd; // MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS); redraw_cmd = MyMPI_RecvCmd(); - + // PrintMessage (1, "Redraw - ", redraw_cmd); static string displname; @@ -147,16 +147,17 @@ void ParallelRun() static Display * display = NULL; static GLXContext context; static XVisualInfo * visinfo = 0; - + // if (!display) if (redraw_cmd == "init") { MyMPI_Recv (displname, 0, MPI_TAG_VIS); MyMPI_Recv (curDrawable, 0, MPI_TAG_VIS); MyMPI_Recv (contextid, 0, MPI_TAG_VIS); - + display = XOpenDisplay (displname.c_str()); + /* PrintMessage (3, "displ - name = ", displname); PrintMessage (3, "display = ", display, @@ -179,8 +180,8 @@ void ParallelRun() cout << "P" << id << ": window-props: x = " << wx << ", y = " << wy << ", w = " << ww << ", h = " << wh << ", depth = " << depth << endl; - */ - + */ + #define VISUAL #ifdef VISUAL @@ -269,20 +270,22 @@ void ParallelRun() // context = glXCreateContext( display, visinfo, 0, /* curContext, */ False ); context = glXCreateContext( display, visinfo, glXImportContextEXT ( display, contextid ), False); glXMakeCurrent (display, curDrawable, context); + + #else // try to get GLXcontext from the master. // this needs an indirect context (BUT DOES NOT WORK ????) + context = glXImportContextEXT ( display, contextid ); - //PrintMessage (1, "GLX-contextid = " , contextid, - // " imported context ", context); + PrintMessage (1, "GLX-contextid = " , contextid, + " imported context ", context); glXMakeCurrent (display, curDrawable, context); #endif // PrintMessage (1, "redraw - init complete"); } - if (redraw_cmd == "broadcast") {