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

FFT - example code gives error on setup

Lars_J_
Beginner
936 Views

Hi all,

Our company is considering purchasing Intel MKL, and we have received a trail. I am however struggling to set up the descriptor for a 3d fft. When trying to commit the descriptor I get the following error: Intel MKL DFTI ERROR: Size of one of transform dimensions exceeds 2^32 (32 bits)

At first I thought that the way I set up the transform was wrong, but when I tried to run one of the examples I got the same error message. The example I tried to run is the one at the bottom of https://software.intel.com/en-us/node/522290. I am able to run a simple 1d fft based on an example I found on stackoverflow, so it seems that something strange happens when setting up the 3d fft. I'm on windows 10, and using Visual Studio 2015 with the newest version of Intel MKL.

Below is the code I'm trying to run, and I've also attached a visual studio solution that should reproduce the problem, Include directories and lib-paths must be set before it can be run. 

Any help is appreciated.

#include "stdafx.h"
#include <vector>
#include <complex>
#include "mkl_dfti.h"

std::vector<std::complex<double>> perform_1d_fft(std::vector<std::complex<double>> &in) {
	std::vector<std::complex<double>> out(in.size());
	DFTI_DESCRIPTOR_HANDLE descriptor;
	MKL_LONG status;

	status = DftiCreateDescriptor(&descriptor, DFTI_DOUBLE, DFTI_COMPLEX, 1, in.size());
	status = DftiSetValue(descriptor, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
	status = DftiCommitDescriptor(descriptor);
	status = DftiComputeForward(descriptor, in.data(), out.data());
	status = DftiFreeDescriptor(&descriptor);

	return out;
}


/* Example from https://software.intel.com/en-us/node/522290 */
void three_dimensional_real_fft() {
	float x[32][100][19];
	std::complex<float> y[32][100][10]; /* 10 = 19/2 + 1 */
	DFTI_DESCRIPTOR_HANDLE my_desc_handle;
	MKL_LONG status, l[3];
	MKL_LONG strides_out[4];

	//...put input data into x 0<=j<=31, 0<=k<=99, 0<=s<=18
	l[0] = 32; l[1] = 100; l[2] = 19;

	strides_out[0] = 0; strides_out[1] = 1000;
	strides_out[2] = 10; strides_out[3] = 1;

	status = DftiCreateDescriptor(&my_desc_handle, DFTI_SINGLE,
		DFTI_REAL, 3, l);

	auto a = DftiErrorMessage(status);
	status = DftiSetValue(my_desc_handle,
		DFTI_CONJUGATE_EVEN_STORAGE, DFTI_COMPLEX_COMPLEX);
	auto b = DftiErrorMessage(status);
	status = DftiSetValue(my_desc_handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
	auto c = DftiErrorMessage(status);
	status = DftiSetValue(my_desc_handle,
		DFTI_OUTPUT_STRIDES, strides_out);
	auto d = DftiErrorMessage(status);

	status = DftiCommitDescriptor(my_desc_handle);
	auto e = DftiErrorMessage(status);
	status = DftiComputeForward(my_desc_handle, x, y);
	auto f = DftiErrorMessage(status);
	status = DftiFreeDescriptor(&my_desc_handle);
	auto g = DftiErrorMessage(status);
}

int main()
{
	std::vector<std::complex<double>> values = {
		std::complex<double>(1.0, 2.0),
		std::complex<double>(3.0, 4.0),
		std::complex<double>(5.0, 6.0),
		std::complex<double>(7.0, 8.0),
	};

	auto result = perform_1d_fft(values);

	three_dimensional_real_fft();
	return 0;
}

 

0 Kudos
2 Replies
Zhen_Z_Intel
Employee
936 Views

Hi Lars,

I could not reproduce your problem. Please make sure you link with MKL library file correctly. Have you ever tried to compile with commend lines? Please try to compile with command lines in "Compiler 17.0 for Intel 64/IA32 VisualStudio 14.0" to check if this problem is caused by linkage problem.

For Intel Compiler
>icl IntelMKLApp.cpp -Qmkl

or for microsoft compiler
>cl IntelMKLApp.cpp -I"%MKLROOT%"\include mkl_intel_lp64.lib mkl_core.lib mkl_sequential.lib

0 Kudos
Lars_J_
Beginner
936 Views

Hi Fiona,

Thanks for your reply. It turned out that this happened because I was trying to link against too many .lib files. When I only had mkl_rt.lib as additional dependency in my visual studio project (Properties -> Linker -> Input), everything worked just fine.

0 Kudos
Reply