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

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

Deleted_U_Intel
Employee
453 Views
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.
0 Kudos
4 Replies
Vladimir_Koldakov__I
New Contributor III
453 Views

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

0 Kudos
samkwitty
Beginner
453 Views
I have the same exact issue. Any resolution on this?
0 Kudos
Vladimir_Koldakov__I
New Contributor III
453 Views

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

0 Kudos
Vladimir_Koldakov__I
New Contributor III
453 Views

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

0 Kudos
Reply