MKL use and linking

MKL use and linking

I'm trying to using the MKL routine in a code.
In fact i'm interested in evaluating the gradient of a certain function.
Previously, when i had at disposal the IMSL libraries, i used the IMSL function CDGRD.
Now i need to use the MKL. As i understand there is not a similar function in the MKL library, but the gradient can be obtained by using the MKL routine evaluating the jacobian of a one value function.
Regarding this point i haven't understand which function i have to use between djacobi_solve and djacobi.
I tried to use both by following the examples reported in the manual.

1) Djacobi :
I used the following command:
res=djacobi(FCN_2,1,NUNK,gnew(1:NUNK),xnB(1:NUNK),epsjac)

where FCN_2 is the external function having one value and depending on NUNK variables
gnew is the gradient
xnB is the vector containing the variables at the current stage
epsjac is the precision

I did not get the same results as with the function CDGRD. I get a very big number for the first components and zero for the other gradient components, while the res is a very big negative number.

2) DJACOBI_SOLVE
I tried to compile the example shown at http://www.intel.com/software/products/mkl/docs/WebHelp/osr/osr_djacobi_...

Unfortunately I cannot find the mkl_opt_tr.f, so i removed the "include" line.
Then I get some error messages saying that it does not recognize the djacobi_init, djacobi_solve and so on. So i suppose i do not link correctly to the MKL libraries.

HELP AND SUGGESTIONS???
Thanks
C.

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

you wrote....

"Then I get some error messages saying that it does not recognize the djacobi_init, djacobi_solve and so on. So i suppose i do not link correctly to the MKL libraries."

Can you get me the log file of these messages?
What MKL version you are using?
Is this ia32 or Intel64 architecture?
--Gennagy

Hi,

(1) djacobi

your input data is wrong. djacobi requires external function defined as FCN(m, n, x, f). Following (sometimes bizzare) logic of IMSL lib you probably calling something like FCN (n, x,f). Fix the interface and you should be fine.

(2) linking

You just need (linker)

mkl_intel_c.lib mkl_core.lib mkl_solver.lib mkl_intel_thread.lib libiomp5md.lib

(for IA32 or x64 equivalent)

and

INCLUDE ''MKL_RCI.fi' statement.

If you still have problems I can come up later on with an example.

A.

EDIT: gnew must be defined as matrix, so call it with gnew(1, 1:nunk).

One more comment about this example:
The line 47 must be changed as
IF ( RCI_REQUEST == 1) THEN
-we will fix all these misprints ( including Artur mentioned about above ).
--GIF

Thank you all!
I succesfully used the djacobi function. There was an interface problem because i was not using double precision variables, and a problem related to the precision (i adopted a too low value). At the moment the ISML function and the MKL function give the same results.
However I get an unexpected warning:

OMP: Warning #18: Setting environment variable "__KMP_REGISTERED_LIB_5092" failed:
OMP: System error #203: The system could not find the environment option that was entered
OMP: Error #110: Clearing __KMP_REGISTERED_LIB env var failed.

It's very strange since i do not use OPENMP. Probably these are included in the MKL.
I've read that this problem could be solved by including the libguide40.lib or the newer version (I do not have). Unfortunately when i link to libguide40.lib the warning does not disappear.

I'm using a ia32 system, on windows, under visual studio. The MKL version is the 9.1.027.

Can someone tell me why this warning appears and how to solve it?

It's important noting that iput "mkl_s.lib libguide40.lib"in the "linkerinputadditional dependencies" row of the property page of my project.

If you don't intend to use the OpenMP support in MKL 9.1, you must link the serial library, not the standard threaded one. Much of the advice you have been getting applies only to recent MKL versions, which is understandable, as you didn't tell what you are doing until now.

Quoting - tim18
If you don't intend to use the OpenMP support in MKL 9.1, you must link the serial library, not the standard threaded one. Much of the advice you have been getting applies only to recent MKL versions, which is understandable, as you didn't tell what you are doing until now.

Thank you Tim18.
As you wrote i can choose to use or not the OpenMP support. As consequence i suppose the MKL functions i'm using can also operate without the OpenMP support.
My problem is due to the fact that i'm not fully understood which libraries have to be linked.
By reading the manual i've understand i have to link to mkc_c_dll.lib and libguide40.lib (since it's raccomended to link dynamically). But if i do so i get: "unresolved _DJACOBI symbol.... in module2"

So i tried to link the other libraries and i get no error message only if i link mkl_s.lib and libguide40.lib(no mkl_s_dll.lib)

When i usemkl_s.lib the djacobi function gives the same results as the IMSL function.
Note that I need to link to libguide40.lib because without this lib i get error messages due to unresolved OMP variables....

However if I use the MKL functions linking as above or if I return to the code using the IMSL routines but i leave the link to mkl_s.lib, some variables not related to the gradient vary, and in particular the index of an array goes out of range. Note that if I use the IMSL version without the link to mkl_s.lib all works fine.

I guess i'm not using the right linking mode.
Please can you tell me what's wrong?
Claudio

mkl_s_lib is meant to support CVF. If you link it, you will not be able to use mkl_c_lib, which is required by ifort and the C/C++ compilers.
It's true, you should be able to link in the OpenMP support and prevent threading at run time by setting an environment variable (MKL_SERIAL?) but I don't know that the environment variable has any effect on linking issues. I thought in one place you were saying you didn't want to link in OpenMP support. There is a serial version of MKL for that purpose. In 9.1, it was optional and installed in a separate folder.

Quoting - clodxpro

Thank you Tim18.
As you wrote i can choose to use or not the OpenMP support. As consequence i suppose the MKL functions i'm using can also operate without the OpenMP support.
My problem is due to the fact that i'm not fully understood which libraries have to be linked.
By reading the manual i've understand i have to link to mkc_c_dll.lib and libguide40.lib (since it's raccomended to link dynamically). But if i do so i get: "unresolved _DJACOBI symbol.... in module2"

did you use INCLUDE 'MKL_RCI.fi' in the other module?

A.

Quoting - ArturGuzik

did you use INCLUDE 'MKL_RCI.fi' in the other module?

A.

I've tried.
When I include the MKL_RCI.fi (while using mkl_c_dll.lib and libguide40.lib ) i get 31 error messages and 4 warnings like the following:

WARNING: warning #5117 : Bad # preprocessor line
ERROR: Error5 error #5082: Syntax error, found '**' when expecting one of: ( %% : . = =>D:ProgrammiIntel_NEWMKL9.1.027includeMKL_RCI.fi33

ERROR: Error6 error #5082: Syntax error, found '**' when expecting one of: ( %% : . = =>D:ProgrammiIntel_NEWMKL9.1.027includeMKL_RCI.fi41

and so on...
I think the errors are due to format issues. I guess it could be trivial errors, but i'm not experienced with format issues.
Do you have any suggestions?
Thank
C

Quoting - clodxpro

I've tried.
When I include the MKL_RCI.fi (while using mkl_c_dll.lib and libguide40.lib ) i get 31 error messages and 4 warnings like the following:

WARNING: warning #5117 : Bad # preprocessor line
ERROR: Error5 error #5082: Syntax error, found '**' when expecting one of: ( %% : . = =>D:ProgrammiIntel_NEWMKL9.1.027includeMKL_RCI.fi33

ERROR: Error6 error #5082: Syntax error, found '**' when expecting one of: ( %% : . = =>D:ProgrammiIntel_NEWMKL9.1.027includeMKL_RCI.fi41

and so on...
I think the errors are due to format issues. I guess it could be trivial errors, but i'm not experienced with format issues.
Do you have any suggestions?
Thank
C

I remember that (actually that was one of support issues I submitted at that time, I mean version 9). Well, two options:

(1) the easy thing would be just extract the interface of djacobi routine (and probably some of the parameters) to your own MODULE file, and then USE your_module_name instead of INCLUDE ..... one

(2) try to fix the format but as far as I can recall, compiler was not recognizing the mixture of "*.fi" and other files.

A.

Quoting - ArturGuzik

I remember that (actually that was one of support issues I submitted at that time, I mean version 9). Well, two options:

(1) the easy thing would be just extract the interface of djacobi routine (and probably some of the parameters) to your own MODULE file, and then USE your_module_name instead of INCLUDE ..... one

(2) try to fix the format but as far as I can recall, compiler was not recognizing the mixture of "*.fi" and other files.

A.

Thank you!
Please can you explain me widely the 1st point?
Thanks
C

Quoting - clodxpro

Thank you all!
I succesfully used the djacobi function. There was an interface problem because i was not using double precision variables, and a problem related to the precision (i adopted a too low value). At the moment the ISML function and the MKL function give the same results.
However I get an unexpected warning:

OMP: Warning #18: Setting environment variable "__KMP_REGISTERED_LIB_5092" failed:
OMP: System error #203: The system could not find the environment option that was entered
OMP: Error #110: Clearing __KMP_REGISTERED_LIB env var failed.

It's very strange since i do not use OPENMP. Probably these are included in the MKL.
I've read that this problem could be solved by including the libguide40.lib or the newer version (I do not have). Unfortunately when i link to libguide40.lib the warning does not disappear.

I'm using a ia32 system, on windows, under visual studio. The MKL version is the 9.1.027.

Can someone tell me why this warning appears and how to solve it?

It's important noting that iput "mkl_s.lib libguide40.lib"in the "linkerinputadditional dependencies" row of the property page of my project.

clodxpro,
some an additional comment: if you don't intend to use threading version of mkl, you can link the serial version of 9.1. the linking line will be something like for win32:
"icl test.c mkl_c.lib"
by another words your linkerinputadditional dependencies" will contains only mkl_c.lib
and therefore your "Additional Library Directories" will looks like 9.1lib_serialia32lib,
where as an examples = C:AppsIntelMKL
note: There are two options for downloading and installing Intel MKL 9.1 for Windows*:
A standard package containing the Intel MKL product: w_mkl_p_9.1.0xx.exe
An extended package containing the Intel MKL product plus ILP64 and serial versions of the library:
_mkl_enh_p_9.1.0xx.exe
So - you need to install w_mkl_enh_p_9.1.027.exe
You can get this version on intel registration center "htps://registrationcenter.intel.com"

Quoting - clodxpro

Thank you!
Please can you explain me widely the 1st point?
Thanks
C

OK. This is even simpler than I thought. If you open MKL_RCI.fi file you'll find the following (required) declarations. Just copy the statements below to your routine and remove INCLUDE command from your source.

    EXTERNAL DJACOBI
    INTEGER  DJACOBI
    INTEGER    TR_SUCCESS
    PARAMETER (TR_SUCCESS = 1501)
    INTEGER    TR_INVALID_OPTION
    PARAMETER (TR_INVALID_OPTION = 1502)
    INTEGER    TR_OUT_OF_MEMORY
    PARAMETER (TR_OUT_OF_MEMORY = 1503)

Then your code should compile and build. Later I will attach example code I have. Make sure that parameters values didn't change over the time (by checking with your version include file).

Please also pay attention to Tim's and Gennady's posts, as they have more insight into old version (you're using) memmory related issues.

A.

Login to leave a comment.