Re: [petsc-dev] calling petsc from a mex file
I confirm the same problem. But I also don't know how to fix this systematically in the buildsystem. I found hard-coded -L options here https://bitbucket.org/petsc/petsc/src/9e21ac129fc054b3abeb584f186c61369f6d442a/config/BuildSystem/config/packages/MatlabEngine.py#lines-39 but I'm in doubts I can do the same with -Wl,-rpath. Vaclav > 9. 5. 2018 v 18:49, Munson, Todd: > > Note: I compiled the latest Petsc using --with-matlab and changed to the > src/snes/examples/tutorials directory and did a "make ex5". The > compilation works fine, but the "-Wl,-rpath" for the matlab > libraries is missing and I have to set my DYLD_LIBRARY_PATH > manually. I don't know where to fix this in the build > system.
Re: [petsc-dev] calling petsc from a mex file
There is some issue with my matlab installation. I also tried it on linux and the simple Petsc initialize and finalize work fine. When I start setting up and using TaoSolve, I get a segmentation violation. I am going to switch to using the PetscMatlabEngine, which is what I should have done from the beginning; that seems to be the safer option. Note: I compiled the latest Petsc using --with-matlab and changed to the src/snes/examples/tutorials directory and did a "make ex5". The compilation works fine, but the "-Wl,-rpath" for the matlab libraries is missing and I have to set my DYLD_LIBRARY_PATH manually. I don't know where to fix this in the build system. Thanks, Todd. > On May 9, 2018, at 1:55 AM, Smith, Barry F.wrote: > > > Huh > > $ matlab -nodisplay > > < M A T L A B (R) > >Copyright 1984-2018 The MathWorks, Inc. > R2018a (9.4.0.813654) 64-bit (maci64) > February 23, 2018 > > Warning: Name is nonexistent or not a directory: > /Users/barrysmith/Src/nodal-dg/Codes1.1 > Warning: Name is nonexistent or not a directory: > /Users/barrysmith/Src/nodal-dg/Codes1.1/CFD2D > Warning: Name is nonexistent or not a directory: > /Users/barrysmith/Src/nodal-dg/Codes1.1 > > To get started, type one of these: helpwin, helpdesk, or demo. > For product information, visit www.mathworks.com. > >>> taopounders() >>> exit > ~/Src/petsc/src/tao/leastsquares/examples/matlab > (tmunson/tao-pounders-matlab-interface=) arch-matlab > > >> On May 8, 2018, at 2:30 PM, Munson, Todd wrote: >> >> >> Its in tmunson/tao-pounders-matlab-interface >> >> Most of the code is commented out or otherwise inactive. There is a hacked >> command in src/tao/leastsquares/examples/matlab that I use to compile the >> mex file. >> >> To test, you should be able to start matlab and say "taopounders(); exit". >> >> Todd. >> >>> On May 8, 2018, at 2:21 PM, Smith, Barry F. wrote: >>> >>> >>> Push the branch that does this or send me the code and I'll debug it. I now >>> have some vague memory about this behavior. >>> >>> Barry >>> >>> On May 8, 2018, at 1:53 PM, Munson, Todd wrote: > On May 8, 2018, at 1:02 PM, Smith, Barry F. wrote: > > > >> On May 8, 2018, at 12:30 PM, Munson, Todd wrote: >> >> >> Hi, >> >> I wonder if anyone has experience calling petsc from matlab using mex. >> I have the >> simplest possible mexFunction that just calls PetscInitialize() and >> PetscFinalize(). That part seems to work fine, but when I exit >> from matlab I get a segmentation violation and a petsc error >> message. > > What are all the error messages? Cut and paste. I've done this in the > past but not for years. Below is the matlab session and error message. I do note that if I issue PetscFinalize() and that command completes, the Petsc signal handlers remain installed/active. If I do a PetscPopSignalHandler() immediately after PetscInitialize(), I do not get the error message, but a "Segmentation fault: 11" output at the end. Because petsc is being loaded as a dynamic library, are there possibly uninitialized global variables or state? Thanks, Todd. [0]PETSC ERROR: [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind [0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors [0]PETSC ERROR: likely location of problem given in stack below [0]PETSC ERROR: - Stack Frames [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available, [0]PETSC ERROR: INSTEAD the line number of the start of the function [0]PETSC ERROR: is given. [0]PETSC ERROR: - Error Message -- [0]PETSC ERROR: Signal received [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting. [0]PETSC ERROR: Petsc Development GIT revision: v3.9.1-409-gf553c6556e GIT Date: 2018-05-07 17:17:17 -0500 [0]PETSC ERROR: Unknown Name on a arch-darwin-c-debug named eduroam062-089.wl.anl-external.org by tmunson Tue May 8 12:04:45 2018
Re: [petsc-dev] calling petsc from a mex file
Huh $ matlab -nodisplay < M A T L A B (R) > Copyright 1984-2018 The MathWorks, Inc. R2018a (9.4.0.813654) 64-bit (maci64) February 23, 2018 Warning: Name is nonexistent or not a directory: /Users/barrysmith/Src/nodal-dg/Codes1.1 Warning: Name is nonexistent or not a directory: /Users/barrysmith/Src/nodal-dg/Codes1.1/CFD2D Warning: Name is nonexistent or not a directory: /Users/barrysmith/Src/nodal-dg/Codes1.1 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. >> taopounders() >> exit ~/Src/petsc/src/tao/leastsquares/examples/matlab (tmunson/tao-pounders-matlab-interface=) arch-matlab > On May 8, 2018, at 2:30 PM, Munson, Toddwrote: > > > Its in tmunson/tao-pounders-matlab-interface > > Most of the code is commented out or otherwise inactive. There is a hacked > command in src/tao/leastsquares/examples/matlab that I use to compile the > mex file. > > To test, you should be able to start matlab and say "taopounders(); exit". > > Todd. > >> On May 8, 2018, at 2:21 PM, Smith, Barry F. wrote: >> >> >> Push the branch that does this or send me the code and I'll debug it. I now >> have some vague memory about this behavior. >> >> Barry >> >> >>> On May 8, 2018, at 1:53 PM, Munson, Todd wrote: >>> >>> >>> On May 8, 2018, at 1:02 PM, Smith, Barry F. wrote: > On May 8, 2018, at 12:30 PM, Munson, Todd wrote: > > > Hi, > > I wonder if anyone has experience calling petsc from matlab using mex. I > have the > simplest possible mexFunction that just calls PetscInitialize() and > PetscFinalize(). That part seems to work fine, but when I exit > from matlab I get a segmentation violation and a petsc error > message. What are all the error messages? Cut and paste. I've done this in the past but not for years. >>> >>> Below is the matlab session and error message. I do note that if I issue >>> PetscFinalize() and >>> that command completes, the Petsc signal handlers remain installed/active. >>> If I do a >>> PetscPopSignalHandler() immediately after PetscInitialize(), I do not get >>> the error >>> message, but a "Segmentation fault: 11" output at the end. >>> >>> Because petsc is being loaded as a dynamic library, are there possibly >>> uninitialized global >>> variables or state? >>> >>> Thanks, Todd. >>> >>> [0]PETSC ERROR: >>> >>> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, >>> probably memory access out of range >>> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger >>> [0]PETSC ERROR: or see >>> http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind >>> [0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X >>> to find memory corruption errors >>> [0]PETSC ERROR: likely location of problem given in stack below >>> [0]PETSC ERROR: - Stack Frames >>> >>> [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available, >>> [0]PETSC ERROR: INSTEAD the line number of the start of the function >>> [0]PETSC ERROR: is given. >>> [0]PETSC ERROR: - Error Message >>> -- >>> [0]PETSC ERROR: Signal received >>> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for >>> trouble shooting. >>> [0]PETSC ERROR: Petsc Development GIT revision: v3.9.1-409-gf553c6556e GIT >>> Date: 2018-05-07 17:17:17 -0500 >>> [0]PETSC ERROR: Unknown Name on a arch-darwin-c-debug named >>> eduroam062-089.wl.anl-external.org by tmunson Tue May 8 12:04:45 2018 >>> [0]PETSC ERROR: Configure options --download-mpich CC=/usr/bin/clang >>> CXX=/usr/bin/clang++ FC=/opt/local/bin/gfortran >>> [0]PETSC ERROR: #1 User provided function() line 0 in unknown file >>> application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0 >>> [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59 >>> : >>> system msg for write_line failure : Bad file descriptor >> >
Re: [petsc-dev] calling petsc from a mex file
Its in tmunson/tao-pounders-matlab-interface Most of the code is commented out or otherwise inactive. There is a hacked command in src/tao/leastsquares/examples/matlab that I use to compile the mex file. To test, you should be able to start matlab and say "taopounders(); exit". Todd. > On May 8, 2018, at 2:21 PM, Smith, Barry F.wrote: > > > Push the branch that does this or send me the code and I'll debug it. I now > have some vague memory about this behavior. > >Barry > > >> On May 8, 2018, at 1:53 PM, Munson, Todd wrote: >> >> >> >>> On May 8, 2018, at 1:02 PM, Smith, Barry F. wrote: >>> >>> >>> On May 8, 2018, at 12:30 PM, Munson, Todd wrote: Hi, I wonder if anyone has experience calling petsc from matlab using mex. I have the simplest possible mexFunction that just calls PetscInitialize() and PetscFinalize(). That part seems to work fine, but when I exit from matlab I get a segmentation violation and a petsc error message. >>> >>> What are all the error messages? Cut and paste. I've done this in the past >>> but not for years. >> >> Below is the matlab session and error message. I do note that if I issue >> PetscFinalize() and >> that command completes, the Petsc signal handlers remain installed/active. >> If I do a >> PetscPopSignalHandler() immediately after PetscInitialize(), I do not get >> the error >> message, but a "Segmentation fault: 11" output at the end. >> >> Because petsc is being loaded as a dynamic library, are there possibly >> uninitialized global >> variables or state? >> >> Thanks, Todd. >> >> [0]PETSC ERROR: >> >> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, >> probably memory access out of range >> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger >> [0]PETSC ERROR: or see >> http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind >> [0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X >> to find memory corruption errors >> [0]PETSC ERROR: likely location of problem given in stack below >> [0]PETSC ERROR: - Stack Frames >> >> [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available, >> [0]PETSC ERROR: INSTEAD the line number of the start of the function >> [0]PETSC ERROR: is given. >> [0]PETSC ERROR: - Error Message >> -- >> [0]PETSC ERROR: Signal received >> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for >> trouble shooting. >> [0]PETSC ERROR: Petsc Development GIT revision: v3.9.1-409-gf553c6556e GIT >> Date: 2018-05-07 17:17:17 -0500 >> [0]PETSC ERROR: Unknown Name on a arch-darwin-c-debug named >> eduroam062-089.wl.anl-external.org by tmunson Tue May 8 12:04:45 2018 >> [0]PETSC ERROR: Configure options --download-mpich CC=/usr/bin/clang >> CXX=/usr/bin/clang++ FC=/opt/local/bin/gfortran >> [0]PETSC ERROR: #1 User provided function() line 0 in unknown file >> application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0 >> [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59 >> : >> system msg for write_line failure : Bad file descriptor >
Re: [petsc-dev] calling petsc from a mex file
Push the branch that does this or send me the code and I'll debug it. I now have some vague memory about this behavior. Barry > On May 8, 2018, at 1:53 PM, Munson, Toddwrote: > > > >> On May 8, 2018, at 1:02 PM, Smith, Barry F. wrote: >> >> >> >>> On May 8, 2018, at 12:30 PM, Munson, Todd wrote: >>> >>> >>> Hi, >>> >>> I wonder if anyone has experience calling petsc from matlab using mex. I >>> have the >>> simplest possible mexFunction that just calls PetscInitialize() and >>> PetscFinalize(). That part seems to work fine, but when I exit >>> from matlab I get a segmentation violation and a petsc error >>> message. >> >> What are all the error messages? Cut and paste. I've done this in the past >> but not for years. > > Below is the matlab session and error message. I do note that if I issue > PetscFinalize() and > that command completes, the Petsc signal handlers remain installed/active. > If I do a > PetscPopSignalHandler() immediately after PetscInitialize(), I do not get the > error > message, but a "Segmentation fault: 11" output at the end. > > Because petsc is being loaded as a dynamic library, are there possibly > uninitialized global > variables or state? > > Thanks, Todd. > > [0]PETSC ERROR: > > [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, > probably memory access out of range > [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger > [0]PETSC ERROR: or see > http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind > [0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to > find memory corruption errors > [0]PETSC ERROR: likely location of problem given in stack below > [0]PETSC ERROR: - Stack Frames > > [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available, > [0]PETSC ERROR: INSTEAD the line number of the start of the function > [0]PETSC ERROR: is given. > [0]PETSC ERROR: - Error Message > -- > [0]PETSC ERROR: Signal received > [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for > trouble shooting. > [0]PETSC ERROR: Petsc Development GIT revision: v3.9.1-409-gf553c6556e GIT > Date: 2018-05-07 17:17:17 -0500 > [0]PETSC ERROR: Unknown Name on a arch-darwin-c-debug named > eduroam062-089.wl.anl-external.org by tmunson Tue May 8 12:04:45 2018 > [0]PETSC ERROR: Configure options --download-mpich CC=/usr/bin/clang > CXX=/usr/bin/clang++ FC=/opt/local/bin/gfortran > [0]PETSC ERROR: #1 User provided function() line 0 in unknown file > application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0 > [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59 > : > system msg for write_line failure : Bad file descriptor
Re: [petsc-dev] calling petsc from a mex file
> On May 8, 2018, at 1:02 PM, Smith, Barry F.wrote: > > > >> On May 8, 2018, at 12:30 PM, Munson, Todd wrote: >> >> >> Hi, >> >> I wonder if anyone has experience calling petsc from matlab using mex. I >> have the >> simplest possible mexFunction that just calls PetscInitialize() and >> PetscFinalize(). That part seems to work fine, but when I exit >> from matlab I get a segmentation violation and a petsc error >> message. > > What are all the error messages? Cut and paste. I've done this in the past > but not for years. Below is the matlab session and error message. I do note that if I issue PetscFinalize() and that command completes, the Petsc signal handlers remain installed/active. If I do a PetscPopSignalHandler() immediately after PetscInitialize(), I do not get the error message, but a "Segmentation fault: 11" output at the end. Because petsc is being loaded as a dynamic library, are there possibly uninitialized global variables or state? Thanks, Todd. [0]PETSC ERROR: [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind [0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors [0]PETSC ERROR: likely location of problem given in stack below [0]PETSC ERROR: - Stack Frames [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available, [0]PETSC ERROR: INSTEAD the line number of the start of the function [0]PETSC ERROR: is given. [0]PETSC ERROR: - Error Message -- [0]PETSC ERROR: Signal received [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting. [0]PETSC ERROR: Petsc Development GIT revision: v3.9.1-409-gf553c6556e GIT Date: 2018-05-07 17:17:17 -0500 [0]PETSC ERROR: Unknown Name on a arch-darwin-c-debug named eduroam062-089.wl.anl-external.org by tmunson Tue May 8 12:04:45 2018 [0]PETSC ERROR: Configure options --download-mpich CC=/usr/bin/clang CXX=/usr/bin/clang++ FC=/opt/local/bin/gfortran [0]PETSC ERROR: #1 User provided function() line 0 in unknown file application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0 [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59 : system msg for write_line failure : Bad file descriptor
Re: [petsc-dev] calling petsc from a mex file
> On May 8, 2018, at 12:30 PM, Munson, Toddwrote: > > > Hi, > > I wonder if anyone has experience calling petsc from matlab using mex. I > have the > simplest possible mexFunction that just calls PetscInitialize() and > PetscFinalize(). That part seems to work fine, but when I exit > from matlab I get a segmentation violation and a petsc error > message. What are all the error messages? Cut and paste. I've done this in the past but not for years. > > I have tried compiling both with --download-mpich and --with-mpi=0 with the > same outcome. > > Maybe I am missing something flags I need to set when configuring petsc? > > Any help would be appreciated. > > My backup plan is to rewrite the matlab code that wants to invoke a petsc > solver so > that I can make it work using a PetscMatlabEngine instead. > > Thanks, Todd. >
[petsc-dev] calling petsc from a mex file
Hi, I wonder if anyone has experience calling petsc from matlab using mex. I have the simplest possible mexFunction that just calls PetscInitialize() and PetscFinalize(). That part seems to work fine, but when I exit from matlab I get a segmentation violation and a petsc error message. I have tried compiling both with --download-mpich and --with-mpi=0 with the same outcome. Maybe I am missing something flags I need to set when configuring petsc? Any help would be appreciated. My backup plan is to rewrite the matlab code that wants to invoke a petsc solver so that I can make it work using a PetscMatlabEngine instead. Thanks, Todd.