How Can I Use MKL in the Native Part of a Windows WPF Application

How Can I Use MKL in the Native Part of a Windows WPF Application

WPF (Windows Presentation Foundation) is a dot net managed code application and the primary api recommended by Microsoft for new desktop applications. To incorporate native code (c++) into a WPF application requires a dll. All the native code must exist in a dll, and the managed code part calls into the native code for its services. We require high performance, that can be provided by the Intel MKL and the native code environment for a WPF application.

There appears to be no support for including MKL in a native code dll. While I can build the application, I get a access violation at mkl_serv_allocate when attempting to create a descriptor for fft processing.

How can we Use the MKL in the native code part of a WPF application. Are there any patches to allow this to happen, or if it should be possible, is there an example application, or recommended set of link options to to make this work correctly.

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

Hello Sara,

Could you please provide more details?

What's your platform? How do you declare and call fft functions from managed code?

BTW: MKL provides a tool: /tools/builder to build a custom dll from static libraries.

You can also find link option if run MKL java examples. In such a case custom dll is built too.

Thanks,

-Vladimir

I have the same exact issue. Any resolution on this?

Hello, Sara,

Your information is too laconic to make a conclusion.

I have not found any problem to call DftiCreateDescriptor from managed C++.

Here is my test:

type test1.cpp

#using

using namespace System;

using namespace System::Runtime::InteropServices;

//#include

typedef void *DFTI_DESCRIPTOR_HANDLE;

[DllImport("mkl.dll")]

extern "C" int DftiCreateDescriptor( DFTI_DESCRIPTOR_HANDLE desc,

int precision, int domain, int dimention, int length);

int main() {

DFTI_DESCRIPTOR_HANDLE handle;

int size = 1 << 20;

int status = DftiCreateDescriptor( &handle,

35,//DFTI_SINGLE, /* DFTI_PRECISION */

33,//DFTI_REAL, /* DFTI_FORWARD_DOMAIN */

1, /* Dimension */

size /* Length */

);

Console::WriteLine(status);

//printf("status=%d, handle=0x%08xn",status,handle);

}

Let's see what I do on my win32 platform.

set MKLROOT=wrkmkl10.1

First of all I build custom dll library (see User Guide ch.5)

cd %MKLROOT%toolsbuilder

Here is the list of required functions:

echo DftiCreateDescriptor > dfti_list

nmake ia32 export=dfti_list name=mkl BUF_LIB=

...skipped...

Creating library mkl.lib and object mkl.exp

Let's go to the work directory

cd wrkcpp

Add paths to the custom dll and MKLDLLsto the 'path' env viriable:

set path=%MKLROOT%toolsbuilder;%MKLROOT%ia32bin;%path%

Compile:

cl /clr test1.cpp

Execute:

test1.exe

Results:

0

Or

status=0, handle=0x00944540

Could you please give me a test and steps to reproduce the failure?

Thanks,

Vladimir

Hello, Sara,
Now I see. You substitute the internal MKL function with yours one. Then you say:

Quoting - Jason Sara
I get a access violation at mkl_serv_allocate when attempting to create a descriptor for fft processing.

I am sure this is not MKL problem but this is a problem of your function.
I think this is wrong way to override undocumented functions.

Let's discuss your original problem. As I understand the problem is linking error. Do you use the MKL builder tool (User Guide ch.5) to build the dll? See also my example.

Thanks,

Vladimir

Leave a Comment

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