Hello,
I have a problem with the complex multiplication on large arrays. The following code leads to segmentation fault in vzMul:
const MKL_INT cLength = std::pow(2, 30) + 1; /* MKL_INT = int = int32 */ const size_t cLengthInBytes = cLength * sizeof(MKL_Complex16); const int cAlignment = 64; MKL_Complex16* pDataComplex1 = static_cast<MKL_Complex16*>(mkl_malloc(cLengthInBytes, cAlignment)); MKL_Complex16* pDataComplex2 = static_cast<MKL_Complex16*>(mkl_malloc(cLengthInBytes, cAlignment)); MKL_Complex16* pDataComplex3 = static_cast<MKL_Complex16*>(mkl_malloc(cLengthInBytes, cAlignment)); for (uint32_t i = 0; i < cLength; i++){ pDataComplex1.real = 1.0; pDataComplex1.imag = 0.0; pDataComplex2.real = 0.0; pDataComplex2.imag = 1.0; } vzMul(cLength, pDataComplex1, pDataComplex2, pDataComplex3); mkl_free(pDataComplex1); mkl_free(pDataComplex2); mkl_free(pDataComplex3);
According to the definition of MKL_INT as int32 it should be allowed to insert arrays of length int32Max = 2^31 - 1. There isn't any limitation mentioned in the documentation. The same issue seems to exist for vzAbs.
I use MKL Version 2019.0.1 Build 20180928
Link Copied
Mario, I don't see the problem on my side with on lin (RH 7) OS with the latest version 2019.5 on different types of CPU. Please show how did you build the case and what is your OS?
Thank you for your answer.
My environment:
The code (see attached file with minimal example) was compiled with:
icpc -c -g -std=c++11 -MMD -MP -MF "main.o.d" -o main.o main.cpp
icpc -o mulsegfault main.o -mkl=sequential
>> Checking the problem with the latest version of MKL ( 2019u5) on RH7
>> the code was slightly modified and attached to this thread.
>> building: icpc -g -std=c++11 -MMD -MP -mkl test_vzmul.cpp
>> here is the output:
]$ ./a.out
cLength == 1073741825
cLengthInBytes == 17179869200
... before vzMul ...
... after vzMul ...
... after mkl_free ...
Major version: 2019
Minor version: 0
Update version: 5
Product status: Product
Build: 20190808
Platform: Intel(R) 64 architecture
Processor optimization: Intel(R) Advanced Vector Extensions (Intel(R) AVX) enabled processors
================================================================
Compiling and running test_vzmul.cpp (attached by you) with
icpc -g -std=c++11 -MMD -MP -mkl test_vzmul.cpp
works perfectly without any error in my environment. It seems that the option "-mkl=sequential" leads to the segmentation fault. Compiling the same code with
icpc -g -std=c++11 -MMD -MP -mkl=sequential test_vzmul.cpp
leads to the following output:
]$ ./a.out
cLength == 1073741825
cLengthInBytes == 17179869200
... before vzMul ...
Segmentation fault (core dumped)
It is noticeable that the segmentation fault only occurs for arrays with length >= 2^30+1. Is it possible that the complex array is internally interpreted as real array of double length 2^31 + 2 (which overflows int32)?
yes, i see the segfault issue when linked against sequential version of MKL, otherwise, there is no problem when linked against threaded mode. We will check the cause of the problem.
Is there any news on the topic. Is a bugfix planned?
The problem was caused by 32-bit integer overflow and already fixed into internal branches of mkl.
and the fix is planning to be available into MKL 2020 u1 as MKL 2020 will be available very soon and the code freeze already happened. in the case if you need to try the eng. build - let me know.
Thank you for the update. Other arithmetic functions like vzAdd and zvDiv seem to have the same error. Were these also fixed in MKL 2020?
actually the fix will not be available in MKL 2020 ( the ERT ~ after 2 ww approximately ) . The fix of these problems is targeting to be available into MKL 2020 u1 only. We will keep you updated.
$ ./a.out
cLength == 1073741825
cLengthInBytes == 17179869200
Major version: 2020
Minor version: 0
Update version: 1
Product status: Product
Build: 20200208
Platform: Intel(R) 64 architecture
Processor optimization: Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors
================================================================
... before vzMul ...
... after vzMul ...
... after mkl_free ...
Mario,
the fix available in mkl 2020.1 which available for download. Please keep us informed of the results.
Gennady
For more complete information about compiler optimizations, see our Optimization Notice.