- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Problem
Segmentation Fault in LAPACKE_sgees
Question
I should be giving enough buffer to LAPACKE_sgees (in Math Kernel Library) but when the following code run, a segmentation fault occurs in line 47. However, the comment in line 27 becomes active, this function succeeds and gives the correct result. This action is done in VC++ 2022.
And under the icx compiler, both of them failed.
How can I solve this problem and run this function safely?
Environment
- Windows 10 21H2
- Visual Studio 2022 Community
- Visual C++ 2022 or Intel C++ Compiler (2022.1.0.256)
- Intel libraries for oneAPI (2022.1.0.256)
Code
#include <cstdint>
#include <cstdio>
#include <mkl.h>
namespace imkl
{
constexpr int order = 3;
constexpr int size = order * order;
int ShapeArrayPrint(float* _A, int _side)
{
for (int i = 0; i < _side; i++)
{
for (int j = 0; j < _side; j++)
{
printf("%10lf ", _A[i * _side + j]);
}
printf("\n");
}
return 0;
}
}
int main()
{
//int _a = 0;
float* mat_a = new float[imkl::size]
{
1, 2, 0,
0, 3, 0,
2, -4, 2
};
int* tmp_sdim = new int[imkl::size] {0};
float* lpwr = new float[imkl::size] {0};
float* lpwi = new float [imkl::size] {0};
float* lpMat = new float[imkl::size] {0};
imkl::ShapeArrayPrint(mat_a, imkl::order);
printf("\n");
int ret = LAPACKE_sgees
(
LAPACK_ROW_MAJOR, 'N', 'N', nullptr,
imkl::order, mat_a, imkl::order, tmp_sdim,
lpwr, lpwi, lpMat, imkl::order
);
imkl::ShapeArrayPrint(mat_a, imkl::order);
printf("\n");
delete[] tmp_sdim;
delete[] lpwr;
delete[] lpwi;
delete[] lpMat;
delete[] mat_a;
return 0;
}
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thank you for trying.
The cause may be linking to "*ilp.lib" lib files.
I added all lib files of mkl to the option of "Additional Dependencies". The lib files seem to have two types of library "LP interfaces" and "ILP interfaces". The former uses 32bits to index the array and the latter uses 64bits. You must set some options when you compile using "ILP interfaces".
I solved this by removing "*ilp.lib" libs from the option.
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,
Thanks for reaching out to us.
Could you please attach your VS project file here so that we can try reproducing the issue?
I've tried running the provided code on my end in both VS2022 and Intel oneAPI command prompt with icx compiler (Intel C++ Compiler (2022.1.0.256)) but could not see the segementation fault error which you are mentioning and the output displayed is as shown below
1.000000 2.000000 0.000000
0.000000 3.000000 0.000000
2.000000 -4.000000 2.000000
2.000000 2.000000 -4.000000
0.000000 1.000000 2.000000
0.000000 0.000000 3.000000
Additionally, we suggest you try running the code from Intel oneAPI command prompt and see if the issue still persists.
Command:
> icx /Qmkl *.cpp
Regards,
Vidya.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thank you for trying.
The cause may be linking to "*ilp.lib" lib files.
I added all lib files of mkl to the option of "Additional Dependencies". The lib files seem to have two types of library "LP interfaces" and "ILP interfaces". The former uses 32bits to index the array and the latter uses 64bits. You must set some options when you compile using "ILP interfaces".
I solved this by removing "*ilp.lib" libs from the option.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,
>>The lib files seem to have two types of library "LP interfaces" and "ILP interfaces"
Yes, there are two types of interfaces LP64 and ILP64.
Here is the link with more details regarding the same.
>>I solved this by removing "*ilp.lib" libs from the option.
Glad to know that your issue is resolved.
Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.
Regards,
Vidya.
