- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've freshly installed the Intel® Parallel Studio XE Composer Edition for Fortran OS X* (student version). It comes with the Math Kernel Library, which is why I bought it. I'm having a hard time getting started with MKL though. Here's what I've done step-by-step. (sorry for the beginner question, this is probably really obvious to everyone else here).
1) Installed Intel® Parallel Studio XE Composer Edition for Fortran OS X* (no problem). I can run a 'hello world' script using ifort
and throw the -mkl
link command on at the end with no problem (not calling any mkl commands just yet).
2) Following these instructions I set my environment variables using a script provided by intel (located in opt/intel/bin to be precise). I have the intel 64-bit architecture (according to ifort -V
) so I navigate to opt/intel/mkl/bin and run bash mklvars.sh intel64 mod ilp64
. It runs without error (or any output, I assume it's working).
3) I write the following code to use MKL's gemm command for fortran95. Just multiplying 2 matrices.
program test implicit none real, dimension(2,2) :: testA, testB, testC testA = 1 testB = 1 testC = 0 ! I don't think I need this line, but it shouldn't matter call gemm(testA, testB, testC) write(*,*) testC end program test
4) I compile with ifort test_mkl.f90 -o test -mkl
. I get the following error:
Undefined symbols for architecture x86_64:
"_gemm_", referenced from:
_MAIN__ in ifortSTVOrB.o
ld: symbol(s) not found for architecture x86_64
5) I try ifort test_mkl.f90 -o test -L/opt/intel/mkl/lib -mkl
and get the same result.
6) If I add the line USE mkl95_blas, ONLY: gemm
, above implicit none
in both of the above examples I get:
test_mkl.f90(4): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MKL95_BLAS]
USE mkl95_blas, ONLY: gemm
--------^
test_mkl.f90(12): error #6406: Conflicting attributes or multiple declaration of name. [GEMM]
call gemm(testA, testB, testC )
---------^
test_mkl.f90(4): error #6580: Name in only-list does not exist. [GEMM]
USE mkl95_blas, ONLY: gemm
--------------------------^
compilation aborted for test_mkl.f90 (code 1)
If your curious, I have successfully run this example script in XCODE using MKL, so it's definitely something I'm doing and not my installation. Specifically, my .mod files are built and are in the directories in the Include statement below (generate the same error as above).
ifort test_mkl.f90 -I/opt/intel/mkl/include/intel64/ilp64 -L/opt/intel/mkl/lib/ -mkl -lmkl_blas95
ifort test_mkl.f90 -I/opt/intel/composer_xe_2015.3.187/mkl/include/intel64/ilp64 -L/opt/intel/composer_xe_2015.3.187/mkl/lib/
ifort test_mkl.f90 -I/opt/intel/composer_xe_2015.3.187/mkl/inlcude/intel64/ilp64 -L/opt/intel/composer_xe_2015.3.187/mkl/lib/ -mkl -lmkl_blas95
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are a bit lax in using Blas/Lapack routines through Fortran 95 interfaces. When you use Blas95/Lapack95 routines such as gemm(), you must provide an interface. Failing to do so will give linker errors, at least.
Secondly, the name of the module that supplies the interface should match the name of the module included in your specific version of MKL. Look at the names in the mkl/include/intel64/ilp64 directory or in the table "Interface Libraries and Modules" in the MKL user guide. I think that the file name is blas95.mod (I don't have OSX, so check this), so you should say USE BLAS95.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are a bit lax in using Blas/Lapack routines through Fortran 95 interfaces. When you use Blas95/Lapack95 routines such as gemm(), you must provide an interface. Failing to do so will give linker errors, at least.
Secondly, the name of the module that supplies the interface should match the name of the module included in your specific version of MKL. Look at the names in the mkl/include/intel64/ilp64 directory or in the table "Interface Libraries and Modules" in the MKL user guide. I think that the file name is blas95.mod (I don't have OSX, so check this), so you should say USE BLAS95.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks mecej4,
Changing the USE statement allowed me to compile. I then ran into the problem from this thread and had to run the terminal command:
source /opt/intel/composer_xe_2015.3.187/mkl/bin/mklvars.sh intel64
It works, but I'm curious if that 'source' command took care of the interface issues you mentioned?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ben, Mecej4,
Thanks for raising and answer the problems. It seems the Fortran 95 interface bring a lot of trouble here.
For beginner, I recommend you to build and run the example code under MKL install folder. /opt/intel
For example, under Linux (similar as Mac OS),
>cp /opt/intel/composer_xe_2015.2.164/mkl/examples/examples_f95.tgz .
>tar -xzvf examples_f95.tgz
GEMM sample code is:
> vi blas95/source/dgemmx.f90
program DGEMM_MAIN
use f95_precision, only: wp => dp
use blas95, only: gemm
implicit none
1. if you'd like try Fotran Blas 95 interface, the blod is needed. please also check the name as mecej4 mentioned. It should be same name as the *.mod file
[yhu5@prc-mic01 lp64]$ ls
blas95.mod f95_precision.mod lapack95.mod mkl_service.mod
[yhu5@prc-mic01 lp64]$ pwd
/opt/intel/composer_xe_2015.2.164/mkl/include/intel64/lp64
2. build and run the sample.
2.1 source compiler, which include ifort and mkl environment setting.
[yhu5@prc-mic01 lp64]$ source /opt/intel/composer_xe_2015.2.164/bin/compilervars.sh intel64
[yhu5@prc-mic01 lp64]$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.2.164 Build 20150121
Copyright (C) 1985-2015 Intel Corporation. All rights reserved.
2.2 build the sample
[yhu5@prc-mic01 blas95]$ make sointel64 function=dgemmx
make dgemmx.res EXT=so _IA=intel64 RES_EXT=so
make[1]: Entering directory `/home/yhu5/mkl_example/blas95'
mkdir -p ./_results/intel_lp64_parallel_intel_iomp5_intel64_so
ifort -I /opt/intel/composer_xe_2015.2.164/mkl/include/intel64/lp64 -w source/dgemmx.f90 source/common_func.f /opt/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_blas95_lp64.a -L"/opt/intel/composer_xe_2015.2.164/mkl/lib/intel64" -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -L"/opt/intel/composer_xe_2015.2.164/mkl/../compiler/lib/intel64" -liomp5 -lpthread -ldl -o _results/intel_lp64_parallel_intel_iomp5_intel64_so/dgemmx.out
Notes: please make sure
1. you have libmkl_blas95_lp64.a installed.
2. ifort -mkl = -L"/opt/intel/composer_xe_2015.2.164/mkl/lib/intel64" -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -L"/opt/intel/composer_xe_2015.2.164/mkl/../compiler/lib/intel64" -liomp5 -lpthread -ldl
So Ben's command line should ok
ifort test_mkl.f90 -I/opt/intel/composer_xe_2015.3.187/mkl/inlcude/intel64/ilp64 -L/opt/intel/composer_xe_2015.3.187/mkl/lib/ -mkl -lmkl_blas95 (if libmkl_blas95.a is there).
3. regarding the functionality of source compilervars.sh intel64 before run the program or build the program.
It will set MKLROOT, MKL Include, library path, and run-time path etc. so you can build and run the code easily. Otherwise you need manually write all path in command line and also need to set below (if dynamic link. -mkl is dynamic link by default). at run time.
export LD_LIBRARY_PATH (DYLD_LIBRARY_PATH)="/opt/intel/composer_xe_2015.2.164/mkl/lib/intel64":"/opt/intel/impi/4.1.2.040/intel64/lib:/opt/intel/composer_xe_2015.2.164/compiler/lib/intel64:/opt/intel/mic/coi/host-linux-release/lib:/opt/intel/mic/myo/lib:/opt/intel/composer_xe_2015.2.164/mpirt/lib/intel64:/opt/intel/composer_xe_2015.2.164/ipp/../compiler/lib/intel64
4. About ILP64 and LP64, 32bit or Intel 64. You may read the MKL user guide for more details.
https://software.intel.com/en-us/articles/intel-math-kernel-library-documentation
Best Regards,
Ying

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page