Problem running C# examples

Problem running C# examples

I can't get the C#examples from http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/ to run.

Everything compiles fine, but I get the following exception at run-time:

Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'cblas_dgemm' in DLL 'mkl.dll'.

To build the examples, I ran the following command:

nmake ia32 MKLROOT="C:Program FilesIntelMKL10.2.3.029"

I'm running on Intel Core i7-920 with 64-bit Windows Vista OS.

Thanks for any advice.

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

It makes no sense that I get that error because when I run the following from the command line:

dumpbin /exports mkl.dll

I get:

Section contains the following exports for mkl.dll

00000000 characteristics

4B58DFF0 time date stamp Thu Jan 21 17:14:56 2010

0.00 version

1 ordinal base

13 number of functions

13 number of names

ordinal hint RVA name

1 0 000075D0 DftiCommitDescriptor

2 1 00007630 DftiComputeBackward

3 2 000076B0 DftiComputeForward

4 3 00007730 DftiCreateDescriptor

5 4 00007840 DftiFreeDescriptor

6 5 00007850 DftiGetValue

7 6 00007AF0 DftiSetValue

8 7 00007C40 cblas_dgemm

9 8 00007E70 dgeev

10 9 00007ED0 pardiso

11 A 00007F30 vdDiv

12 B 00008238 vmlClearErrorCallBack

13 C 00008210 vmlSetErrorCallBack

Did you use the link advisor on the forum header page to help you make a selection of mkl dll .lib ?

For example, you might have mixed 32- and 64-bit compilation and libraries, or 64-bit "ilp64" integers and 32-bit "lp64" integers if in 64-bit mode, or followed advice relevant to a much older MKL version.

Hi,

Have yourun on 64-bit OS 64-bit target?

nmakeem64t MKLROOT=...

Thanks,

Vladimir

I used the link a the top of the forumpage.

If I run the command:

nmake ia64 MKLROOT="C:\Program Files\Intel\MKL\10.2.3.029"

I get the following error:

_fseeki64.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'IA64'

Are there not any prebuilt Windows DLL's (32-bit and 64-bit) that can be downloaded? I'm already familiar with the interop mechanisms of the .NET framework, so it's a little frustrating that I can't get this to work. I'm currently usinggeneric, non-optimized versions of LAPACK and BLAS in my .NET application and I'm just curious about performance benefits of MKL, which I understand are considerable.

Is it possible that I don't have 64-bit C++ compiler installed on my system?

Typing just "cl" I get:

Microsoft 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86

Shouldn't I still be able to create a 32-bit version like I do with my non-optimized LAPACK and BLAS?

If you want to use the 32-bit CL, that is in conflict with your nmake ia64, which says to build using Itanium compatible libraries. You would set ia32 rather than ia64 for the 32-bit case.

If you want to use the intel64 libraries, you must install the x64 selection under the C++ category in your Visual Studio setup (not available in VS Express). Then you would have options in the Start menu to open either 32-bit or x64 cmd window, and in VS GUI to set X64 mode.

I'm still not sure why I can compile the 32-bit version, but get this exception at run-time:

System.EntryPointNotFoundException: Unable to find an entry point named 'cblas_dgemm' in DLL 'mkl.dll'.

I'm using the evaluation version. Is it possibly a licence file issue?

I'm grasping at straws at this point.

Not a license issue. You must take care that the PATH which is active includes the 32-bit dll you require, if it is a 32-bit build. A same named entry point in the em64t (X64) dll will be ignored in this case.

I appreciate all the responses so far.

I still never got the example from the top of the forum page to work.

So, I decided to use the MKL Custom DLL builder that is in:

C:\Program Files\Intel\MKL\10.2.3.029\tools\builder

I was able to build a DLL with the desired BLAS and LAPACK functions I am interested in using.

Now, I'm wrote a simple app to test DGEMM (not the CBLAS version, the BLAS version). However, I'm getting the following error:

MKL ERROR : Parameter 8 was incorrect on entry to DGEMM

I'm just using a very simple example, e.g.

A =[1 2 3; 4 5 6]

B= [0 1 0 1; 1 0 0 1; 1 0 1 0]

C = [5 1 3 3; 11 4 6 9]

Here's my code:

.....

namespace TestIntelMathKernelLibrary
{
    class MKL_Class
    {
        [DllImport("mkl", EntryPoint = "DGEMM"), SuppressUnmanagedCodeSecurity]
	public static extern void dgemm(ref char TransA, ref char TransB, ref int M, ref int N, ref int K, ref double alpha, IntPtr A, ref int lda, IntPtr B, ref int ldb, ref double beta, double[] C, ref int ldc);
    }


    class Program
    {
        static void Main(string[] args)
        {
            char TransA = 'N';
            char TransB = 'N';
            int M = 2;
            int N = 4;
            int K = 3;
            double alpha = 1.0;
            double beta = 0.0;
            int lda = M;
            int ldb = K;
            int ldc = M;

            // Column major order matrix data
            double[] A = new double[] { 1, 4, 2, 5, 3, 6 }; // M x K
            double[] B = new double[] { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0 }; // K x N
            double[] C = { 5, 11, 1, 4, 3, 6, 3, 9 }; // M x N
            
            /* Computation */
            unsafe
            {
                fixed (double* ptrA = A)
                fixed (double* ptrB = B)
                {
                    MKL_Class.dgemm(ref TransA, ref TransB, ref M, ref N, ref K, ref alpha, (IntPtr)ptrA, ref lda, (IntPtr)ptrB, ref ldb, ref beta, C, ref ldc);
                }
            }


        }

Hi,
I used the provided code example, it works.
I used Visual Studio 2008 Command Prompt (32 bit!) on the Intel64 architecture.
Here is protocol:

set lib=%MKLROOT%\ia32\lib;%lib%

echo EXPORTS > user.def
echo DGEMM >> user.def

link /DLL /MACHINE:IX86 /def:user.def mkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib user32.lib /out:mkl.dll

set path=.;%MKLROOT%\ia32\bin;%path%

csc /platform:x86 /unsafe .\dgemm.cs

dgemm.exe

BTW. Its need not to use unsafe code. You may pass A and B in the same way as C.

Thanks,
Vladimir

Quoting Vladimir Koldakov (Intel)

Hi,
I used the provided code example, it works.
I used Visual Studio 2008 Command Prompt (32 bit!) on the Intel64 architecture.
Here is protocol:

set lib=%MKLROOT%\ia32\lib;%lib%

echo EXPORTS > user.def
echo DGEMM >> user.def

link /DLL /MACHINE:IX86 /def:user.def mkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib user32.lib /out:mkl.dll

set path=.;%MKLROOT%\ia32\bin;%path%

csc /platform:x86 /unsafe .\dgemm.cs

dgemm.exe

BTW. Its need not to use unsafe code. You may pass A and B in the same way as C.

Thanks,
Vladimir

Thank you very much Vladimir! It worked. I also took your advice and removed the /unsafe option (I just had to slightly modify the DllImport signature.)

Since I don't do much development using command line tools, I was trying to create my custom DLL in the VS2008 IDE, but I couldn't figure out all of the compiler settings such thatwould remove allname decoration/mangling. Is there any documentation on how to do this?

To date, I have only developed 32-bit applications. Would I see a significant performance boost by going to 64-bit?

Thanks again,

Darrin

Oops.I only thought it worked. I wasn't paying attention to my linker error:

LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12

But, I couldn't understand why my test app was working. Turns out, I have Matlab installed, and wouldn't you know it, Matlab has a DLL in my PATH that is called mkl.dll -- I presume created with Intel MKL? So, my test app was using Matlab's version of mkl.dll.

I resolved the linker error by including library "libcmt.lib".

Also, to make sure it wasn't going to use Matlab's version, I changed the output to mkl_custom.dll.

Slowly, but surely, I'll get the hang of this. When I figure out how to do all this DLL building in the IDE, I'll really get productive.

Thanks again for the advice,

-Darrin

Hi Darrin

you wrote:

To date, I have only developed 32-bit applications. Would I see a significant performance boost by going to 64-bit?

CurrentlyMKL BLAS32bit code is asfast as 64bit one.Iguess you would see several percents of a performance boost

Regards,

Sergey

Quoting Sergey Kazakov (Intel)

Hi Darrin

you wrote:

To date, I have only developed 32-bit applications. Would I see a significant performance boost by going to 64-bit?

CurrentlyMKL BLAS32bit code is asfast as 64bit one.Iguess you would see several percents of a performance boost

Regards,

Sergey

Thanks Sergey. Good to know.

Regards,

Darrin

Leave a Comment

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