Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Herman_P_Intel
Employee
110 Views

Beginner's guide to compile MKL in windows10 without a full VS2015 installation

I would like to share my experience compiling MKL in windows 10 without a full VS2015 installation. Hopefully this will save some unnecessary trial and error efforts. Since I was doing it on my Intel laptop, which has a very precious and limited SSD space (unless you charge your department for an SSD upgrade), I cannot afford (>16GB) full VS2015 installation on my precious SSD.

Here are the steps:

1. You can get a full-fledge (>16GB installation) VS2015 from ISM (Intel Software Market). But I opted for visualcppbuildtools_full.exe from http://landinghub.visualstudio.com/visual-cpp-build-tools. Download and install it (You can skip the windows SDK to save disk space)

2. Download and install MKL from https://software.intel.com/en-us/intel-mkl

3. Assuming that no1 and no2 are installed to the default target directory. Edit "compilervar_arch.bat" in the following path: C:\IntelSWTools\compilers_and_libraries_2017.2.187\windows\bin\compilervars_arch.bat

(ie. comment out the existence check for devenv.exe, which I don't have without a full VS2015 installation; Left is the edit, right is the original file)

compilervars_arch.png

Now we are ready to play with some examples provided in the MKL installation: C:\IntelSWTools\compilers_and_libraries_2017.2.187\windows\mkl\examples

I would recommend unzipping it out and copying a small examples to your "My Documents" area

Let me walk you with one simple example. I will show you 3 ways of compiling it. Let's try out examples_core_c\cblas\. Copy out data\cblas_sgemm_batchx.d, source\cblas_sgemm_batchx.c, source\common_func.c, source\mkl_example.h, cblas.lst, makefile. Please maintain the same directory structure as in the example folder:

.\
|-- cblas.lst
|-- data
|   `-- cblas_sgemm_batchx.d
|-- makefile
|-- source
|   |-- cblas_sgemm_batchx.c
|   |-- common_func.c
|   `-- mkl_example.h

Open up a windows console: windows-R: cmd, cd into the folder you copied over that example, ie. when you dir, you should see makefile, cblas.lst, data, source. Then type the following:

(I have a 64bit windows10 hp laptop, which is a quite generic IntelIT laptop for every employee, hence the "intel64" at the end of the following line)

>call "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.2.187\windows\bin\compilervars.bat" intel64

This command will setup your environment variables. This will also call "compilervars_arch.bat", that in turn calls "vcvarsall.bat" (the VS2015 env var setup)

These are the 3 ways to compile:

1. Using nmake from VS2015, since the MKL example provides us a "makefile". I don't have icc on my machine, so I will just use cl.exe from VS2015

>nmake libintel64 function=cblas_sgemm_batch+ compiler=msvs /f makefile

The exe in under _results\ folder. Run this to checkout the exe

>_results\msvs_lp64_parallel_intel64_lib\cblas_sgemm_batchx.exe data\cblas_sgemm_batchx.d

2. Directly invoking cl.exe

>cl.exe /w /MT /Femy_cl /IC:\Users\hpandana\myhomedir\mkl_test\my_cl\source source\common_func.c source\cblas_sgemm_batchx.c mkl_core.lib mkl_intel_lp64.lib mkl_intel_thread.lib libiomp5md.lib

(some explanations: /Fe specifies my output exe filename, eg. my_cl.exe in this example; I copied over that example to this path: C:\Users\hpandana\myhomedir\mkl_test\my_cl, so please edit your /I include path accordingly. This method does not require "makefile", and its supporting "cblas.lst" file)

C:\Users\hpandana\myhomedir\mkl_test\my_cl\
|-- data
|   `-- cblas_sgemm_batchx.d
`-- source
    |-- cblas_sgemm_batchx.c
    |-- common_func.c
    `-- mkl_example.h

Just like before, to try out the exe:

>my_cl.exe data\cblas_sgemm_batchx.d

3. Using gcc. I have the strawberry perl (from ISM) installed, that comes with gcc. Any mingw gcc should work as well. Again it is installed at the default target directory (ie. C:\strawberry). I copied over the example again:

C:\Users\hpandana\myhomedir\mkl_test\my_gcc\
|-- data
|   `-- cblas_sgemm_batchx.d
`-- source
    |-- cblas_sgemm_batchx.c
    |-- common_func.c
    `-- mkl_example.h

(please edit the -I include paths, and -L libpaths in the following line accordingly)

>gcc.exe -o my_gcc -IC:\strawberry\c\include -I"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.2.187\windows\mkl\include" -IC:\Users\hpandana\myhomedir\mkl_test\my_cl\source -LC:\strawberry\c\lib -LC:\strawberry\c\lib\gcc\x86_64-w64-mingw32\4.7.3 -L"C:\IntelSWTools\compilers_and_libraries_2017.2.187\windows\redist\intel64_win\mkl" -L"C:\IntelSWTools\compilers_and_libraries_2017.2.187\windows\redist\intel64_win\compiler" source\common_func.c source\cblas_sgemm_batchx.c -lmkl_core -lmkl_rt -lmkl_intel_thread -liomp5md

Again, to try out the exe:

>my_gcc.exe data\cblas_sgemm_batchx.d

That's all. Hope it helps

 

Thanks,
Herman

0 Kudos
1 Reply
Zhen_Z_Intel
Employee
110 Views

Hi Herman, 

Thanks for sharing the experience. I think it would be helpful if some guy would like to compile MKL or other Intel library without VS full package installation, they probably could refer this case.

regards,
Fiona