Community
cancel
Showing results for 
Search instead for 
Did you mean: 
K__Mario
Beginner
135 Views

Segmentation fault in vzMul on large arrays

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

0 Kudos
13 Replies
Gennady_F_Intel
Moderator
135 Views

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?

K__Mario
Beginner
135 Views

Thank you for your answer.

My environment:

  • Red Hat Enterprise Linux Client 7.6, 64-bit
  • 251,6GB RAM
  • Intel Xeon(R) CPU E5-2680v3@2.50GHz x 48

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

 

Gennady_F_Intel
Moderator
135 Views

>> 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
================================================================
 

 

K__Mario
Beginner
135 Views

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)

K__Mario
Beginner
135 Views

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)?

Gennady_F_Intel
Moderator
135 Views

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.

K__Mario
Beginner
135 Views

Is there any news on the topic. Is a bugfix planned?

Gennady_F_Intel
Moderator
135 Views

The problem was caused by 32-bit integer overflow and already fixed into internal branches of mkl.

Gennady_F_Intel
Moderator
135 Views

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.

K__Mario
Beginner
135 Views

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?

Gennady_F_Intel
Moderator
135 Views

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. 

Gennady_F_Intel
Moderator
135 Views

$ ./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 ...
 

Gennady_F_Intel
Moderator
135 Views

Mario,

the fix available in mkl 2020.1 which available for download. Please keep us informed of the results.

Gennady