<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Memory crash in DSS in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978983#M17306</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I modified DSS solver so that I could solve my own system using it but at the dss_solve_real step memory error occurs. I use malloc to allocate memory for the system while the example dss_sym_c.c uses static constants.&lt;/P&gt;

&lt;P&gt;When I try to solve 1000 x 1000 system my program crashes with a segmentation fault. In case of larger systems 100 000 x 100 000 "MKL-DSS-DSS-Error, Out of memory" happens.&lt;/P&gt;

&lt;P&gt;Here's the code:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
#include&amp;lt;math.h&amp;gt;
#include "mkl_dss.h"
#include "mkl_types.h"

MKL_INT
main ()
{
  MKL_INT i;
  _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_INDEFINITE;
  MKL_INT nRows;
  MKL_INT nCols;
  MKL_INT nNonZeros;
  MKL_INT nRhs;
  _INTEGER_t *rowIndex;
  _INTEGER_t *columns;
  _DOUBLE_PRECISION_t *values;
  _DOUBLE_PRECISION_t *rhs;
  _DOUBLE_PRECISION_t *solValues;

  FILE *In;
  MKL_INT n, nz;
  MKL_INT *I = NULL, *J = NULL;
 _DOUBLE_PRECISION_t *val = NULL, *sol = NULL, *RHS = NULL;

  if ( ( In = fopen ("matr_rhs_binary", "rb" ) ) == NULL ) {
    fprintf (stderr, "Error opening file\n");		
    return (-1);
  }

  fread ( &amp;amp;n, sizeof(MKL_INT), 1, In );
  printf ("n = %d\n", n);	

  fread ( &amp;amp;nz, sizeof(MKL_INT), 1, In );
  printf ("nz = %d\n", nz);

  I = (MKL_INT *) malloc ( sizeof (I[0]) * (n + 1));                             // csr row pointers for matrix A
  J = (MKL_INT *) malloc ( sizeof (J[0]) * nz);                                  // csr column indices for matrix A
  val = (_DOUBLE_PRECISION_t *) malloc ( sizeof (val[0]) * nz);                  // csr values for matrix A	
  sol = (_DOUBLE_PRECISION_t *) malloc ( sizeof (sol[0]) * n);
  RHS = (_DOUBLE_PRECISION_t *) malloc ( sizeof (RHS[0]) * n);

  for (i = 0; i &amp;lt; n + 1; i++)
    fread ( &amp;amp;(I&lt;I&gt;), sizeof(I[0]), 1, In );
  for (i = 0; i &amp;lt; nz; i++)
    fread ( &amp;amp;(val&lt;I&gt;), sizeof(val[0]), 1, In );
  for (i = 0; i &amp;lt; nz; i++)
    fread ( &amp;amp;(J&lt;I&gt;), sizeof(J[0]), 1, In );
  for (i = 0; i &amp;lt; n; i++)
    fread ( &amp;amp;(RHS&lt;I&gt;), sizeof(RHS[0]), 1, In);	
	
  fclose (In);

  nRows = n;
  nCols = n;
  nNonZeros = nz;
  nRhs = n;

  rowIndex = (_INTEGER_t *) malloc ( sizeof (rowIndex[0]) * (nRows + 1) );
  columns = (_INTEGER_t *) malloc ( sizeof (columns[0]) * nNonZeros );
  values = (_DOUBLE_PRECISION_t *) malloc ( sizeof (values[0]) * nNonZeros );
  rhs = (_DOUBLE_PRECISION_t *) malloc ( sizeof (rhs[0]) * nCols );
  solValues = (_DOUBLE_PRECISION_t *) malloc ( sizeof (solValues[0]) * nCols );

  for (i = 0; i &amp;lt; n + 1; i++)
    rowIndex&lt;I&gt; = I&lt;I&gt;;
  for (i = 0; i &amp;lt; n; i++)
    rhs&lt;I&gt; = RHS&lt;I&gt;;
  for (i = 0; i &amp;lt; nz; i++) {
    columns&lt;I&gt; = J&lt;I&gt;;
    values&lt;I&gt; = val&lt;I&gt;;
  }
/* --------------------- */
/* 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 &amp;lt; 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 &amp;lt; nCols; i++)
    printf (" %g", solValues&lt;I&gt;);
  printf ("\n");
  exit (0);
printError:
  printf ("Solver returned error code %d\n", error);
  exit (1);
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 12 Apr 2014 15:23:18 GMT</pubDate>
    <dc:creator>Max_T_</dc:creator>
    <dc:date>2014-04-12T15:23:18Z</dc:date>
    <item>
      <title>Memory crash in DSS</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978983#M17306</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I modified DSS solver so that I could solve my own system using it but at the dss_solve_real step memory error occurs. I use malloc to allocate memory for the system while the example dss_sym_c.c uses static constants.&lt;/P&gt;

&lt;P&gt;When I try to solve 1000 x 1000 system my program crashes with a segmentation fault. In case of larger systems 100 000 x 100 000 "MKL-DSS-DSS-Error, Out of memory" happens.&lt;/P&gt;

&lt;P&gt;Here's the code:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
#include&amp;lt;math.h&amp;gt;
#include "mkl_dss.h"
#include "mkl_types.h"

MKL_INT
main ()
{
  MKL_INT i;
  _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_INDEFINITE;
  MKL_INT nRows;
  MKL_INT nCols;
  MKL_INT nNonZeros;
  MKL_INT nRhs;
  _INTEGER_t *rowIndex;
  _INTEGER_t *columns;
  _DOUBLE_PRECISION_t *values;
  _DOUBLE_PRECISION_t *rhs;
  _DOUBLE_PRECISION_t *solValues;

  FILE *In;
  MKL_INT n, nz;
  MKL_INT *I = NULL, *J = NULL;
 _DOUBLE_PRECISION_t *val = NULL, *sol = NULL, *RHS = NULL;

  if ( ( In = fopen ("matr_rhs_binary", "rb" ) ) == NULL ) {
    fprintf (stderr, "Error opening file\n");		
    return (-1);
  }

  fread ( &amp;amp;n, sizeof(MKL_INT), 1, In );
  printf ("n = %d\n", n);	

  fread ( &amp;amp;nz, sizeof(MKL_INT), 1, In );
  printf ("nz = %d\n", nz);

  I = (MKL_INT *) malloc ( sizeof (I[0]) * (n + 1));                             // csr row pointers for matrix A
  J = (MKL_INT *) malloc ( sizeof (J[0]) * nz);                                  // csr column indices for matrix A
  val = (_DOUBLE_PRECISION_t *) malloc ( sizeof (val[0]) * nz);                  // csr values for matrix A	
  sol = (_DOUBLE_PRECISION_t *) malloc ( sizeof (sol[0]) * n);
  RHS = (_DOUBLE_PRECISION_t *) malloc ( sizeof (RHS[0]) * n);

  for (i = 0; i &amp;lt; n + 1; i++)
    fread ( &amp;amp;(I&lt;I&gt;), sizeof(I[0]), 1, In );
  for (i = 0; i &amp;lt; nz; i++)
    fread ( &amp;amp;(val&lt;I&gt;), sizeof(val[0]), 1, In );
  for (i = 0; i &amp;lt; nz; i++)
    fread ( &amp;amp;(J&lt;I&gt;), sizeof(J[0]), 1, In );
  for (i = 0; i &amp;lt; n; i++)
    fread ( &amp;amp;(RHS&lt;I&gt;), sizeof(RHS[0]), 1, In);	
	
  fclose (In);

  nRows = n;
  nCols = n;
  nNonZeros = nz;
  nRhs = n;

  rowIndex = (_INTEGER_t *) malloc ( sizeof (rowIndex[0]) * (nRows + 1) );
  columns = (_INTEGER_t *) malloc ( sizeof (columns[0]) * nNonZeros );
  values = (_DOUBLE_PRECISION_t *) malloc ( sizeof (values[0]) * nNonZeros );
  rhs = (_DOUBLE_PRECISION_t *) malloc ( sizeof (rhs[0]) * nCols );
  solValues = (_DOUBLE_PRECISION_t *) malloc ( sizeof (solValues[0]) * nCols );

  for (i = 0; i &amp;lt; n + 1; i++)
    rowIndex&lt;I&gt; = I&lt;I&gt;;
  for (i = 0; i &amp;lt; n; i++)
    rhs&lt;I&gt; = RHS&lt;I&gt;;
  for (i = 0; i &amp;lt; nz; i++) {
    columns&lt;I&gt; = J&lt;I&gt;;
    values&lt;I&gt; = val&lt;I&gt;;
  }
/* --------------------- */
/* 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 &amp;lt; 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 &amp;lt; nCols; i++)
    printf (" %g", solValues&lt;I&gt;);
  printf ("\n");
  exit (0);
printError:
  printf ("Solver returned error code %d\n", error);
  exit (1);
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Apr 2014 15:23:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978983#M17306</guid>
      <dc:creator>Max_T_</dc:creator>
      <dc:date>2014-04-12T15:23:18Z</dc:date>
    </item>
    <item>
      <title>Hello, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978984#M17307</link>
      <description>&lt;P&gt;&lt;BR /&gt;
	Hello,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;For the large matrix size with the out of memory error, you can use the out of core interfaces, &amp;nbsp;it will save some computation data into the disk.&amp;nbsp;&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;For the segmentation fault with the matrix size 1000x1000, is that only matrix that report the problem? For other similar or small size of Matrix, &amp;nbsp;can your code work for you?&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;If this is only related to that matrix, we need the test data to investigate the problem. &amp;nbsp; If you can not attached in the user forum, you may submit some issue in the intel premier support &amp;nbsp;to attach the data.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
	Chao&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2014 02:10:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978984#M17307</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2014-04-14T02:10:22Z</dc:date>
    </item>
    <item>
      <title>Oops! I found a misprint:</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978985#M17308</link>
      <description>&lt;P&gt;Oops! I found a misprint: nRhs = 1. Now memory doesn't crash, but I get a zero solution. The problem is definately not in the matrix because I tested the program on several systems and was always getting zero.&amp;nbsp; What can be the reason of it?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2014 15:14:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-crash-in-DSS/m-p/978985#M17308</guid>
      <dc:creator>Max_T_</dc:creator>
      <dc:date>2014-04-14T15:14:00Z</dc:date>
    </item>
  </channel>
</rss>

