Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
18 Views

New with the tool - I'm having some issues, with DftiCreateDescriptor. Help really appreciated

Hi all,

I'm coding an application using C# with Visual Studio 2008. I've been reading the documentation that came with the Intel Math Library...and some forums...but couldn't get an answer.

Scenario:

Attempting to statically-link MKL v9.x into a managed C++ DLL to calculate FFT, using Visual Studio 2008.

Linker command:

/OUT:"C:\\Projects\\Acquisition Toolkit\\Mainline\\\\Builds\\Debug\\AcquisitionToolkit.FFT.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\\Projects\\Acquisition Toolkit\\Mainline\\\\Lib\\Win32" /DLL /MANIFEST /MANIFESTFILE:"Debug\\Win32\\AcquisitionToolkit.FFT.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /ASSEMBLYDEBUG /PDB:"c:\\Projects\\Acquisition Toolkit\\Mainline\\Builds\\Debug\\AcquisitionToolkit.FFT.pdb" /DYNAMICBASE /FIXED:No /NXCOMPAT /MACHINE:X86 /KEYFILE:"AcquisitionToolkit.snk" /ERRORREPORT:PROMPT mkl_c.lib mkl_ia32.lib libguide40.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib



Getting an unresolved external when linking:


1>FFT.obj : warning LNK4248: unresolved typeref token (0100000E) for 'DFTI_DFT_Desc_struct'; image may not run



At run-time, it crashes on the call to DftiCreateDescriptor, presumably because it didn't know the format of the descriptor struct:


// create the FFT descriptor

DFTI_DESCRIPTOR_HANDLE desc;

long val = DftiCreateDescriptor(&desc, DFTI_DOUBLE, DFTI_REAL, 1, length);

// commit the FFT descriptor

DftiCommitDescriptor(desc);

We are including the mkl_dfti.h header file. Are there additional header files we need or additional libraries we need to link with? Where is that descriptor struct actually defined?


I attempted to dynamically link using the mkl_c_dll.lib, but get the same unresolved external linker warning. Is there some other linker option I need?


Please if someone could give me some kind of guidance/help. I'd REALLY appreciate it.

Thanks!!

0 Kudos
5 Replies
Highlighted
New Contributor III
18 Views

Hi,

Please see examples of using MKL in C# code. The article contains a small suite including DFTI example. The first package Intel_MKL_C#_Examples.zip demonstrates how to build custom dll for calling MKL functionsfrom C#. Since MKL 10.3 its not required to build a custom DLL. The second package demonstrates using MKL 10.3.

Thanks,
Vladimir

0 Kudos
Highlighted
Beginner
18 Views

Hi Vladimir,

Thanks for your answer. I've tried using those examples, but seems that they're not working for version 9.1. As I am not able to have the newer version...I need to make it work with this one.

I've tried doing

nmake ia32 MKLREDIST="C:\Documents and settings\myUser\desktop\Intel_MKL_C#_Examples"

nmake ia32 MKLROOT="C:\Documents and settings\myUser\desktop\Intel_MKL_C#_Examples"

nmake ia32 MKLROOT="C:\program files\intel\ml\9.1"

nmake ia32 MKLREDIST="C:\program files\intel\ml\9.1"

And I'm getting the same error message. Seems that for this version (9.1) there's no "mkl_intel_c_dll.lib" file. I've found that there's one called "mkl_c.lib". I was thinking that maybe that file is the same (but it's the 9.1 version), so I renamed it to "mkl_intel.....", and got another error. This time it's asking for another file "mkl_intel_thread_dll.lib", and I haven't found any "similar" file name for it.

I know that doing this is not going to fix the situation...but I've nochoice but to try it...is there anything else that I could do with it?

Thanks!!

0 Kudos
Highlighted
New Contributor III
18 Views

Hi Diego,

Please replace the makefile with the attached one. It works for ia32 target both on 32- and 64-bit OS for MKL 9.1. makefile

I believe the correct command line in your case should be:

nmake ia32 MKLROOT="C:\program files\intel\ml\9.1"

Thanks,
Vladimir

0 Kudos
Highlighted
Beginner
18 Views

Hi,

After compiling with the makefile that you provided me, I attempted to use the DLL in my project. I'm still getting this warning which is :

Warning 1 warning LNK4248: unresolved typeref token (0100000E) for 'DFTI_DFT_Desc_struct'; image may not run

And the code stops working in the line marked with '-------->'

/*****************************************************************************

* FFT.cpp

*/

#include

#include "FFT.h"

START_NAMESPACE

/**

Compute the FFT

*/

void

FFT::Compute(array^ x, array^ y)

{

int length = x->Length;

if (y->Length != x->Length)

throw gcnew System::ArgumentException("FFT: arrays must be same length");

double* xx = new double[length];

for (int i = 0; i < length; i++)

xx = x;

double* yy = new double[length];

for (int i = 0; i < length; i++)

yy = y;

// create the FFT descriptor

DFTI_DESCRIPTOR_HANDLE desc;

--------> long val = DftiCreateDescriptor(&desc, DFTI_DOUBLE, DFTI_REAL, 1, length);

So would you please provide me the size of the data that the DFTI_DFT_Desc_struct is handling?

Do we need any additional header or lib file with the definition of the struct (DFTI_DFT_Desc_struct)?

0 Kudos
Highlighted
Employee
18 Views

Hi Diego,

The issue is related to /clr (managed C++) and is explained in various places on Internet, for example here: http://www.dotnet247.com/247reference/msgs/1/7811.aspx. Rewording the reply of Anson Tsao from MS for our context:

The problem is because struct DFTI_DFT_Desc_struct{} is not defined in the header files. To fix the problem define it your sources (e.g. stdafx.h):

struct DFTI_DFT_Desc_struct {};

More info: DFTI_DESCRIPTOR_HANDLE is defined as typedef struct DFTI_DFT_Desc_struct *DFTI_DESCRIPTOR_HANDLE; for typesafety. In native C++, not having struct DFTI_DFT_Desc_struct defined is not a problem, but in managed C++ functions it will throw TypeLoadException when the CLR is trying to resolve struct DFTI_DFT_Desc_struct *.

I hope this will helpyou. In particular, for a quick workaround you should add the definition somewhere inthe clr-compiled code, as follows:

Option 1.Add the following definition in the global namespace (e.g. just after#include "mkl_dfti.h"):

[cpp]struct DFTI_DFT_Desc_struct {};[/cpp]

Option 2. Modify mkl_dfti.h for clr-compilation by adding the following three lines just before the first line mentioning DFTI_DFT_Desc_struct:

[cpp]#if defined(__cplusplus_cli)
struct DFTI_DFT_Desc_struct {};
#endif[/cpp]

Thanks
Dima

0 Kudos