Porting Linux* VMSTAT and Open Source Tools to Intel® Xeon Phi™ Coprocessor:


Since the micro-os running on Intel® Xeon Phi™ is based on Linux Open source kernel, it may be possible in many cases to port existing open source Linux* tools to the native micro-os environment without enormous effort. Vmstat is an open source tool which is useful for monitoring system wide memory and resource usage.  In this blog I shall share how you can build this tool of your own, using minimum changes for cross compilation. To do this I downloaded procps 3.2.7  version from the source forge location http://procps.sourceforge.net/download.html .

Located inside the procps3.2.7 folder is the make file.  Where I modified the following lines:
CC=icc
CFLAGS       := -mmic -O2 -s
LDFLAGS      := -mmic

I modified the 

#ALL_CFLAGS   := $(PKG_CFLAGS) $(CFLAGS)
And replaced with ALL_CFLAGS   :=  $(CFLAGS)

as PKG_CFLAGS contains flags related to gcc compiler whereas I am using the Intel® compiler icc.

Set the path to include Intel Composer XE by source /opt/intel/composerxe/bin/compilervars.sh, assuming someone has installed the compiler at the default path on the system. Now execute the make.

> make vmstat

This will build the vmstat binary for you that you can run on Linux* prompt on the micro-OS running on Intel® Xeon Phi™ coprocessor.

The build will give out some warnings as shown below which you can ignore as those will be discovered in the micro-os environment inside the coprocessor.

x86_64-k1om-linux-ld: warning: libimf.so, needed by proc/libproc-3.2.7.so, not found (try using -rpath or -rpath-link)
x86_64-k1om-linux-ld: warning: libsvml.so, needed by proc/libproc-3.2.7.so, not found (try using -rpath or -rpath-link)

You can mount the vmstat binary folder or send the built vmstat and relevant library to mic0. Now log into the mic-os console by running:
>ssh mic0:

Set the load library path to include the proc folder under the build directory which contains libproc-3.2.7.so dynamic link library and also include path to Intel(R) MIC architecture libraries.
> export LD_LIBRARY_PATH=$PWD/proc:$LD_LIBRARY_PATH;
 
Now you can run the vmstat on the micro-os environment. Following is an output from vmstat run inside the micro-os while running an offload application on the Intel® Xeon Phi™. It was running at 1 second interval. The application started running when column ‘r’  started showing ‘3’.  Information on vmstat output can be found here: https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/4/html/Introduction_To_System_Administration/s2-resource-tools-vmstat.html


 
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0      0 7497992      0  97408    0    0     0     0   98   98  0  1 99  0
 2  0      0 7497952      0  97408    0    0     0     0   90  191  0  1 99  0
 1  0      0 7195016      0 395432    0    0     0     0 4197  228  0  2 98  0
 3  0      0 6747936      0 641880    0    0     0     0 48268 5232  1  0 99  0
 3  0      0 6746680      0 642084    0    0     0     0 33136 1156 91  2  8  0
 3  0      0 6746680      0 642084    0    0     0     0 33388 1303 91  2  7  0
 1  0      0 6893048      0 642084    0    0     0     0 18005  808 84  3 12  0
 0  0      0 6893112      0 642084    0    0     0     0  187  110  0  8 92  0
 

 


Have you built any open source tool for Intel® Xeon Phi™? If so please post your effort here. My goal is to  build a list of available open source tools here that will help the Intel® Xeon Phi™ community to be aware of what is already being done and work with each other to build a strong tool set.
 

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.