<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Linking problem: Missing symbol when using auto parallelisation in (MEX file / shared object) in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-problem-Missing-symbol-when-using-auto-parallelisation/m-p/756765#M12252</link>
    <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;Sorry for such a long post - I'd be REALLY grateful if somebody could help me get to the bottom of this problem.&lt;BR /&gt;&lt;BR /&gt;So I have a MATLAB MEX file (a shared object, essentially) which works perfectly when compiled for serial operation.&lt;BR /&gt;&lt;BR /&gt;It is linked using the definition .map file:&lt;BR /&gt;FMEX {&lt;BR /&gt; global:&lt;BR /&gt;  mexfunction_;&lt;BR /&gt; local:&lt;BR /&gt;  *;&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;Using nm myFileName.mexa64 on the resultant object yields a list of symbols which, importantly, include:&lt;BR /&gt;&lt;BR /&gt;mexfunction_&lt;BR /&gt;&lt;BR /&gt;This is the symbol used by MATLAB to run the mex function. When I add the -parallel flag to my compile line, the autoparallelisation does its thing. When I then link the object (adding -liomp to the link line, of course) I get an output file as expected. All external symbols are resolved.&lt;BR /&gt;&lt;BR /&gt;However, using nm on the new output file shows that it does not contain the mexfunction_ symbol (although there is something called mexfunction__kmpc_reduction_lock_0).&lt;BR /&gt;&lt;BR /&gt;As a result, I get the following error when executing it in MATLAB, because of course the mexfunction_ symbol cannot be found:&lt;BR /&gt;&lt;BR /&gt;Mex file entry point is missing. Please check the (case-sensitive) &lt;BR /&gt;spelling of mexFunction (for C MEX-files), or the (case-insensitive) &lt;BR /&gt;spelling of MEXFUNCTION (for FORTRAN MEX-files).&lt;BR /&gt;??? Invalid MEX-file '/home/thc29/Dropbox/syncTomoPIVtoolbox/code_tomoreconstruction/mxmart_large_pvr/mxmart_large_pvr_parallel.mexa64': .&lt;BR /&gt;&lt;BR /&gt;Can anyone please help explain why this symbol is missing? I know this is possible because it worked for me once - for the life of me, I don't know what changed to make it stop working!&lt;BR /&gt;&lt;BR /&gt;I've added a whole set of stuff below to try and help diagnose the issue...&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Tom Clark&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;____________________________&lt;BR /&gt;IMPORTANT PARTS OF nm OUTPUT:&lt;BR /&gt;&lt;BR /&gt;With the -parallel option:&lt;BR /&gt;0000000000000000 A FMEX&lt;BR /&gt;00000000002013b0 b mexfunction__kmpc_reduction_lock_0&lt;BR /&gt;&lt;BR /&gt;Without (working):&lt;BR /&gt;
0000000000000000 A FMEX&lt;BR /&gt;00000000000013c0 T mexfunction_&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
____________________________&lt;BR /&gt;STRUCTURE OF MEX FUNCTION&lt;BR /&gt;&lt;BR /&gt;! Type definitions for MATLAB mex files&lt;BR /&gt;#include "fintrf.h"&lt;BR /&gt;&lt;BR /&gt;! MEX file gateway function&lt;BR /&gt; SUBROUTINE mexFunction(nlhs, plhs, nrhs, prhs)&lt;BR /&gt;  USE weights_mod_pvr&lt;BR /&gt; IMPLICIT NONE&lt;BR /&gt;&lt;BR /&gt;!  DECLARE STUFF&lt;BR /&gt;! ALLOCATE VARIABLE SIZE ARRAYS DECLARED WITHIN THE MODULE&lt;BR /&gt;! COPY FROM INPUT POINTERS TO LOCAL VARIABLES&lt;BR /&gt;&lt;BR /&gt;! Call a subroutine (defined within the module) to do some heavyweight processing&lt;BR /&gt; CALL reconstruct(ARGS)&lt;BR /&gt;&lt;BR /&gt;! COPY FROM LOCAL VARIABLES TO OUTPUT POINTERS&lt;BR /&gt;! DEALLOCATE VARIABLE SIZE ARRAYS DECALRED WITHIN THE MODULE&lt;BR /&gt;&lt;BR /&gt;  RETURN&lt;BR /&gt; END SUBROUTINE mexFunction&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
____________________________&lt;BR /&gt;COMPILATION AND LINKING SCRIPT&lt;BR /&gt;&lt;BR /&gt;# Set up name of mex file to compile&lt;BR /&gt;MEXNAME="mxmart_large_pvr_parallel"&lt;BR /&gt;MODNAME="weights_mod_pvr"&lt;BR /&gt;FORTEXT="F90"&lt;BR /&gt;MEXEXT="mexa64"&lt;BR /&gt;&lt;BR /&gt;# Set up root directories&lt;BR /&gt;TMWROOT="/home/thc29/MATLAB/R2010b"&lt;BR /&gt;&lt;BR /&gt;# Compilation Flags For Module&lt;BR /&gt;MODCOMPILEFLAGS="-c -O3 -fPIC -heap-arrays -fexceptions -xSSSE3 -parallel -guide -vec-report2 -par-report2"&lt;BR /&gt;&lt;BR /&gt;# Compile Module&lt;BR /&gt;ifort $MODCOMPILEFLAGS $MODNAME"."$FORTEXT&lt;BR /&gt;&lt;BR /&gt;# Compilation Flags For Mex Function&lt;BR /&gt;COMPILEFLAGS="-c -O3 -heap-arrays -fexceptions -ipo -fPIC -DMX_COMPAT_32 -xSSSE3 -DMATLAB_MEX_FILE"&lt;BR /&gt;&lt;BR /&gt;# Linker Flags &lt;BR /&gt;LINKFLAGS=" -O3 -fPIC -shared -fno-omit-frame-pointer -DMATLAB_MEX_FILE -DMX_COMPAT_32 -static-intel -ipo -xSSSE3"&lt;BR /&gt;&lt;BR /&gt;# Compile mex function&lt;BR /&gt;ifort $COMPILEFLAGS -I$TMWROOT/extern/include $MEXNAME.$FORTEXT&lt;BR /&gt;&lt;BR /&gt;# Link (static intel with -fPIC)&lt;BR /&gt;ifort $LINKFLAGS -Wl,--version-script,$TMWROOT/extern/lib/glnxa64/fexport.map -Wl,--no-undefined -o $MEXNAME.$MEXEXT $MEXNAME.o $MODNAME.o /opt/intel/lib/intel64/libifcoremt_pic.a -Wl,-rpath-link,$TMWROOT/bin/glnxa64 -L$TMWROOT/bin/glnxa64 -lmx -lmex -lmat -lm -L/opt/intel/lib/intel64/ -liomp5&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sat, 06 Aug 2011 13:52:40 GMT</pubDate>
    <dc:creator>t_clark</dc:creator>
    <dc:date>2011-08-06T13:52:40Z</dc:date>
    <item>
      <title>Linking problem: Missing symbol when using auto parallelisation in (MEX file / shared object)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-problem-Missing-symbol-when-using-auto-parallelisation/m-p/756765#M12252</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;Sorry for such a long post - I'd be REALLY grateful if somebody could help me get to the bottom of this problem.&lt;BR /&gt;&lt;BR /&gt;So I have a MATLAB MEX file (a shared object, essentially) which works perfectly when compiled for serial operation.&lt;BR /&gt;&lt;BR /&gt;It is linked using the definition .map file:&lt;BR /&gt;FMEX {&lt;BR /&gt; global:&lt;BR /&gt;  mexfunction_;&lt;BR /&gt; local:&lt;BR /&gt;  *;&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;Using nm myFileName.mexa64 on the resultant object yields a list of symbols which, importantly, include:&lt;BR /&gt;&lt;BR /&gt;mexfunction_&lt;BR /&gt;&lt;BR /&gt;This is the symbol used by MATLAB to run the mex function. When I add the -parallel flag to my compile line, the autoparallelisation does its thing. When I then link the object (adding -liomp to the link line, of course) I get an output file as expected. All external symbols are resolved.&lt;BR /&gt;&lt;BR /&gt;However, using nm on the new output file shows that it does not contain the mexfunction_ symbol (although there is something called mexfunction__kmpc_reduction_lock_0).&lt;BR /&gt;&lt;BR /&gt;As a result, I get the following error when executing it in MATLAB, because of course the mexfunction_ symbol cannot be found:&lt;BR /&gt;&lt;BR /&gt;Mex file entry point is missing. Please check the (case-sensitive) &lt;BR /&gt;spelling of mexFunction (for C MEX-files), or the (case-insensitive) &lt;BR /&gt;spelling of MEXFUNCTION (for FORTRAN MEX-files).&lt;BR /&gt;??? Invalid MEX-file '/home/thc29/Dropbox/syncTomoPIVtoolbox/code_tomoreconstruction/mxmart_large_pvr/mxmart_large_pvr_parallel.mexa64': .&lt;BR /&gt;&lt;BR /&gt;Can anyone please help explain why this symbol is missing? I know this is possible because it worked for me once - for the life of me, I don't know what changed to make it stop working!&lt;BR /&gt;&lt;BR /&gt;I've added a whole set of stuff below to try and help diagnose the issue...&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Tom Clark&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;____________________________&lt;BR /&gt;IMPORTANT PARTS OF nm OUTPUT:&lt;BR /&gt;&lt;BR /&gt;With the -parallel option:&lt;BR /&gt;0000000000000000 A FMEX&lt;BR /&gt;00000000002013b0 b mexfunction__kmpc_reduction_lock_0&lt;BR /&gt;&lt;BR /&gt;Without (working):&lt;BR /&gt;
0000000000000000 A FMEX&lt;BR /&gt;00000000000013c0 T mexfunction_&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
____________________________&lt;BR /&gt;STRUCTURE OF MEX FUNCTION&lt;BR /&gt;&lt;BR /&gt;! Type definitions for MATLAB mex files&lt;BR /&gt;#include "fintrf.h"&lt;BR /&gt;&lt;BR /&gt;! MEX file gateway function&lt;BR /&gt; SUBROUTINE mexFunction(nlhs, plhs, nrhs, prhs)&lt;BR /&gt;  USE weights_mod_pvr&lt;BR /&gt; IMPLICIT NONE&lt;BR /&gt;&lt;BR /&gt;!  DECLARE STUFF&lt;BR /&gt;! ALLOCATE VARIABLE SIZE ARRAYS DECLARED WITHIN THE MODULE&lt;BR /&gt;! COPY FROM INPUT POINTERS TO LOCAL VARIABLES&lt;BR /&gt;&lt;BR /&gt;! Call a subroutine (defined within the module) to do some heavyweight processing&lt;BR /&gt; CALL reconstruct(ARGS)&lt;BR /&gt;&lt;BR /&gt;! COPY FROM LOCAL VARIABLES TO OUTPUT POINTERS&lt;BR /&gt;! DEALLOCATE VARIABLE SIZE ARRAYS DECALRED WITHIN THE MODULE&lt;BR /&gt;&lt;BR /&gt;  RETURN&lt;BR /&gt; END SUBROUTINE mexFunction&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
____________________________&lt;BR /&gt;COMPILATION AND LINKING SCRIPT&lt;BR /&gt;&lt;BR /&gt;# Set up name of mex file to compile&lt;BR /&gt;MEXNAME="mxmart_large_pvr_parallel"&lt;BR /&gt;MODNAME="weights_mod_pvr"&lt;BR /&gt;FORTEXT="F90"&lt;BR /&gt;MEXEXT="mexa64"&lt;BR /&gt;&lt;BR /&gt;# Set up root directories&lt;BR /&gt;TMWROOT="/home/thc29/MATLAB/R2010b"&lt;BR /&gt;&lt;BR /&gt;# Compilation Flags For Module&lt;BR /&gt;MODCOMPILEFLAGS="-c -O3 -fPIC -heap-arrays -fexceptions -xSSSE3 -parallel -guide -vec-report2 -par-report2"&lt;BR /&gt;&lt;BR /&gt;# Compile Module&lt;BR /&gt;ifort $MODCOMPILEFLAGS $MODNAME"."$FORTEXT&lt;BR /&gt;&lt;BR /&gt;# Compilation Flags For Mex Function&lt;BR /&gt;COMPILEFLAGS="-c -O3 -heap-arrays -fexceptions -ipo -fPIC -DMX_COMPAT_32 -xSSSE3 -DMATLAB_MEX_FILE"&lt;BR /&gt;&lt;BR /&gt;# Linker Flags &lt;BR /&gt;LINKFLAGS=" -O3 -fPIC -shared -fno-omit-frame-pointer -DMATLAB_MEX_FILE -DMX_COMPAT_32 -static-intel -ipo -xSSSE3"&lt;BR /&gt;&lt;BR /&gt;# Compile mex function&lt;BR /&gt;ifort $COMPILEFLAGS -I$TMWROOT/extern/include $MEXNAME.$FORTEXT&lt;BR /&gt;&lt;BR /&gt;# Link (static intel with -fPIC)&lt;BR /&gt;ifort $LINKFLAGS -Wl,--version-script,$TMWROOT/extern/lib/glnxa64/fexport.map -Wl,--no-undefined -o $MEXNAME.$MEXEXT $MEXNAME.o $MODNAME.o /opt/intel/lib/intel64/libifcoremt_pic.a -Wl,-rpath-link,$TMWROOT/bin/glnxa64 -L$TMWROOT/bin/glnxa64 -lmx -lmex -lmat -lm -L/opt/intel/lib/intel64/ -liomp5&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 06 Aug 2011 13:52:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-problem-Missing-symbol-when-using-auto-parallelisation/m-p/756765#M12252</guid>
      <dc:creator>t_clark</dc:creator>
      <dc:date>2011-08-06T13:52:40Z</dc:date>
    </item>
  </channel>
</rss>

