Software Archive
Read-only legacy content
17061 Discussions

Anyone compiled zlib for MIC ?

Chen_S_1
Beginner
1,189 Views

Hi Everyone,

I'm compiling a static library for Xeon Phi, 

and this library uses  'zlib compression' library ( http://www.zlib.net/ ) .

When I try to build zlib on my CentOS computer (which contains the Xeon Phi),

I keep getting errors during 'make test' which are shown in the .log file attached.

I've tried 2 configure command, both showed the same errors :

1) CC=icc CFLAGS="-mmic" CHOST=x86_64 ./configure

2) CC=icc CFLAGS="-mmic" CHOST=x86_64 ./configure --sharedlibdir=/opt/intel/composer_xe_2013.5.192/compiler/lib/intel64

I would love some advice

Thanks

Chen

0 Kudos
6 Replies
Kevin_D_Intel
Employee
1,189 Views

The document available under Configuring Intel® Xeon Phi™ coprocessors inside a cluster includes instructions for Compiling native GNU tools which includes zlib and other GNU tools.

0 Kudos
Chen_S_1
Beginner
1,189 Views

Please explain something to me,

if I only wish to compile zlib on the host PC, not on the Phi itself,

and have it built as a MIC binary (so I could then build my main library which depends

on zlib, and copy it to uOS),

is there a shorter way ?

0 Kudos
Kevin_D_Intel
Employee
1,189 Views

The issue is configure. If the app did not depend on its operation and instead the code could simply be compiled/linked then compilation on the host with -mmic would do the job.

There is another similar procedure contributed by a customer discussed on Cross-compilation challenges but it isn't any shorter than the earlier cited method.

The only other shorter method would be if someone provided a pre-built zlib for native that you could simply use to build your library.

0 Kudos
Chen_S_1
Beginner
1,189 Views

Kevin, thanks for your help,

I'm reading pg. 21 in "Configuring Intel® Xeon Phi™ coprocessors inside a cluster" , 

and I see the command to build zlib, now, excuse me for the newbie questions but:

a. should I run those commands on the Phi (after ssh'ing into it), 

or are they being run on the host ? (which somehow copies them into the uOS environment

which is in /opt/crtdc/micgnu/)

b. is there even a way to install Intel Compiler on the Xeon Phi itself? should I even do it in case the main program should

only be run on the Phi and not compiled on it?

Thank you very much once again,

Chen

0 Kudos
Kevin_D_Intel
Employee
1,189 Views

For a), execute them all on the Intel Xeon Phi as per the first-bullet on pg. 20 under the Compiling native GNU tools section:

  • “All steps needed to build the native environment are executed on the uOS of the Intel Xeon Phi coprocessor.”

For b), there’s no way to install the Intel compiler on the coprocessor and no need to. It functions fine as a coprocessor cross-compiler running on the host (with -mmic) and using the k1om binutils (distributed/installed with MPSS) to produce a complete native executable (including the main program) that can be shipped to the coprocessor and executed.

0 Kudos
Georg_V_
Beginner
1,189 Views

Here are some notes that I took when compiling it a while ago. There were some strange constructs in the generated makefile that required manual fixes:

Compiling for Intel M

Georg

Compiling for MIC:
========================
- change configure not to use stdio:
...
cat > $test.c <<EOF
extern int getchar();
int hello() {return 1+1;}
EOF
...
- prefix=`pwd`/compiled_mic CC=icc CFLAGS="-mmic -fPIC" LDSHARED="icc -shared" ./configure
- make; make install
- ignore errors about executables. They are not needed.
- cp compiled_mic/lib/libz.so* ../../../precompiled/lib.mic64
- cp compiled_mic/lib/libz.so* ../../../precompiled/lib.mic64-g

Compiling fuer Intel MIC offload
===============================
$ unset TARGET_ARCH # otherwise "amd64" magically appears as a target
$ CC=icc CFLAGS="-offload-attribute-target=mic -fPIC" LDSHARED="icc -shared" ./configure --prefix=`pwd`/compiled_offload --64
$ make
# Creation of fat lib actually failed, because mechanism in makefile creates .o files in objcts/ and moves
# only the .o files are copied to .lo, not the *MIC.o files. do link step manually:
$ icc -shared -offload-attribute-target=mic -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o  -lc
$ make test
$ make install
$ cp -d compiled_offload/lib/*.so* ../../../../3rd_party/precompiled/lib.linux64-offload

 

0 Kudos
Reply