<?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 Hi, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026223#M19928</link>
    <description>&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Hi,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Please see my comments below&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Thanks,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Alex&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;SPAN style="line-height: 1.5;"&gt;&amp;gt; &lt;EM&gt;When I create a matrix handle using routine mkl_sparse_?_create_csr, the handle will copy all data to new memory blocks? Or it only save the pointers in handle?&lt;/EM&gt; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;SPAN style="line-height: 1.5;"&gt;It save pointer in handle only.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;gt; &lt;EM&gt;2. As the result of routine&amp;nbsp;&lt;A href="https://software.intel.com/node/9e16b849-6c81-4aca-8214-90f6d8516cec"&gt;mkl_sparse_spmm&lt;/A&gt;&amp;nbsp;, is it created in mkl routines？I will call destroy routine for it ? And then the internal data like column indexes array and matrix values array should be free expicit or not?&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Didn't got it. This function return &amp;nbsp;&lt;SPAN class="kwd" style="box-sizing: border-box; font-family: 'Courier New', Courier, monospace; color: rgb(102, 102, 102); font-size: 13px; line-height: 18.2000007629395px;"&gt;sparse_matrix_t&lt;/SPAN&gt;&lt;SPAN style="color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 18.2000007629395px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="var" style="box-sizing: border-box; font-style: italic; font-family: 'Courier New', Courier, monospace; color: rgb(102, 102, 102); font-size: 13px; line-height: 18.2000007629395px;"&gt;*C&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;which contain result of multiplication and could be used in further routines and/or export routine.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;gt; &lt;EM&gt;By the way, I found routines declared in header file : mkl_sparse_?_set_value, but they are not found in manual. And there are comment about these routines:&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;EM&gt;/* update existing value in the matrix ( for internal storage only, should not work with user-allocated matrices) */&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;EM&gt;It means I can not using them in my code?&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;This function allow you to change value of matrix in sparse_matrix structure so i don't see any barrier to use it in your code&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Thanks,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Tianxiong Lu&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2015 18:54:02 GMT</pubDate>
    <dc:creator>Alexander_K_Intel2</dc:creator>
    <dc:date>2015-09-14T18:54:02Z</dc:date>
    <item>
      <title>What is the memory management strategy in sparse_matrix_t ?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026222#M19927</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I have two questions about memory management of sparse_matrix_t :&lt;/P&gt;

&lt;P&gt;1. When I create a matrix handle using routine mkl_sparse_?_create_csr, the handle will copy all data to new memory blocks? Or it only save the pointers in handle?&amp;nbsp; If it copy all data to new block, and the routine mkl_sparse_destroy will free these memory blocks or not ?&lt;/P&gt;

&lt;P&gt;2. As the result of routine &lt;A href="https://software.intel.com/node/9e16b849-6c81-4aca-8214-90f6d8516cec"&gt;mkl_sparse_spmm&lt;/A&gt; , is it created in mkl routines？I will call destroy routine for it ? And then the internal data like column indexes array and matrix values array should be free expicit or not?&lt;/P&gt;

&lt;P&gt;By the way, I found routines declared in header file : mkl_sparse_?_set_value, but they are not found in manual. And there are comment about these routines:&lt;/P&gt;

&lt;P&gt;/* update existing value in the matrix ( for internal storage only, should not work with user-allocated matrices) */&lt;/P&gt;

&lt;P&gt;It means I can not using them in my code?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Tianxiong Lu&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 16:18:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026222#M19927</guid>
      <dc:creator>Tianxiong_Lu</dc:creator>
      <dc:date>2015-09-14T16:18:27Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026223#M19928</link>
      <description>&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Hi,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Please see my comments below&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Thanks,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Alex&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;SPAN style="line-height: 1.5;"&gt;&amp;gt; &lt;EM&gt;When I create a matrix handle using routine mkl_sparse_?_create_csr, the handle will copy all data to new memory blocks? Or it only save the pointers in handle?&lt;/EM&gt; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;SPAN style="line-height: 1.5;"&gt;It save pointer in handle only.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;gt; &lt;EM&gt;2. As the result of routine&amp;nbsp;&lt;A href="https://software.intel.com/node/9e16b849-6c81-4aca-8214-90f6d8516cec"&gt;mkl_sparse_spmm&lt;/A&gt;&amp;nbsp;, is it created in mkl routines？I will call destroy routine for it ? And then the internal data like column indexes array and matrix values array should be free expicit or not?&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Didn't got it. This function return &amp;nbsp;&lt;SPAN class="kwd" style="box-sizing: border-box; font-family: 'Courier New', Courier, monospace; color: rgb(102, 102, 102); font-size: 13px; line-height: 18.2000007629395px;"&gt;sparse_matrix_t&lt;/SPAN&gt;&lt;SPAN style="color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 13px; line-height: 18.2000007629395px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="var" style="box-sizing: border-box; font-style: italic; font-family: 'Courier New', Courier, monospace; color: rgb(102, 102, 102); font-size: 13px; line-height: 18.2000007629395px;"&gt;*C&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;which contain result of multiplication and could be used in further routines and/or export routine.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;gt; &lt;EM&gt;By the way, I found routines declared in header file : mkl_sparse_?_set_value, but they are not found in manual. And there are comment about these routines:&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;EM&gt;/* update existing value in the matrix ( for internal storage only, should not work with user-allocated matrices) */&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;EM&gt;It means I can not using them in my code?&lt;/EM&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;This function allow you to change value of matrix in sparse_matrix structure so i don't see any barrier to use it in your code&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Thanks,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Tianxiong Lu&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2015 18:54:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026223#M19928</guid>
      <dc:creator>Alexander_K_Intel2</dc:creator>
      <dc:date>2015-09-14T18:54:02Z</dc:date>
    </item>
    <item>
      <title>Hi Alex,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026224#M19929</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Hi Alex,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;1. What does the means "&lt;EM style="font-size: 11.666666030883789px; line-height: 14.999999046325684px;"&gt;should not work with user-allocated matrices“ ？Maybe I can ignore it.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM style="font-size: 11.666666030883789px; line-height: 14.999999046325684px;"&gt;2.&amp;nbsp;&lt;/EM&gt;&lt;SPAN style="font-size: 11.666666030883789px; line-height: 14.999999046325684px; font-style: italic;"&gt;-- Didn't got it. This function return &amp;nbsp;sparse_matrix_t&amp;nbsp;*C&amp;nbsp;which contain result of multiplication and could be used in further routines and/or export routine.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 11.666666030883789px; line-height: 14.999999046325684px;"&gt;Did you mean that MKL will free struct C ? Or I should destroy it while program finished.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Tianxiong Lu&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2015 01:41:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026224#M19929</guid>
      <dc:creator>Tianxiong_Lu</dc:creator>
      <dc:date>2015-09-15T01:41:14Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026225#M19930</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;1. What does the means "&lt;/SPAN&gt;&lt;EM style="font-size: 12px; line-height: 18px;"&gt;should not work with user-allocated matrices“ ？Maybe I can ignore it.&amp;nbsp;&lt;/EM&gt;- yes, just ignore i&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;2. Did you mean that MKL will free struct C.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;In the end of the program you need to call&amp;nbsp;&lt;/SPAN&gt;mkl_sparse_destroy ( C ) routine to free struct C&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 09:46:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026225#M19930</guid>
      <dc:creator>Alexander_K_Intel2</dc:creator>
      <dc:date>2015-09-24T09:46:29Z</dc:date>
    </item>
    <item>
      <title>Hi Tianxiong, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026226#M19931</link>
      <description>&lt;P&gt;Hi Tianxiong,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Just update the thread. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;There is new example, sparse_sppm.c added in MKL 11.3 update 3, in which we show how to use mkl_sparse_spmm and mkl_sparse_export_csr.&lt;BR /&gt;
	&lt;BR /&gt;
	There also is shown how to work with attendant arrays and memory for them.&lt;/P&gt;

&lt;P&gt;You are welcomed to try it.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Ying&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;/*******************************************************************************
* Copyright 2013-2016 Intel Corporation All Rights Reserved.
*
* The source code,  information  and material  ("Material") contained  herein is
* owned by Intel Corporation or its  suppliers or licensors,  and  title to such
* Material remains with Intel  Corporation or its  suppliers or  licensors.  The
* Material  contains  proprietary  information  of  Intel or  its suppliers  and
* licensors.  The Material is protected by  worldwide copyright  laws and treaty
* provisions.  No part  of  the  Material   may  be  used,  copied,  reproduced,
* modified, published,  uploaded, posted, transmitted,  distributed or disclosed
* in any way without Intel's prior express written permission.  No license under
* any patent,  copyright or other  intellectual property rights  in the Material
* is granted to  or  conferred  upon  you,  either   expressly,  by implication,
* inducement,  estoppel  or  otherwise.  Any  license   under such  intellectual
* property rights must be express and approved by Intel in writing.
*
* Unless otherwise agreed by Intel in writing,  you may not remove or alter this
* notice or  any  other  notice   embedded  in  Materials  by  Intel  or Intel's
* suppliers or licensors in any way.
*******************************************************************************/

/******************************************************************************
*
* Consider the matrix A
*
*                 |  10     11      0     0     0   |
*                 |   0      0     12    13     0   |
*   A    =        |  15      0      0     0    14   |,
*                 |   0     16     17     0     0   |
*                 |   0      0      0    18    19   |
*
* and diagonal matrix B
*
*                 |   5      0      0     0     0   |
*                 |   0      6      0     0     0   |
*   B    =        |   0      0      7     0     0   |.
*                 |   0      0      0     8     0   |
*                 |   0      0      0     0     9   |
*
*  Both matrices A and B are stored in a zero-based compressed sparse row (CSR) storage
*  scheme with three arrays (see 'Sparse Matrix Storage Schemes' in the
*  Intel Math Kernel Library Developer Reference) as follows:
*
*           values_A = ( 10  11  12  13  15  14  16  17  18  19 )
*          columns_A = (  0   1   2   3   0   4   1   2   3   4 )
*         rowIndex_A = (  0       2       4       6       8      10 )
*
*           values_B = ( 5  6  7  8  9  )
*          columns_B = ( 0  1  2  3  4  )
*         rowIndex_B = ( 0  1  2  3  4  5 )
*
*  The example computes two scalar products :
*
*         &amp;lt; (A*B)*x ,       y &amp;gt; = left,   using MKL_SPARSE_D_SPMM and CBLAS_DDOT.
*         &amp;lt;     B*x , (A^t)*y &amp;gt; = right,  using MKL_SPARSE_D_MV and CBLAS_DDOT.
*
*         These products should result in the same value. To obtain matrix C,
*         use MKL_SPARSE_D_EXPORT_CSR and print the result.
*
******************************************************************************/

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;assert.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include "mkl.h"

int main() {

#define M 5
#define NNZ 10
#define ALIGN 128

/* To avoid constantly repeating the part of code that checks inbound SparseBLAS functions' status,
   use macro CALL_AND_CHECK_STATUS */
#define CALL_AND_CHECK_STATUS(function, error_message) do { \
          if(function != SPARSE_STATUS_SUCCESS)             \
          {                                                 \
          printf(error_message); fflush(0);                 \
          status = 1;                                       \
          goto memory_free;                                 \
          }                                                 \
} while(0)

/* Declaration of values */
    double  *values_A = NULL, *values_B = NULL, *values_C = NULL;
    MKL_INT *columns_A = NULL, *columns_B = NULL, *columns_C = NULL;
    MKL_INT *rowIndex_A = NULL, *rowIndex_B = NULL, *pointerB_C = NULL, *pointerE_C = NULL;

    double  *rslt_mv = NULL, *rslt_mv_trans = NULL, *x = NULL, *y = NULL;

    double   left, right, residual;
    MKL_INT  rows, cols, i, j, ii, status;

    sparse_index_base_t    indexing;
    struct matrix_descr    descr_type_gen;
    sparse_matrix_t        csrA = NULL, csrB = NULL, csrC = NULL;

/* Allocation of memory */
    values_A = (double *)mkl_malloc(sizeof(double) * NNZ, ALIGN);
    columns_A = (MKL_INT *)mkl_malloc(sizeof(MKL_INT) * NNZ, ALIGN);
    rowIndex_A = (MKL_INT *)mkl_malloc(sizeof(MKL_INT) * (M + 1), ALIGN);

    values_B = (double *)mkl_malloc(sizeof(double) * M, ALIGN);
    columns_B = (MKL_INT *)mkl_malloc(sizeof(MKL_INT) * M, ALIGN);
    rowIndex_B = (MKL_INT *)mkl_malloc(sizeof(MKL_INT) * (M + 1), ALIGN);

    x = (double *)mkl_malloc(sizeof(double) * M, ALIGN);
    y = (double *)mkl_malloc(sizeof(double) * M, ALIGN);
    rslt_mv = (double *)mkl_malloc(sizeof(double) * M, ALIGN);
    rslt_mv_trans = (double *)mkl_malloc(sizeof(double) * M, ALIGN);

/* Set values of the variables*/
    descr_type_gen.type = SPARSE_MATRIX_TYPE_GENERAL;
    status = 0, ii = 0;
 //Matrix A 
    for( i = 0; i &amp;lt; NNZ; i++ )
          values_A&lt;I&gt; = i + 10;
    for( i = 0; i &amp;lt; NNZ; i++ )
          columns_A&lt;I&gt; = i % 5;
    rowIndex_A[0] = 0;
    for( i = 1; i &amp;lt; M + 1; i++ )
          rowIndex_A&lt;I&gt; = rowIndex_A[i - 1] + 2;

 //Matrix B
    for( i = 0; i &amp;lt; M; i++ )
          values_B&lt;I&gt; = i + 5;
    for( i = 0; i &amp;lt; M; i++ )
          columns_B&lt;I&gt; = i % 5;
    for( i = 0; i &amp;lt; M + 1; i++ )
          rowIndex_B&lt;I&gt; = i;

 //Vectors x and y
    for( i = 0; i &amp;lt; M; i++ )
    {
          x&lt;I&gt; = 1.0; y&lt;I&gt; = 1.0;
    }
/* Printing usable data */
    printf( "\n\n_______________Example program for MKL_SPARSE_D_SPMM_________________\n\n" );
    printf( " COMPUTE  A * B = C, where matrices are stored in CSR format\n" );
    printf( "\n MATRIX A:\nrow# : (value, column) (value, column)\n" );
    for( i = 0; i &amp;lt; M; i++ )
    {
        printf("row#%d:", i + 1); fflush(0);
        for( j = rowIndex_A&lt;I&gt;; j &amp;lt; rowIndex_A[i+1]; j++ )
        {
            printf(" (%5.0f, %6d)", values_A[ii], columns_A[ii] ); fflush(0);
            ii++;
        }
        printf( "\n" );
    }
    ii = 0;
    printf( "\n MATRIX B:\nrow# : (value, column)\n" );
    for( i = 0; i &amp;lt; M; i++ )
    {
        printf("row#%d:", i + 1); fflush(0);
        for( j = rowIndex_B&lt;I&gt;; j &amp;lt; rowIndex_B[i+1]; j++ )
        {
            printf(" (%5.0f, %6d)", values_B[ii], columns_B[ii] ); fflush(0);
            ii++;
        }
        printf( "\n" );
    }
    printf( "\n Check the resultant matrix C, using two scalar products\n" );
    printf( " (values of these scalar products must match).\n" );

/* Prepare arrays, which are related to matrices.
   Create handles for matrices A and B stored in CSR format */
    CALL_AND_CHECK_STATUS(mkl_sparse_d_create_csr( &amp;amp;csrA, SPARSE_INDEX_BASE_ZERO, M, M, rowIndex_A, rowIndex_A+1, columns_A, values_A ),
                          "Error after MKL_SPARSE_D_CREATE_CSR, csrA \n");
    CALL_AND_CHECK_STATUS(mkl_sparse_d_create_csr( &amp;amp;csrB, SPARSE_INDEX_BASE_ZERO, M, M, rowIndex_B, rowIndex_B+1, columns_B, values_B ),
                          "Error after MKL_SPARSE_D_CREATE_CSR, csrB \n");

/* Compute C = A * B  */
    CALL_AND_CHECK_STATUS(mkl_sparse_spmm( SPARSE_OPERATION_NON_TRANSPOSE, csrA, csrB, &amp;amp;csrC ),
                          "Error after MKL_SPARSE_SPMM \n");

/* Analytic Routines for MKL_SPARSE_D_MV.
   HINTS: provides estimate of number and type of upcoming matrix-vector operations
   OPTIMIZE: analyze sparse matrix; choose proper kernels and workload balancing strategy */
    CALL_AND_CHECK_STATUS(mkl_sparse_set_mv_hint( csrA, SPARSE_OPERATION_TRANSPOSE,     descr_type_gen, 1 ),
                          "Error after MKL_SPARSE_SET_MV_HINT, csrA \n");
    CALL_AND_CHECK_STATUS(mkl_sparse_set_mv_hint( csrB, SPARSE_OPERATION_NON_TRANSPOSE, descr_type_gen, 1 ),
                          "Error after MKL_SPARSE_SET_MV_HINT, csrB \n");
    CALL_AND_CHECK_STATUS(mkl_sparse_set_mv_hint( csrC, SPARSE_OPERATION_NON_TRANSPOSE, descr_type_gen, 1 ),
                          "Error after MKL_SPARSE_SET_MV_HINT, csrC \n");

    CALL_AND_CHECK_STATUS(mkl_sparse_optimize( csrA ),
                          "Error after MKL_SPARSE_OPTIMIZE, csrA \n");
    CALL_AND_CHECK_STATUS(mkl_sparse_optimize( csrB ),
                          "Error after MKL_SPARSE_OPTIMIZE, csrB \n");
    CALL_AND_CHECK_STATUS(mkl_sparse_optimize( csrC ),
                          "Error after MKL_SPARSE_OPTIMIZE, csrC \n");

/* Execution Routines */
/* Step 1:
          Need to compute the following variables:
                 rslt_mv = C * x
                    left = &amp;lt;rslt_mv, y&amp;gt;              */
    CALL_AND_CHECK_STATUS(mkl_sparse_d_mv( SPARSE_OPERATION_NON_TRANSPOSE, 1.0, csrC, descr_type_gen, x, 0.0, rslt_mv ),
                          "Error after MKL_SPARSE_D_MV, csrC*x  \n");
    left = cblas_ddot( M, rslt_mv, 1, y, 1 );

/* Step 2:
          Need to compute the following variables:
           rslt_mv       =     B * x
           rslt_mv_trans = (A)^t * y
                   right = &amp;lt;rslt_mv, rslt_mv_trans&amp;gt;  */

    CALL_AND_CHECK_STATUS(mkl_sparse_d_mv( SPARSE_OPERATION_NON_TRANSPOSE, 1.0, csrB, descr_type_gen, x, 0.0, rslt_mv ),
                          "Error after MKL_SPARSE_D_MV, csrB*x  \n");
    CALL_AND_CHECK_STATUS(mkl_sparse_d_mv( SPARSE_OPERATION_TRANSPOSE,     1.0, csrA, descr_type_gen, y, 0.0, rslt_mv_trans),
                          "Error after MKL_SPARSE_D_MV, csrA*y  \n");
    right = cblas_ddot( M, rslt_mv, 1, rslt_mv_trans, 1);

/* Step 3:
          Compare values obtained for left and right  */
    residual = fabs(left - right)/(fabs(left)+1);

    printf( "\n The difference between &amp;lt; C*x , y &amp;gt; and &amp;lt; B*x , (A^t)*y &amp;gt; = %g,\n", residual );
    printf( " which means that MKL_SPARSE_D_SPMM arrived correct at a solution.\n" );
/* Printing OUTPUT DATA */
    CALL_AND_CHECK_STATUS(mkl_sparse_d_export_csr( csrC, &amp;amp;indexing, &amp;amp;rows, &amp;amp;cols, &amp;amp;pointerB_C, &amp;amp;pointerE_C, &amp;amp;columns_C, &amp;amp;values_C ),
                          "Error after MKL_SPARSE_D_EXPORT_CSR  \n");

    printf( "\n RESULTANT MATRIX C:\nrow# : (value, column) (value, column)\n" );
    ii = 0;
    for( i = 0; i &amp;lt; M; i++ )
    {
        printf("row#%d:", i + 1); fflush(0);
        for( j = pointerB_C&lt;I&gt;; j &amp;lt; pointerE_C&lt;I&gt;; j++ )
        {
            printf(" (%5.0f, %6d)", values_C[ii], columns_C[ii] ); fflush(0);
            ii++;
        }
        printf( "\n" );
    }
    printf( "_____________________________________________________________________  \n" );

/* Deallocate memory */
memory_free:
 &lt;STRONG&gt;//Release matrix handle. Not necessary to deallocate arrays for which we don't allocate memory: values_C, columns_C, pointerB_C, and pointerE_C.
 //These arrays will be deallocated together with csrC structure.
    if( mkl_sparse_destroy( csrC ) != SPARSE_STATUS_SUCCESS)
    { printf(" Error after MKL_SPARSE_DESTROY, csrC \n");fflush(0); status = 1; }
&lt;/STRONG&gt;
 //Deallocate arrays for which we allocate memory ourselves.
    mkl_free(rslt_mv_trans); mkl_free(rslt_mv); mkl_free(x); mkl_free(y);

 //Release matrix handle and deallocate arrays for which we allocate memory ourselves.
    if( mkl_sparse_destroy( csrA ) != SPARSE_STATUS_SUCCESS)
    { printf(" Error after MKL_SPARSE_DESTROY, csrA \n");fflush(0); status = 1; }
    mkl_free(values_A); mkl_free(columns_A); mkl_free(rowIndex_A);

    if( mkl_sparse_destroy( csrB ) != SPARSE_STATUS_SUCCESS)
    { printf(" Error after MKL_SPARSE_DESTROY, csrB \n");fflush(0); status = 1; }
    mkl_free(values_B); mkl_free(columns_B); mkl_free(rowIndex_B);


    return status;
}&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;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2016 01:47:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/What-is-the-memory-management-strategy-in-sparse-matrix-t/m-p/1026226#M19931</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2016-05-23T01:47:10Z</dc:date>
    </item>
  </channel>
</rss>

