Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

beginners guide to use mkl with ivf

peter_cool14
Beginner
1,494 Views
Can somebody help me how to use mkl with ivf 11.0 on a 64 bit computer (this might not matter). As I see it why should i use command line when im using visual fortran. Every user says i ran this on command line...... This kinda scares me. I dont know anything about computer internals and i dont want to waste my time learning that. Come on guys Fortran is intended for engineering and scientific calculations and it looks to me like i should include all the paths, libraries etc etc. This really sucks. I think it is time to switch to Matlab. When you install Matlab its just ready to do everything. But installing Intel'sFortran is a pain at the first place and after installation there are tons of other headaches. A kid might want to use ivf as is, for adding and subtracting numbers. But without mkl and array visualizer doesnt make sense to me. And moreover the documetation is not on the same page ofall operating systems(like a 64 bit ). The documentation is absolutely outdated. Before selling ivf you should warn buyers ! This is only meant for advanced computer users !
0 Kudos
25 Replies
ArturGuzik
Valued Contributor I
1,302 Views
Quoting - peter_cool14
Can somebody help me how to use mkl with ivf 11.0 on a 64 bit computer (this might not matter). As I see it why should i use command line when im using visual fortran. Every user says i ran this on command line...... This kinda scares me. I dont know anything about computer internals and i dont want to waste my time learning that. Come on guys Fortran is intended for engineering and scientific calculations and it looks to me like i should include all the paths, libraries etc etc. This really sucks. I think it is time to switch to Matlab. When you install Matlab its just ready to do everything. But installing Intel'sFortran is a pain at the first place and after installation there are tons of other headaches. A kid might want to use ivf as is, for adding and subtracting numbers. But without mkl and array visualizer doesnt make sense to me. And moreover the documetation is not on the same page ofall operating systems(like a 64 bit ). The documentation is absolutely outdated. Before selling ivf you should warn buyers ! This is only meant for advanced computer users !
Peter,

sure you can get help but please do provide some details so that help can be better addressed. I mean:

(1) system/platform (ivf means Windows, right? but XP or Vista)
(2) which processor architecture do you have -> Intel 64 or IA64 (Itanium)?
(3) if answer in (1) is Windows, which version of Visual Studio you have? 2005/2008/PE or something else (Eclipse?)

Installing on Windows is pretty straightforward (at least with the latest installer). If you have Visual Studio NO COMMAND line is required. For 64-bit you need to manually add the include and lib folders for the MKL, if installed, to Visual Studio using the Tools > Options > Intel Fortran > Compilers dialog.

just add in libraries tab
$(IFortInstallDir)mklem64tlib

and include tab
$(IFortInstallDir)mklinclude

this will let linker know where to look for libs and include files. This is well described in Release Notes (page 6). These installation issues will be fixed in the next release (Intel claims).

From page 5:

4.2 Configure Visual Studio for 64-bit Applications
If you are using Microsoft Visual Studio 2005* or 2008 and will be developing 64-bit applications (for the Intel 64 or IA-64 architectures) you may need to change the configuration of Visual Studio to add 64-bit support.

If you are using Visual Studio 2005/2008 Standard Edition or Visual Studio 2005 Premier Partner Edition, no configuration is needed to build Intel 64 architecture applications.

For other editions:
1.From Control Panel > Add or Remove Programs, select Microsoft Visual Studio 2005 (or 2008) > Change/Remove. The Visual Studio Maintenance Mode window will appear. Click Next.
2. Click Add or Remove Features
3. Under Select features to install, expand Language Tools > Visual C++
4.If the box X64 Compiler and Tools is not checked, check it, then click Update. If the box is already checked, click Cancel.
To use Microsoft Visual Studio 2005/2008 Team System Edition to build applications to run on IA-64 architecture systems, follow the above steps and ensure that the box Itanium Compiler and Tools is checked.

A.
0 Kudos
Gennady_F_Intel
Moderator
1,302 Views
Peter, as an additional to the Artur's comment,
probably will helps for you to look at the mkls user guide. See chapter 4, Configuring Intel Visual Fortran to Link with Intel MKL.
--Gennady

0 Kudos
peter_cool14
Beginner
1,302 Views
Thanks Arthur

Info about my computer

Os : windows vista business; intel 64; visual studio 2005 version 8.0.50727.867 (it came with ivf)

I did what you said, adding to that, Gennedy's suggestion.

when i tried to compile an example (caxpyix.f) from mkl folder i get the following

1 fatal error LNK1104: cannot open file 'mkl_c.lib:'

the one ilooked upis the 'userguide' in mkl folder.

where the heck is this file 'mkl_lib.c' and why i was instructed to do so if it wasnt there!
0 Kudos
ArturGuzik
Valued Contributor I
1,302 Views
Quoting - peter_cool14
Thanks Arthur

Info about my computer

1 fatal error LNK1104: cannot open file 'mkl_c.lib:'

Hi Peter,

if you see this error, you're making a real progress:-). The reason you got this is that you're trying to build on x64. The mkl_c.lib contains CDECL calling convention version (mkl_s.lib is STDCALL counterpart) support, which is valid for Win32 environment/builds only (so if you're later building version for IA32, it should be fine). What you need is ***_lp64.lib or **_ilp64.lib. See examples in User's Guide but pay attention to architecture (on x64 system there is more combination, in general, because you can run both 32 and 64 versions of your program, which is actually nice).

Taking example from Guide (static linking of users code with Fortran 95 BLAS interface, and parallel Intel
MKL supporting LP64 interface):

libiomp5md.lib mkl_intel_lp64.lib mkl_blas95.lib mkl_intel_thread.lib mkl_core.lib


I find usefull Table 5-3 Computational libraries to link, by function domain on page 5-9, which shows also the differences between architectures.

libiomp5md.lib is RTL library which should use with new apps you're building.

I'm not sure now to which folder you pointed Visual Studio (for which architecture).

You can simply copy the line (following our example) to Additional Dependencies command, that is, copy, say,

libiomp5md.lib mkl_intel_lp64.lib mkl_blas95.lib mkl_intel_thread.lib mkl_core.lib

To Project->properties->Linker->Input->Additional Dependencies


A.
0 Kudos
peter_cool14
Beginner
1,302 Views
Thanks Arthur

But I got upto that level 4hrs ago :-). I used the 1st point in the section "Linking on systems based on Intel 64 architechture"

And now I get following errors
1. unresolved external symbol MAXVALUE referenced in function MAIN_
2. unresolved external symbolPRINTVECTORC referenced in function MAIN_
0 Kudos
ArturGuzik
Valued Contributor I
1,302 Views
Quoting - peter_cool14
And now I get following errors
1. unresolved external symbol MAXVALUE referenced in function MAIN_
2. unresolved external symbolPRINTVECTORC referenced in function MAIN_

Well, they call it "learning the hard way" but once you go through...

These routines do not look as if they're part of MKL (are they?) so you have some linking problem(s) (or Module visibility) with your own code. The thing is that linker doesn't know where to find definitions of Maxvalue, and PrintvectorC in Main Program unit (where you call them). Are they in other library/portion of the code? Did you include (add) all required files to the project?

A.
0 Kudos
peter_cool14
Beginner
1,302 Views
Arthur,

This is the very first example in mklexamplesblassourcecaxpyx.f

The file in bold letter is the one that i've added to the project. I am assuming that you have the same path in your computer.

0 Kudos
ArturGuzik
Valued Contributor I
1,302 Views
Quoting - peter_cool14
Arthur,

This is the very first example in mklexamplesblassourcecaxpyx.f

The file in bold letter is the one that i've added to the project. I am assuming that you have the same path in your computer.

OK.

The trick is:

* External Subroutines
external CAXPYI, MaxValue, PrintVectorC
*
so....

you need to add to project file common_func.f file (from the same folder). This file contains the definitions of these (maxvalue, printvectorc) routines. Please note, that you can use standard Fortran function MaxVal() and PRINT *,.... to replace them. I have to agree with you on that this example is not so straightforward to build:-). Once you start the program it seems to hang, but this is because it waits for user input. You just started ...hard way.

The suggestions for Intel MKL would be -- include a simple VS project (for windows platform) to make a start easier.

A.

0 Kudos
peter_cool14
Beginner
1,302 Views
You are right Arthur. I started the hard way( example). :-)

0 Kudos
peter_cool14
Beginner
1,302 Views
Gosh! I've deleted source files(caxvyx.f), in an attemp to try other examples. I gotta reinstall ivf again.
Thanks a lot Arthur.

If you wish to reply now, i'l be here (anyways)


0 Kudos
ArturGuzik
Valued Contributor I
1,302 Views
Quoting - peter_cool14
Gosh! I've deleted source files(caxvyx.f), in an attemp to try other examples. I gotta reinstall ivf again.
Thanks a lot Arthur.
Don't reinstall compiler!!! You just deleted example sources from MKL. Just copy them back (from CD).

Try to build your own program which calls something from MKL. This particular example you selected (caxvyx.f) is not too good (data etc.) to demostrate the power of MKL.


A.
0 Kudos
peter_cool14
Beginner
1,302 Views
That is a good suggestion

However i've a download version. So I can not restist resinstalling again.

I've done resinstallation already. Got the file back!

0 Kudos
ArturGuzik
Valued Contributor I
1,302 Views

Hi,

absolutely nothing (wrong) or at least I don't see it. You just passed your break point and (as no errors were encountered!) the program terminated and console window closed. That because you're running it in debug mode.

Select Customize->Commands->Debug-> find and drag onto your toolbar button Start without debugging (green empty triangle, similar to that one you already have). Then (running without debugging) console window won't close.

(a) Other option -> just put second break point at the very end so you'll have a chance to examine "c"

(b) or print results to file.

A.
0 Kudos
peter_cool14
Beginner
1,302 Views

Hi Arthur,

There was a small miscommunication. I did not mention that i started without debugging for the first time(which i always do). Also there was a 'write' command right after the 'call' command in the code. this can be seen in the new files i am attaching.

I tried doing the two things you mentioned. Not to my surprise I was not able to print the results. It wasnt surprise to me becasue I tired to convert a huge fortran code into a subroutine that passes some values. It did not work either.

I think something is wrong with the settings of my compiler or may be not.

Please find the attached screenshot of my code.

More info on attached files: 1st attachment is the onewhen i start without debugging
2nd attachment is the one when i start debugging
For your convinience i am pasting the data i've used (if you wanna run this code on your computer)

data a/1.0,2.0,1.0,-3.0,4.0,-1.0, 2.0,0.0,-1.0,2.0,0.0,-1.0, -1.0,1.0,-1.0,2.0,0.0,-1.0, -1.0,1.0,1.0,2.0,1.0,-3.0, 4.0,-1.0,2.0,0.0,-1.0,2.0/
data b/1.0,2.0,1.0,-3.0,4.0, -1.0,2.0,0.0,-1.0,2.0, 0.0,-1.0,-1.0,1.0,-1.0, 2.0,-2.0,1.0,-1.0,1.0/
data c/0.5,0.5,0.5,0.5,0.5,0.5, 0.5,0.5,0.5,0.5,0.5,0.5, 0.5,0.5,0.5,0.5,0.5,0.5, 0.5,0.5,0.5,0.5,0.5,0.5/

Appreciate your help
0 Kudos
peter_cool14
Beginner
1,302 Views
Hi Arthur,

It seems to be a problem with 'lda' which is the 8th parameter. when i give any other value greater than 6 (say 8) it gives me following error message on the output screen.

mkl error: parameter 8 was incorrect on entry to sgemm
press any key to continue


0 Kudos
Peter
Beginner
1,302 Views
Artur,

I think im getting there. I believe i did not add the paths properly.

For the object file 'libiomp5md.lib', i did not specify the path correctly. It is in a different folder
The first path I've addedintoolsoptionsinterlvisuallfortrancompilerslibraries

$(IFortInstallDir)mklem64lib == C:Program Files (x86)IntelCompiler11.0�72fortranmklem64tlib (if i am correct)

So I still have to include a second path for the file 'libiomp5md.lib' which is in the following folder
C:Program Files (x86)IntelCompiler11.0�72fortranlibintel64

I made this equivalent to $(IFortInstallDir)libintel64 and added to the libraries.

Similarly I added this in the 'additional library directories' of linkergeneral in the normal way ("C:Program Files (x86)IntelCompiler11.0�72fortranlibintel64")

Now i slightly modifed the code
i declared
integer largedima
largedima=6
...
.....
......
call sgemm('n','n',6,4,5,alpha,a,largedima,beta,b,5,c,6)

which now returns the following error

error mkl: parameter 8 was wrong input to sgemm

earlier it used to be the same number (=6) however i did not declare as integer type, instead i used it directly in the sgemm() routine.

Appreciate your help
0 Kudos
ArturGuzik
Valued Contributor I
1,302 Views
Quoting - peter_cool14
Now i slightly modifed the code
i declared
integer largedima
largedima=6
...
.....
......
call sgemm('n','n',6,4,5,alpha,a,largedima,beta,b,5,c,6)


Peter,

if you get there (that MKL reports error in arguments) we're very close. So the good news is that you made it working (as far as MKL is concerned).

Could you attach the source of your example. I can take a look at this later (without retyping)

A.


0 Kudos
Peter
Beginner
1,302 Views
Artur,

Please find the attached code in a text file. I am attaching a text document and original source code. Just to make sure you get get the file.


0 Kudos
ArturGuzik
Valued Contributor I
1,105 Views
Quoting - peter_cool14
Artur,

Please find the attached code in a text file.

Please find attached file (source). I put some comments inside the code. Use DGEMM for double precision input data (or Fortran 95 interface, so it can recognize the type and call appriopriate version).

A.
0 Kudos
Reply