Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

sgetrf corrupts the stack?

sugarpie
Beginner
901 Views
I'm having some issues with sgetrf , when invoked Foo (see code below) I get an exception upon completing the method call to Foo:

Run-Time Check Failure #2 - Stack around the variable 'ipiv' was corrupted.

The exception is thrown when the method returns, that is after the delete [] wpi call. If the call to sgetrf is removed the method executes and returns without corrupting the stack.

I'm using MKL 10.1.0.018 and Visual Studio 2008.

int _tmain(int argc, char *argv[])
{

const int M = 5;
const int K = 4;
const int N = 3;

float* p = new float[K*N];
float* w = new float[K*N];
float* wp = new float[K*N];

memset((void*)wp,0,(size_t)K*N*sizeof(float));
// ...
Foo(p,w,wp,N,N,K);
// ...
}

void Foo(const float* p,float* w,float* wp,int M,int N,int K){
int ipiv = 0;
int info = 0;
float work = 0;
int lwork = 0;
float* wpi = new float[N*N];

memset((void*)wpi,0,(size_t)N*N*sizeof(float));

cblas_sgemm(CblasRowMajor,CblasTrans,CblasNoTrans,N,N,K,1.0f,p,M,w,N,1.0f,wpi,N);
// if this called is removed, the stack does not become corrupt
sgetrf(&N,&N,wpi,&N,&ipiv,&info);
// ...
delete [] wpi;
}

Thanks in advance!
// olof
0 Kudos
1 Solution
Gennady_F_Intel
Moderator
901 Views

Olof,
At the first glance, the cause of the problem dealt with ipiv:
please look at description of sgetrf: Ipiv == array, dimensional at least max(1,min(m.n)) and etc.
Therefore, replace int ipiv by int ipiv and try again.
Please let us know if any further problems.
--Gennady

View solution in original post

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
902 Views

Olof,
At the first glance, the cause of the problem dealt with ipiv:
please look at description of sgetrf: Ipiv == array, dimensional at least max(1,min(m.n)) and etc.
Therefore, replace int ipiv by int ipiv and try again.
Please let us know if any further problems.
--Gennady

0 Kudos
sugarpie
Beginner
901 Views

Olof,
At the first glance, the cause of the problem dealt with ipiv:
please look at description of sgetrf: Ipiv == array, dimensional at least max(1,min(m.n)) and etc.
Therefore, replace int ipiv by int ipiv and try again.
Please let us know if any further problems.
--Gennady


Thank you! The stack is now safe and sound=)
0 Kudos
Reply