beginners guide to use mkl with ivf

beginners guide to use mkl with ivf

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 !

26 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

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

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!

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.

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_

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.

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.

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.

You are right Arthur. I started the hard way( example). :-)

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)

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.

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!

Quoting - peter_cool14

Hi Arthur,

Well, I tried to create my own program, a simple matrix multiplication. Everything worked good, except when im trying to write output the program stops and closes. Below is my code. Please see what is wrong!


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.

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

Attachments: 

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

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.072fortranmklem64tlib (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.072fortranlibintel64

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.072fortranlibintel64")

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

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.

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.

Attachments: 

AttachmentSize
Downloadtext/plain New_Text_Document.txt580 bytes
Downloadapplication/octet-stream Source1.F90510 bytes

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.

Attachments: 

AttachmentSize
Downloadapplication/octet-stream Peter.F901.13 KB

Artur,

I still get the same error. But now I know what was wrong.

I succesfully solved 3 equations 3 unknowns using Lapack(sgesv), not contempt yet.

I'l try to solve it on my own (genmm). I know my code was right (but not perfect). The problem is adding paths, i mean it is a complier thing.

Anyways, thanks a lot for your help throughout. I owe a beer :-)

I'l post back once i get that right.

Artur,

And finally it worked.

The lesson i've learnt so far is be very careful when giving the .lib files in linkerinput tab.

The reason why my last code that calls sgemm did not work was because i used .lib files for parallel codes instead of sequential computing. I am glad I have basic idea what parallel and sequential computing is.

Quoting - peter_cool14

I succesfully solved 3 equations 3 unknowns using Lapack(sgesv), not contempt yet.

I'l try to solve it on my own (genmm). I know my code was right (but not perfect). The problem is adding paths, i mean it is a complier thing.

Peter,

I took a closer look. Your call is wrong and the arguments are incorrect (as MKL reports).

MKL definitions

call dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

and your

call dgemm('n', 'n', 6, 4, 5, alpha, a, largedima, beta, b, 5, c, 6)

This must be the case:

(1) your solved other example using LAPACK (which means your paths are OK)

(2) you build and linked this example (which means library found, no compilation and linking errors)

so the only thing remaining to check was... your source. Dimensions are OK, you just replaced B with beta. Correct this and should be fine.

A.

PS. This comes from editor, as it does not recognize Fortran syntax. It supposed to be bold

Quoting - peter_cool14

And finally it worked.

The lesson i've learnt so far is be very careful when giving the .lib files in linkerinput tab.

Peter,

glad to hear that. I didn't see your last post(s) when I replied and then yours were inserted (it happens on Intel forums).

Sure, with libs you have to be carefull.

best wishes

A.

Artur,

you are right regarding the parameters (beta). yes i changed them in the latest code and it worked. I messed with the inputs.

My previous reply regarding, setting files, adding paths made me learn some computer internals. I'l be using them frequently from now on. So hopefully I should have no problem.

Thanks again for stayin with me untill the end (for now) :-)

Leave a Comment

Please sign in to add a comment. Not a member? Join today