Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
6435 Discussions

Crash for a simple 2D MKL FFT example when matrix size is not too larger

strngtn
Beginner
289 Views

Environment:  MKL Version: 2020.2.254

Toolchain: Visual Studio Community 16.7.6,  Host x64,  Target x64

CMakeLists.txt:
add_executable(mkl_test_s main.cpp)
target_link_libraries(mkl_test_s mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib)

 

#include <chrono>
#include <iostream>
#include <random>

#include "mkl.h"
#include "mkl_dfti.h"

void init_array_random(int size, double *a) {
std::uniform_real_distribution<double> unif(0, 1);
std::random_device rd;
std::default_random_engine re(rd());
for (int i = 0; i < size; ++i) a[i] = unif(re);
}

void fft(double *datain, double *dataout, int sz) {
DFTI_DESCRIPTOR_HANDLE handle;
MKL_LONG status;
MKL_LONG sizes[2] = {sz, sz};
status = DftiCreateDescriptor(&handle, DFTI_DOUBLE, DFTI_REAL, 2, sizes);
status = DftiSetValue(handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
status = DftiCommitDescriptor(handle);
auto start = std::chrono::high_resolution_clock::now();
status = DftiComputeForward(handle, datain, dataout);
auto dur = std::chrono::high_resolution_clock::now() - start;
std::cout
<< "FFT Done. Elapse time = "
<< std::chrono::duration_cast<std::chrono::microseconds>(dur).count()
<< "us" << std::endl;
status = DftiFreeDescriptor(&handle);
}

int main(int argc, char *argv[]) {
int size = 299; // Crash when size >= 300
double *in = (double *)mkl_calloc(size * size, sizeof(double), 64);
double *out = (double *)mkl_calloc(size * size, sizeof(double), 64);
init_array_random(size * size, in);
fft(in, out, size);
mkl_free(in);
mkl_free(out);
return 0;
}

 

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
271 Views

building this example as is by the trivial way: icl /Qmkl test.cpp and enabling the verbose mode, I see no problems with my run:


>set MKL_VERBOSE=1


>test_2dfft.exe

MKL_VERBOSE Intel(R) MKL 2020.0 Update 2 Product build 20200624 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Win 2.60GHz intel_thread

MKL_VERBOSE FFT(drfo299:299:299x299:1:1,pack:ccs,tLim:2,desc:0000020CD5E3C700) 1.53ms CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:2

FFT Done. Elapse time = 111128us


> building like icl /Qmkl=seqential ( exactly like you did) run well also with the outputs:

test_2dfft.exe

MKL_VERBOSE Intel(R) MKL 2020.0 Update 2 Product build 20200624 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Win 2.60GHz sequential

MKL_VERBOSE FFT(drfo299:299:299x299:1:1,pack:ccs,tLim:1,desc:0000022C2470BAC0) 1.73ms CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:1

FFT Done. Elapse time = 110499us




Gennady_F_Intel
Moderator
240 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only. 



Reply