using MKL_INT with fftw3

using MKL_INT with fftw3

Hi , I'm using MKL with fftw3 to calculate the price of an option. I've converted code from Matlab to C++. The code used to work in VS2008 but I had to upgrade my environment and now I use VS2010 with a new compiler and it no longer works. Environment information is

System Type x64-based PC

Processor Intel Core2 Duo CPU P8600 @ 2.40GHz, 2401 Mhz, 2 Core(s), 2 Logical Processor(s)

Intel Parallel Studio XE for Windows* (all tools)

Version 2011 (SP1 Update 2 VS)

Intel Math Kernel Library for Windows*

Version 10.3 (9)

Microsoft Visual Studio 2010

Version 10.0.30319.1 RTMRel

Microsoft .NET Framework

Version 4.0.30319 RTMRel

Intel C++ Composer XE 2011 Update 9 Package ID: w_ccompxe_2011.9.300

Intel C++ Composer XE 2011 Update 9 Integration for Microsoft Visual Studio* 2010, Version 12.1.1109.2010, Copyright 2002-2012 Intel Corporation

Intel Inspector XE 2011 Update 9

Intel Inspector XE 2011 Update 9, (build 218166), Copyright 2009-2012 Intel Corporation. All rights reserved.

Intel VTune Amplifier XE 2011 Update 8

Intel VTune Amplifier XE 2011 Update 8, (build 221625), Copyright 2009-2012 Intel Corporation. All rights reserved.

NB. when I look at VS2010 "about" information it does not show the MKL installed. Should it?

The errors coming out from the compilation are all for the use of the MKL_INT declaration of the k variable in the for loop. Example, error is

1>AOptionPricer.cpp(310): warning C4244: 'argument' : conversion from '__int64' to 'const int', possible loss of data

and the related code for this error is

for ( MKL_INT k=0 ; k

complex gxc = i*u[0]*y[k] ;

cA[k].real = gxc.real() ;

cA[k].imag = gxc.imag() ;

}

where the line highlighted for this error in VS2010 is

complex gxc = i*u[0]*y[k] ;

I am doing complex number arithmetic so need y[k] to be a vector calculation, hence the use of MKL_INT. This used to work, but now still compiles but crashes when run. I had this problem some time ago in vs20008, but corrected it with an updated compiler and I think some compiler options. Now I've updated the compiler and environment again and it does not work any more.

my includes are

#include "stdafx.h"

#include "nr3.h"

//#include

#include

#include

#include

#include

#include

#include "interp_1d.h"

#include "interp_linear.h"

#include

#include "fftw3.h"

#include "fftw3_mkl.h"

#include "windows.h"

#include "mkl_service.h"

#include "mkl.h"

#include "mkl_vml.h"

and all are shown as found in vs2010 and as i said i have no link errors, only this conversion error.

I had fixed some of the conversion errors using a static_cast for my call to pow below

for (MKL_INT k=0 ; k

v=pow(static_cast(k),static_cast(2.0f)) ;

complex yyc = -pi*i*a*v ;

cA[k].real = yyc.real() ;

cA[k].imag = yyc.imag() ;

}

but am stuck for a fix for the aforementioned for loop.

Can you please help?

Thanks

Ian

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

A warning is not an error. Try running the code to see if it produces correct results regardless of the warning.

It is unlikely that one can help when you show only snippets of code. In particular, you did not display the declarations of of pi, a, v and i.

Best Reply

Hi,

Please also check consistency of compilation flags and linking line with MKL.
It looks like you compiled with ILP64.

Thanks,
-- Victor

Hi , it compiles ok, but when the code runs the program crashes. If I use standard C++ int instead of MKL_INT it compiles and runs and produces rubbish. Declarations;

VecDoub y ;

VecDoub u;

complex i (0,1) ;

it needs an array for the int for the vector calculations. MKL_INT worked before , but I'm missing something.

Hi Victor, how would I check this compile option ? Below is my linker command line

/OUT:"C:\Users\ianbe\Documents\Visual Studio 2010\Projects\AOptionPricer\x64\Release\AOptionPricer.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl\lib" /LIBPATH:"C:\FFTProj\fftw-3.3.1-dll64" "C:\FFTProj\fftw-3.3.1.pl1-dll32\libfftw3-3.lib" "C:\FFTProj\fftw-3.3.1.pl1-dll32\libfftw3f-3.lib" "C:\FFTProj\fftw-3.3.1.pl1-dll32\libfftw3l-3.lib" "C:\FFTProj\fftw-3.3.1-dll64\libfftw3-3.lib" "C:\FFTProj\fftw-3.3.1-dll64\libfftw3f-3.lib" "C:\FFTProj\fftw-3.3.1-dll64\libfftw3l-3.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" /MANIFEST /ManifestFile:"x64\Release\AOptionPricer.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\ianbe\Documents\Visual Studio 2010\Projects\AOptionPricer\x64\Release\AOptionPricer.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /PGD:"C:\Users\ianbe\Documents\Visual Studio 2010\Projects\AOptionPricer\x64\Release\AOptionPricer.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE

If the error is truly as described, the following may be worth trying:

Replace

v=pow(static_cast(k),static_cast(2.0f)) ;

by

v = k*k;

Hi mecej4,

thanks for your help, but the code snippet with a present error is

for ( MKL_INT k=0 ; k

complex gxc = i*u[0]*y[k] ;

cA[k].real = gxc.real() ;

cA[k].imag = gxc.imag() ;

}

what I said earlier is that I had the same error for the code snippet with pow, but had corrected it with the cast, and showed this as working code. The above code with the complex number is an example of a line that does not work as expected.

Hi Victor,

here's my C++ command line

/I"C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl\include" /I"C:\FFTProj\fftw-3.3.1-dll64" /Zi /nologo /W3 /WX- /O2 /Oi /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"x64\Release\AOptionPricer.pch" /Fa"x64\Release" /Fo"x64\Release" /Fd"x64\Release\vc100.pdb" /Gd /errorReport:queue

MKL_INTis 32-bit intbecause there is no -DMKL_ILP64 in compilation if header is used.
Note, fftw interface uses just simple int, not MKL_INT.
What MKL libraries are used for linkage? I can see just fftw-3.3.1-dll64
So, could you please prepare isolated testcase to reproduce your problem on our side, including compilation and full link line

Thanks,
-- Victor

Ok Victor,

shouldI do this as a win32 or CLR console application?
i remember when in vs2008, there was a problem making vs2008 64bit aware with the .Net framework installed. i think it all broke when this was upgraded on my laptop. So, does using the system namespace make a difference when compiling with MKL?

I'm using

Intel Math Kernel Library

Intel MKL on IA-32

Intel MKL on Intel 64

Intel Math Kernel Library for Windows* Version 10.3 (9)

Hi Victor, you're right.

I recreated the project from new in VS2010 and used a CLR console, but I dont think that matters.

I found I am using the IPL64 option

Configuration Properties ->
Intel Performance Libraries ->

Then for

Use ILP64 Interfaces

I selected NO.

This clears down the conversion warnings , thanks.

I'm now left with an fftw error which I remember was solved by an include of the fftw libraries somewhere, just working out where. i.e. the size_t warnings are all for allocating memory to the fft plan.

1> AOptionPricer_testcase.cpp

1>AOptionPricer_testcase.cpp(467): warning C4244: 'argument' : conversion from 'double' to 'size_t', possible loss of data

1>AOptionPricer_testcase.cpp(468): warning C4244: 'argument' : conversion from 'double' to 'size_t', possible loss of data

1>AOptionPricer_testcase.cpp(469): warning C4244: 'argument' : conversion from 'double' to 'size_t', possible loss of data

1>AOptionPricer_testcase.cpp(470): warning C4244: 'argument' : conversion from 'double' to 'size_t', possible loss of data

1>AOptionPricer_testcase.cpp(471): warning C4244: 'argument' : conversion from 'double' to 'size_t', possible loss of data

1>AOptionPricer_testcase.cpp(472): warning C4244: 'argument' : conversion from 'double' to 'size_t', possible loss of data

1>AOptionPricer_testcase.cpp(473): warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data

1>AOptionPricer_testcase.cpp(474): warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data

1>AOptionPricer_testcase.cpp(475): warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data

1> AssemblyInfo.cpp

1> Generating Code...

1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp

1>AOptionPricer_testcase.obj : warning LNK4248: unresolved typeref token (0100001B) for 'fftw_plan_s'; image may not run

1> AOptionPricer_testcase.vcxproj -> c:\users\ianbe\documents\visual studio 2010\Projects\AOptionPricer_testcase\x64\Debug\AOptionPricer_testcase.exe

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

yes, this last problem is fixed with including the fftw dll in the link, like I asked the same question 3 years ago :-)

http://www.dsprelated.com/showmessage/118138/1.php

but I cant see how to do that in vs2010. i keep getting

1>c:\Users\ianbe\documents\visual studio 2010\Projects\AOptionPricer_testcase\AOptionPricer_testcase\libfftw3l-3.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x480

========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

so back to microsoft for some help.

Anyway, for this thread Victor you gave the correct answer,

Thanks

Ian

The MS linker does not directly read and link to a DLL. You need to have the corresponding import library. When you compile and build a DLL from source code, the import library is created along with the DLL. If you obtained the DLL from a different source, they should provide you with the import library, too.

Thanks, I figured that out, but still stuck with vs2010, as I'm including the fftw3 libs everywhere I can think of, e.g. for c++ , linker and when compiling to list includes I do not see the fftw3 libs at all. So still failing on the fftw error at the moment.

Ian

1>AOptionPricer_testcase.obj : warning LNK4248: unresolved typeref token (0100001B) for 'fftw_plan_s'; image may not run

1> AOptionPricer_testcase.vcxproj -> c:\users\ianbe\documents\visual studio 2010\Projects\AOptionPricer_testcase\x64\Debug\AOptionPricer_testcase.exe

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

the image error is coming from the CLR defined project I created. I switched back to my original win32 console and then no more of these errors.

Leave a Comment

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