Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

OpenMP Static Linking - Intel Compiler 15 Update 4 and xCode 5.02

Royi
Novice
2,146 Views

Hello,

We have a project which we use OpenMP.

The code is built successfully yet it won't run on the target (Same System, OS X 10.9), it would say file is missing.
We couldn't find a way to link it statically.
We looked at the documentation here:

https://software.intel.com/en-us/node/522690

Which links here:

https://software.intel.com/en-us/node/522962#1218123C-FC73-4ED4-BAC2-E643E09C200D

We added the flag "-qopenmp-library=static" at 

AAA.png

Yet it didn't work.
We also put it in the linker at "Other Linker Flags" with the same result.

The code woks on Windows (Though we didn't try "Static Linking" there) so we know everything works.

How can we make a Static Linking project in xCode 5.02 with Intel Compiler 15.0?

Thank You.

0 Kudos
32 Replies
Royi
Novice
373 Views

Hi,

Some updates which might assist others using both Intel IPP and Intel OpenMP (Those 2 doesn't like to work together I guess):

  1. Although documentation says otherwise the flag -intel-static does affect OpenMP integration.
    If OpenMP is enabled and IPP Flag is IPP Common no matter what will be done by the user, all Intel Libraries (The Compiler, IPP and OpenMP) will be linked in Dynamic Link.
  2. If IPP is needed to be linked statically and OpenMP is enabled, IPP must be linked Manually and not using Intel Compiler Integration with Xcode.
    Namely follwoing Chao post and diabling IPP Common flag.
    Note that on Windows it works (As OpenMP is always Dynamic and setting IPP Common and Intel Static really has no affect on OpenMP).
  3. Yet, Since we want IPP and Intel Compiler Libraries to be Static (For instant libirng) we had to link IPP manually as in Chao post (Remember to turn off IPP Common, it won;t work otherwise) make sure the flag for -intel-static is on.
    The problem now is OpenMP is Linked Statically and no way to by pass it.
    We tried -qopenmp-library=dynamic which had no effect (I guess -intel-static supress it).

My suggestion to Intel - Make different flag about linking for each of your package.
Flag for Intel Compiler Run Time (libirng and his friends) Libraries - Dynamic / Static.
Flag for Intel IPP Libraries - Dynamic / Static.
Flag for Intel MKL Libraries - Dynamic / Static.

Flag for Intel OpenMP Libraries - Dynamic / Static.

The whole idea for us, which are not programmers but Algorithm Engineers in Intel Compiler is to automate those use cases.
The last 2 weeks experience wasn't good for us, I think users expect this to work out of the box and in consistent manner.
What we are happy about is that to react and assist on Forums which is great!

So now, we have the problem we can't make Intel Compiler Run Time Libraries and Intel IPP to be static and OpenMP to be dynamic.

Any advise on that? 

Thank You.

0 Kudos
Royi
Novice
373 Views

Hi,

Anyone from Intel can assist us with the issue raised above?

Namely having Intel Run Time and Intel IPP statically linked and OpenMP dynamically?

Thank You.

0 Kudos
Olga_M_Intel
Employee
373 Views

Royi wrote:

Namely having Intel Run Time and Intel IPP statically linked and OpenMP dynamically?

Try the following options "-openmp -ipp -static-intel -ipp-link=static -liomp5"

 

0 Kudos
Royi
Novice
373 Views

Hi Olga,

Where to put this line?
What about the options in Xcode of Intel Compiler, what to set those on?

Thank You.

0 Kudos
KitturGanesh
Employee
373 Views

@Royi:  Due to holiday season you may get some delayed responses as I'll be off as well on vac! That said, what Olga says makes sense as placing the libraries following static should override the previous linker setting and should link following libraries statically. BTW, you should explicitly use the full path of the IPP libraries and link statically as below after the options -qopenmp and -ipp. This way all libraries which follow after the "-static" option would be linked statically and openmp should be linked dynamically:

         "-qopenmp -ipp -static-intel -ipp-link=static -liomp5  $IPPROOT/liblibippac.a  $IPPROOT/lib/libippcore.a ....."

where $IPPROOT is the full path to the IPP directory in your installation  [For example: /opt/intel/parallel_studio_xe_2016.1.039/mac/ipp/"

In XCode you should be able to go to project->target->build settings tab  and type in search "other' and you should be able to add additional command line options for compilation.  

Also, make sure you can build your application completely using command line (not IDE) and using the command line option "-dryrun" the compiler should output the command lines used (won't execute) and you should see the linker "ld" options used by the compiler for linking  as well as below:

......
......
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld  \

 -dynamic \
   
-arch \
.......
.......

Hope the above helps.
_Kittur

 

 

 

0 Kudos
Olga_M_Intel
Employee
373 Views

Royi wrote:

Hi Olga,

Where to put this line?
What about the options in Xcode of Intel Compiler, what to set those on?

Thank You.

Hi Royi,

These options are for the command line usage. As Kittur said you should be able to compile your application without GUI, just using the command line.

I don't use XCode, so can't help with options in GUI.

These options worked for my test.

Look,

1) with "-openmp -ipp -static-intel" IPP libs are linked dynamically, OpenMP lib is linked statically.

$ otool -L ./openmp_sample.mac.exe
./openmp_sample.mac.exe:
        ./libippcv-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libippch-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libippcc-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libippdc-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libippi-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libipps-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libippvm-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        ./libippcore-9.0.dylib (compatibility version 9.0.0, current version 9.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

2) Adding  -ipp-link=static makes IPP libs statically linked as well

$ otool -L ./openmp_sample.mac.exe  

./openmp_sample.mac.exe:
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
3)  Explicit link with libiomp5 by "-liomp5" makes OpenMP library linked dynamically.

$ otool -L ./openmp_sample.mac.exe                                             

./openmp_sample.mac.exe:
        libiomp5.dylib (compatibility version 5.0.0, current version 5.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

It looks like this is what you wanted. Hope it helps.

 

0 Kudos
Royi
Novice
373 Views

Hi Olga,

Our project is big, working using the command line doesn't make sense.

We'd like to work through the Integration Panel you created for VS and XCode.

0 Kudos
Royi
Novice
373 Views

Anyone on this?

0 Kudos
KitturGanesh
Employee
373 Views

Hi Royi, 
As mentioned earlier, make sure to add the following linker options with full path to the IPP libraries under the Build Settings->Linking->Other Linker Flags:   "-qopenmp -ipp -static -ipp-link=static <give full path to the IPP libraries>

Full path like:  $IPPROOT/lib/libipps.a  $IPPROOT/lib/libippcore.a  etc.  These should come after qopenmp -ipp -ipp-link=static as noted above, where IPPROOT is  the path to the installation of the compiler ex: /opt/intel/compilers_and_libraries_2016.1.XXX/mac/ipp" etc.

The -static option above ensures that any libraries coming after it will be linked in statically and so openmp library by default will be linked in dynamically.

_Kittur

0 Kudos
Varvara_R_Intel
Employee
373 Views

Hi Royi,

I've reproduced your problem: with -qopenmp ipp libraries are linked dynamically. If you'd like to link them statically (ipp libraries, not omp) you should add -ipp-link=static to 'Other Linker Flags' (and you don't need to explicitly specify static libraries).  If you'd like to link omp statically too you should additionally select 'Static Libraries' (-staic-intel) in 'Intel Runtime Libraries' box. So, to summorize:

    Case 1. Static ipp and dynamic omp:

-ipp=common

-ipp-link=static

-qopenmp

Case 2. Static ipp and static omp:

-ipp=common

-ipp-link=static

-qopenmp

-static-intel

 

Does it make sense?

0 Kudos
KitturGanesh
Employee
373 Views

@varvara: Thanks much, the method you suggest works and the one I indicated before worked for me as well. 

_Kittur

0 Kudos
Royi
Novice
373 Views

Hello,

@Varvara R., U updated ot Intel Compiler 2018 Update 1.
Tried your approach and it won't work.

One must employ Chao's manual to have Static Linking for IPP and Dynamic OpenMP.
Too bad this doesn't work through the menus.

0 Kudos
Reply