Software Archive
Read-only legacy content
17060 Discussions

Compiling for Phi in the 'Configure' command

Chen_S_1
Beginner
381 Views

Hi,

I'm new to working with Xeon Phi.

I'm trying to build a certain library written in C , with Intel C compiler on Linux (CentOS), 

and I intend to run it on the Phi.

The thing is, I usually build this library with 'configure' and 'make' commands

and with gcc, and now I have to build it with Intel C and with MIC support.

Now , I realize that the -mmic flag is available when compiling directly with icpc/ifort ,

but when I run 'configure' for my library :

"./configure --with-cc=icc ... "

I don't know where to add the "-mmic" flag, so that the library will be built for running on Phi.

Please let me know what you think,

Thanks

Chen

0 Kudos
3 Replies
TimP
Honored Contributor III
381 Views

Add -mmic to the CFLAGS (or similar) environment option or

./configure --with-cc='icc -mmic'

Library build options may need attention:

http://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-896A68BA-D30F-4553-A9A4-7545C5E6EA41.htm

0 Kudos
Andrey_Vladimirov
New Contributor III
381 Views

I usually have success with

[bash]

./configure CC=icc CXX=icpc CFLAGS="-mmic" CXXFLAGS="-mmic" --host=x86_64

[/bash]

The CC/CXX and CFLAGS/CXXFLAGS handle both C and C++ codes, and "--host=x86_64" indicates cross-compilation. Indicating cross-compilation is a trick: in fact, you are compiling for the MIC architecture and not for x86_64, but "--host=..." tells the configure script not to panic when the executable produced by the compiler cannot be run on the host.

The link that Tim has sent talks about using "xiar -qoffload-build" instead of "ar" for linking a static library. This is necessary for static libraries with offload. I believe that for native (i.e., non-offload) and dynamic libraries this is not necessary: you can link using the compiler or probably even with "ld".

If the library has dependencies, you need to compile and install them first, and then, typically, use "-with-OTHERLIBRARY=/path/to/other/library"

0 Kudos
Evan_P_Intel
Employee
381 Views

If you've upgraded to MPSS 3.2 or later, you might consider this approach:

. /opt/mpss/3.2/environment-setup-k1om-mpss-linux
gnu-configize  # to update config.sub
./configure $CONFIGURE_FLAGS --prefix=/usr --libdir=/usr/lib64 \
    LDFLAGS='' LD=k1om-mpss-linux-ld CPPFLAGS='' \
    CC=icc CFLAGS='-mmic' CXX=icpc CXXFLAGS='-mmic'

The main difference is the --host=k1om-mpss-linux argument which referencing $CONFIGURE_FLAGS adds instead.

Using the GCC port to compile something can be done similarly:

. /opt/mpss/3.2/environment-setup-k1om-mpss-linux
gnu-configize  # to update config.sub
./configure $CONFIGURE_FLAGS --prefix=/usr --libdir=/usr/lib64

...although, of course, using GCC is generally ill-advised, since the port for Xeon Phi is unsophisticated and generates poor quality object code relative to ICC.

You may find this other thread interesting:  https://software.intel.com/en-us/forums/topic/509026#comment-1785910

0 Kudos
Reply