Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Maurizio_I_
Beginner
149 Views

Compile OpenCV code with -mmic flags

Hi, i need to compile my opencv code for mic coprocessor. 
I'm working on a Xeon machine hosted by University of Pisa which hosts Phi Co-Processor.
Because i'm not a super user in that machine, i compile OpenCV and FastFlow libraries in my home and setted environmental variables like 
LD_LIBRARY_PATH and PKG_CONFIG_PATH.

I compile my code with 

icc -mmic -Wall -std=c++11  -DNO_DEFAULT_MAPPING -I /home/spm1407/lib/opencv-3.1.0/include/  
-I /home/spm1501/fastflow/ -O3  -o farm farm.cpp -pthread -L/home/spm1407/lib/opencv-3.1.0/lib 
-lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio  -lopencv_video -lopencv_imgproc -lpthread 

When I compile without -mmic flag, compiler works fine. But if I compile with that flag, compiler returns
 

x86_64-k1om-linux-ld: skipping incompatible /home/spm1407/lib/opencv-3.1.0/lib/libopencv_core.so when searching for -lopencv_core
x86_64-k1om-linux-ld: cannot find -lopencv_core
x86_64-k1om-linux-ld: skipping incompatible /home/spm1407/lib/opencv-3.1.0/lib/libopencv_highgui.so when searching for -lopencv_highgui
x86_64-k1om-linux-ld: cannot find -lopencv_highgui
x86_64-k1om-linux-ld: skipping incompatible /home/spm1407/lib/opencv-3.1.0/lib/libopencv_imgcodecs.so when searching for -lopencv_imgcodecs
x86_64-k1om-linux-ld: cannot find -lopencv_imgcodecs
x86_64-k1om-linux-ld: skipping incompatible /home/spm1407/lib/opencv-3.1.0/lib/libopencv_videoio.so when searching for -lopencv_videoio
x86_64-k1om-linux-ld: cannot find -lopencv_videoio
x86_64-k1om-linux-ld: skipping incompatible /home/spm1407/lib/opencv-3.1.0/lib/libopencv_video.so when searching for -lopencv_video
x86_64-k1om-linux-ld: cannot find -lopencv_video
x86_64-k1om-linux-ld: skipping incompatible /home/spm1407/lib/opencv-3.1.0/lib/libopencv_imgproc.so when searching for -lopencv_imgproc
x86_64-k1om-linux-ld: cannot find -lopencv_imgproc


I tried to resolve recompiling OpenCV with this guide https://software.intel.com/en-us/articles/cross-compilation-for-intel-xeon-phi-coprocessor-with-cmak... :
 

export CC=icc
export CXX=icpc
export FC=ifort
export CFLAGS="-mmic"
export CXXFLAGS=$CFLAGS
export FFLAGS=$CFLAGS
export MPI_C=mpiicc
export MPI_CXX=mpiicpc

cd opencv
mkdir release && cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$HOME/lib/opencv-3.1.0 -D WITH_GTK=ON 
-DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DWITH_CUDA=OFF 
-DCMAKE_TOOLCHAIN_FILE=../cmake_files/cmake_template.cmake  ..

when i call make, it returns

[  2%] Building C object 3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_packbits.c.o
[  2%] Building C object 3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_pixarlog.c.o
/home/spm1407/backup/opencv-3.1.0/3rdparty/libtiff/tif_pixarlog.c(93): catastrophic error: cannot open source file "zlib.h"
  #include "zlib.h"
                   ^

compilation aborted for /home/spm1407/backup/opencv-3.1.0/3rdparty/libtiff/tif_pixarlog.c (code 4)

How can i resolve??
Thanks

0 Kudos
7 Replies
Gregg_S_Intel
Employee
149 Views

Were the libraries built with -mmic option?  All of the objects have to be k1om.

Maurizio_I_
Beginner
149 Views

Gregg S. (Intel) wrote:

Were the libraries built with -mmic option?  All of the objects have to be k1om.



Gregg, i tried to compile OpenCv with -mmic but it fails. What's means " All of the objects have to be k1om" ??

Thanks

Gregg_S_Intel
Employee
149 Views

The first generation Intel Xeon Phi coprocessor has a unique instruction set.  Every object in the link command has to have been built with -mmic option.  The "skipping incompatible" messages means those libraries were not built with -mmic.

Maurizio_I_
Beginner
149 Views

Gregg, thank you! Ok, so i compile all libraries with mmic, such as opencv. Please, can you help me?

FFMPEG is compileg with icc -mmic, in fact when i call ffmpeg, program returns
 

ffmpeg version N-80186-g39c0b22 Copyright (c) 2000-2016 the FFmpeg developers
  built with icc (ICC) 15.0.2 20150121
  configuration: --prefix=/home/spm1407/ffmpeg_build --bindir=/home/spm1407/bin --enable-shared --disable-yasm --enable-pic --enable-cross-compile --arch=x86_64 --target-os=linux --cc=icc --cxx=icpc
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 44.100 / 57. 44.100
  libavformat    57. 37.101 / 57. 37.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.100 /  6. 46.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

I tried to compile OpenCV but it returns many errors. I resolve almost all errors, but one is relative to x86_64-k1om-linux-ld, if fact build returns

x86_64-k1om-linux-ld: cannot find -lbz2
x86_64-k1om-linux-ld: cannot find -lgtk-x11-2.0
x86_64-k1om-linux-ld: cannot find -lgdk-x11-2.0
x86_64-k1om-linux-ld: cannot find -latk-1.0
x86_64-k1om-linux-ld: cannot find -lgio-2.0
x86_64-k1om-linux-ld: cannot find -lpangoft2-1.0
x86_64-k1om-linux-ld: cannot find -lgdk_pixbuf-2.0
x86_64-k1om-linux-ld: cannot find -lpangocairo-1.0
x86_64-k1om-linux-ld: cannot find -lcairo
x86_64-k1om-linux-ld: cannot find -lpango-1.0
x86_64-k1om-linux-ld: cannot find -lfreetype
x86_64-k1om-linux-ld: cannot find -lfontconfig
x86_64-k1om-linux-ld: cannot find -lgobject-2.0
x86_64-k1om-linux-ld: cannot find -lgmodule-2.0
x86_64-k1om-linux-ld: cannot find -lgthread-2.0
x86_64-k1om-linux-ld: cannot find -lglib-2.0
x86_64-k1om-linux-ld: cannot find -lgstbase-0.10
x86_64-k1om-linux-ld: cannot find -lgstreamer-0.10
x86_64-k1om-linux-ld: cannot find -lxml2
x86_64-k1om-linux-ld: cannot find -lgobject-2.0
x86_64-k1om-linux-ld: cannot find -lgmodule-2.0
x86_64-k1om-linux-ld: cannot find -lgthread-2.0
x86_64-k1om-linux-ld: cannot find -lglib-2.0
x86_64-k1om-linux-ld: cannot find -lgstbase-0.10
x86_64-k1om-linux-ld: cannot find -lgstreamer-0.10
x86_64-k1om-linux-ld: cannot find -lxml2
x86_64-k1om-linux-ld: cannot find -lavcodec
x86_64-k1om-linux-ld: cannot find -lavformat
x86_64-k1om-linux-ld: cannot find -lavutil
x86_64-k1om-linux-ld: cannot find -lswscale
make[2]: *** [bin/opencv_perf_core] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
make: *** [all] Error 2

I build OpenCv with 

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$HOME/lib/opencv-3.1.0 -D WITH_GTK=ON  -DCMAKE_TOOLCHAIN_FILE=../cmake_files/cmake_template.cmake  -DCMAKE_C_FLAGS=-mmic -DCMAKE_CXX_FLAGS=-mmic  -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_PNG=OFF  -DBUILD_LIBJPEG=ON -DBUILD_SHARED_LIBS=OFF  ..


Any suggest? Thanks

Gregg_S_Intel
Employee
149 Views

You find some or all of the libraries you need compiled with -mmic here:

https://software.intel.com/en-us/articles/intel-and-third-party-tools-and-libraries-available-with-s...

 

Gregg_S_Intel
Employee
149 Views

See especially the tar file "Software for Coprocessor OS (k1om)" available with Intel® Manycore Platform Software Stack (Intel® MPSS).

https://software.intel.com/en-us/articles/intel-manycore-platform-software-stack-mpss

Gregg_S_Intel
Employee
149 Views

 To be clear, what I'm saying is you need k1om versions of each and every one of those libraries.  All objects in the link have to be k1om; that is, built with -mmic.

Reply