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.
7234 Discussions

Memory leaks while using Intel MKL DSS subroutines

vijay1
Beginner
858 Views
Hello,
I am using Intel MKL DSS subroutines to solve a sparse symmetric matrix. Attached is the sample program that I ran. I get memory leaks at the end of the application run. Do I need to use some function in addition to dss_delete() to clean up memory used by DSS subroutines. Please help!
Thanks,
Vijay
/*
********************************************************************************
* Content : MKL DSS C example
*
********************************************************************************
*/
/*
**
** Example program to solve symmetric positive definite system of equations.
**
*/
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#include "mkl_dss.h"
#include "mkl_types.h"
/*
** Define the array and rhs vectors
*/
#define NROWS 5
#define NCOLS 5
#define NNONZEROS 9
#define NRHS 1
static const MKL_INT nRows = NROWS;
static const MKL_INT nCols = NCOLS;
static const MKL_INT nNonZeros = NNONZEROS;
static const MKL_INT nRhs = NRHS;
static _INTEGER_t rowIndex[NROWS + 1] = { 1, 6, 7, 8, 9, 10 };
static _INTEGER_t columns[NNONZEROS] = { 1, 2, 3, 4, 5, 2, 3, 4, 5 };
static _DOUBLE_PRECISION_t values[NNONZEROS] =
{ 9, 1.5, 6, .75, 3, 0.5, 12, .625, 16 };
static _DOUBLE_PRECISION_t rhs[NCOLS] = { 1, 2, 3, 4, 5 };
MKL_INT
main ()
{
#ifdef _DEBUG
_CrtMemState MemState;
_CrtMemCheckpoint(&MemState);
// Use this method to check for memory leaks:
// If you get the following leak message upon closing the app:
// {204} normal block at 0x002F5610, 24 bytes long.
// Data: < c/ Xb/ d/ > 08 63 2F 00 58 62 2F 00 10 64 2F 00 CD CD CD CD
// Then you should call:
//_CrtSetBreakAlloc(4872L);
//
//_CrtSetBreakAlloc(1000);
//_CrtSetBreakAlloc(3411);
_CrtSetBreakAlloc(215);
#endif
MKL_INT i;
/* Allocate storage for the solver handle and the right-hand side. */
_DOUBLE_PRECISION_t solValues[NROWS];
_MKL_DSS_HANDLE_t handle;
_INTEGER_t error;
_CHARACTER_t statIn[] = "determinant";
_DOUBLE_PRECISION_t statOut[5];
MKL_INT opt = MKL_DSS_DEFAULTS;
MKL_INT sym = MKL_DSS_SYMMETRIC;
MKL_INT type = MKL_DSS_POSITIVE_DEFINITE;
/* --------------------- */
/* Initialize the solver */
/* --------------------- */
error = dss_create (handle, opt);
if (error != MKL_DSS_SUCCESS)
goto printError;
/* ------------------------------------------- */
/* Define the non-zero structure of the matrix */
/* ------------------------------------------- */
error = dss_define_structure (handle, sym, rowIndex, nRows, nCols,
columns, nNonZeros);
if (error != MKL_DSS_SUCCESS)
goto printError;
/* ------------------ */
/* Reorder the matrix */
/* ------------------ */
error = dss_reorder (handle, opt, 0);
if (error != MKL_DSS_SUCCESS)
goto printError;
/* ------------------ */
/* Factor the matrix */
/* ------------------ */
error = dss_factor_real (handle, type, values);
if (error != MKL_DSS_SUCCESS)
goto printError;
/* ------------------------ */
/* Get the solution vector */
/* ------------------------ */
error = dss_solve_real (handle, opt, rhs, nRhs, solValues);
if (error != MKL_DSS_SUCCESS)
goto printError;
/* ------------------------ */
/* Get the determinant (not for a diagonal matrix) */
/*--------------------------*/
if (nRows < nNonZeros)
{
error = dss_statistics (handle, opt, statIn, statOut);
if (error != MKL_DSS_SUCCESS)
goto printError;
/*-------------------------*/
/* print determinant */
/*-------------------------*/
printf (" determinant power is %g \\n", statOut[0]);
printf (" determinant base is %g \\n", statOut[1]);
printf (" Determinant is %g \\n", (pow (10.0, statOut[0])) * statOut[1]);
}
/* -------------------------- */
/* Deallocate solver storage */
/* -------------------------- */
error = dss_delete (handle, opt);
if (error != MKL_DSS_SUCCESS)
goto printError;
/* ---------------------- */
/* Print solution vector */
/* ---------------------- */
printf (" Solution array: ");
for (i = 0; i < nCols; i++)
printf (" %g", solValues);
printf ("\\n");
#ifdef _DEBUG
_CrtMemDumpAllObjectsSince(&MemState);
//_CrtDumpMemoryLeaks();
#endif
exit (0);
printError:
printf ("Solver returned error code %d\\n", error);
exit (1);
}
0 Kudos
1 Solution
Gennady_F_Intel
Moderator
858 Views
this is the expected behaviour - please check with user's guide - "Using memory management"

View solution in original post

0 Kudos
1 Reply
Gennady_F_Intel
Moderator
859 Views
this is the expected behaviour - please check with user's guide - "Using memory management"
0 Kudos
Reply