0

I compiled GMP with icc and -mmic option, but can't install on MIC. How should I install? I wrote a demo program, compiled with icc. It says can't find gmp.h. How should I install GMP library on MIC and where to place gmp.h?

Boppity Bop
  • 9,613
  • 13
  • 72
  • 151
  • What is your operating system, where you compiled GMP ? – Grzegorz Szpetkowski Feb 26 '14 at 13:42
  • RedHat Enterprise 6.3. I compiled on CPU with CC=icc CFLAGS=-mmic. But I don't know how to install to Xeon phi – user3346400 Feb 26 '14 at 14:32
  • 1
    "can't install": what failed? "can't find gmp.h": do you know about the `-I` flag? It doesn't matter where you put `gmp.h` as long as you tell the compiler where to find it. You can add `-v` to the command line to see where the compiler looks for stuff by default. – Marc Glisse Feb 26 '14 at 14:41

2 Answers2

1

Build GMP with Intel Compiler:

cd /home/
wget https://gmplib.org/download/gmp/gmp-6.0.0.tar.bz2
tar -xf gmp-6.0.0.tar.bz2
rm -f gmp-6.0.0.tar.bz2
cd gmp-6.0.0
mkdir mic
cd mic
../configure CC=icc CFLAGS="-mmic" --host=x86_64 --disable-assembly --prefix /home/gmp-6.0.0/mic/
make
make install

Use the Intel Compiler with environment variables for mic development:

GMP_INCDIR=/home/gmp-6.0.0/mic/include
GMP_LIBDIR=/home/gmp-6.0.0/mic/lib
mancoast
  • 31
  • 2
0

Though I don't have any expertize on Xeon Phi or even ICC if you are running on Unix-like environment, then you might to try to step through normal configure/make procedure on GMP sources pointing on ICC compiler instead of default GCC in order to build static and/or shared library along with generated gmp.h header, that you can then link with your application. You might want to see GMP documentation on that. Here are some advices, that I stepped to trying to compile it for NVIDIA CUDA:

  1. Supply ./configure with CC and CFLAGS variables to point to desired compiler and its whatever options that you want
  2. Be sure that there is no ABI incompability between your host and Xeon Phi device, especially between 32 and 64 bit architecture.
  3. Consider adding --disable-assembly option to generate "pure-C" build (I am not familiar with Xeon Phi assembly and if/how it is compatibile with x86)
  4. Don't forget to run make check (possibly with -j parameter) after you compiled GMP in order to check if tests are passing, it's very important step if you want use it for some professional purpose.

The library is installed in OS by make install command, for default under /usr/local directory (you might add --prefix option if you want it somewhere else), specifically:

  • /usr/local/include for gmp.h header file
  • /usr/local/lib for static and/or shared libgmp binaries

You might also try to compile your application with mini-gmp package, which is contained within GMP sources (it's located under mini-gmp directory). It's a subset of mpz_* and mpn_* routines, not as sophisticated and fast as normal GMP (and it doesn't have as much serious tests coverage), but it could make the job done with small footprint (it's contained in one header and C-source file). For such option be sure to obtain most recent version of GMP (or even get it from their repository).

Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137
  • THank you very much for your answer. I compiled and install GMP using gcc before on Xeon, and it's a success. I want to use GMP on Xeon phi instead of Intel MKL, so I have this problem.. – user3346400 Feb 26 '14 at 14:30
  • The compile targeted for Xeon phi is a success with CC=icc CFLAGS=-mmic. And I found something I didn't notice from your answer – user3346400 Feb 26 '14 at 14:31