Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Changing a program from IMSL to MKL

samzmse
Beginner
363 Views

I am trying to change a finite element code that currently uses IMSL routines (specifically LFTQS and LFSQS) to the corresponding MKL routines (PBTRF and PBTRS).

The code will run fine for a few timesteps, but eventually, the outputs become unstable and the code stops running. Everything works fine when I run it with the IMSL library.

Everything I have read on the MKL vs IMSL threads state that the MKL has higher performance. Is there a reason they are less stable? Are there any steps I can try to get the code to run stably with the MKL routines?

0 Kudos
7 Replies
Gennady_F_Intel
Moderator
363 Views
I don't think so. It seems to me like "user error". This is an unknown problem for current version of MKL. Can you give us the example which we can check and investigate?
an also -
MKL Version you are using.
Linking line, CPU type ...
--Gennady
0 Kudos
mecej4
Honored Contributor III
363 Views
The IMSL routines and the MKL routines have slightly different calling sequences. Before we start making judgements about stability, we should stop the calculations after one call to the factorizer/solver combination, print the results, and compare. If the results from MKL and IMSL do not agree to within a modest multiple of machine epsilon, that needs to be fixed first.

In a time-dependent calculation, an error in one step is fed into the next and can, therefore, grow. Such growth can be caused by instability, but it can also be caused by errors in forming the banded matrix or mistakes in the calling sequence.
0 Kudos
samzmse
Beginner
363 Views
Thank you for all of your helpful feedback.

In regards to the first question, I am using an Intel 32 bit CPU, MKL version 10.2 update 3, and the linking line is "mkl_solver_sequential.lib mkl_intel_c.lib mkl_sequential.lib mkl_core.lib"

I will start by comparing the differences between the IMSL and MKL after the first time step.
0 Kudos
samzmse
Beginner
363 Views
Again- Thank you for the useful feedback. If I make the first time step very small, the results from the MKL and IMSL after the first call are the same. If the time step is slightly larger, then there are large differences. If I limit the code to only allow the largest time step to be small, it runs fine in either case.
0 Kudos
Gennady_F_Intel
Moderator
363 Views
What does time step stands for? Do you mean that is the size of task you are are solving?

0 Kudos
mecej4
Honored Contributor III
363 Views
If the time step is slightly larger, then there are large differences -- that's not as it should be. If possible, make up a test case with coarse spatial discretization (to make the matrix size small) and a reasonably large time step, print out the banded matrix, post the matrix here and check the solution by hand (or using a tool such as Matlab).

In addition, it would be beneficial to compare the change in the dependent variable. In other words, instead of starting with the initial condition u_0 at t = 0, and solving for u_1 at t = dt, and comparing u_1,IMSL and u_1,MKL, solve for du = u_1 - u_0 and compare du_IMSL with du_MKL. That way, you will not mask out large relative errors by adding the vector d_u with small magnitudes to the vector u_0 with large magnitudes.

Until this problem is resolved, there is no point in letting the calculations go beyond the first time step.

Gennady: Samzmse is probably solving a time-dependent physical problem, such as diffusion or evolution. After discretizing time and space, the differential equations are reduced to a system of algebraic equations. These equations are solved for t = dt, 2 dt, 3 dt, ...

0 Kudos
samzmse
Beginner
363 Views
mecej4 and Gennady

Thank you so much for all of your helpful comments. Gennady was correct in his first post- it was a user error (mine).

Mecej4 was correct- I was solving a time dependent heat transfer problem. The code had a modified Newton Raphson scheme where the matrix on the left hand side was only updated a certain number of times. For some reason, which I do still not quite fully understand, when I changed the corresponding lines of code from the IMSL routines to the MKL routines, it was not calling factorization routine, and this was what was causing the errors. Using mecej4's suggestion, I was able to track it down to the program not factorizing the matrix in certain cases, and have modified the code to make sure that it is factorized.

So thank you both for your help. I wouldn't have been able to find this error without your help! And you were both right, it was not an "MKL vs IMSL" issue.
0 Kudos
Reply