<?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 Re: clarify mkl-sparse-sort in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521744#M35073</link>
    <description>&lt;P&gt;For the sake of others landing here, allow me to add an example of what &lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-2/oneapi-mkl-sparse-sort-matrix.html" target="_self"&gt;oneapi::mkl::sort_matrix()&lt;/A&gt; does:&lt;/P&gt;&lt;P&gt;Consider a dense matrix with 6 non-zero values:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;         | 0  c  0  0 |
denseA = | a  0  e  0 |
         | b  d  0  f |&lt;/LI-CODE&gt;&lt;P&gt;Here's &lt;STRONG&gt;an&lt;/STRONG&gt; example of an unsorted CSR matrix representation of the above dense matrix in 0-based indexing:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;                     |&amp;lt;r1&amp;gt;|&amp;lt;--r2--&amp;gt;|&amp;lt;---r3---&amp;gt;|
sortedCsrARowPtr   = [ 0  |  1     |  3       | 6 ] &amp;lt;- Always sorted by definition
unsortedCsrAColInd = [ 1  |  2  0  |  3  0  1 ]     &amp;lt;- Unsorted
unsortedCsrAValues = [ c  |  e  a  |  f  b  d ]     &amp;lt;- Unsorted, associated to colInd&lt;/LI-CODE&gt;&lt;P&gt;Here's how the unique sorted representation of the above CSR matrix looks like, which is what &lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-2/oneapi-mkl-sparse-sort-matrix.html" target="_self"&gt;oneapi::mkl::sort_matrix()&lt;/A&gt; would give&amp;nbsp;&lt;STRONG&gt;in-place, modifying the user data&lt;/STRONG&gt; in the matrix handle:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;                     |&amp;lt;r1&amp;gt;|&amp;lt;--r2--&amp;gt;|&amp;lt;---r3---&amp;gt;|
sortedCsrARowPtr   = [ 0  |  1     |  3       | 6 ] &amp;lt;- Always sorted by definition
sortedCsrAColInd   = [ 1  |  0  2  |  0  1  3 ]     &amp;lt;- Sorted
sortedCsrAValues   = [ c  |  a  e  |  b  d  f ]     &amp;lt;- Sorted, associated to colInd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2023 02:32:13 GMT</pubDate>
    <dc:creator>Gajanan_Choudhary</dc:creator>
    <dc:date>2023-09-08T02:32:13Z</dc:date>
    <item>
      <title>clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521592#M35064</link>
      <description>&lt;P&gt;Please clarify which value(s) are sorted by the function&amp;nbsp;&lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-1/oneapi-mkl-sparse-sort-matrix.html" target="_blank"&gt;https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-1/oneapi-mkl-sparse-sort-matrix.html&lt;/A&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 17:12:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521592#M35064</guid>
      <dc:creator>sycl-developer</dc:creator>
      <dc:date>2023-09-07T17:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521609#M35065</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The &lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-2/oneapi-mkl-sparse-sort-matrix.html" target="_self"&gt;oneapi::mkl::sparse::sort_matrix() documentation&lt;/A&gt;&amp;nbsp;says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;SPAN&gt;The&amp;nbsp;&lt;/SPAN&gt;oneapi::mkl::sparse::sort_matrix&lt;SPAN&gt;&amp;nbsp;API performs in-place sorting of user-provided sparse matrix arrays stored in a given sparse matrix handle.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;For CSR matrices that are currently the only supported matrix format, this means that it sorts the user-provided &lt;STRONG&gt;column indices&lt;/STRONG&gt; and &lt;STRONG&gt;values&lt;/STRONG&gt; arrays of the CSR matrix for &lt;STRONG&gt;each row&lt;/STRONG&gt; of the matrix. By "user-provided", we mean the user data stored in the matrix handle through the &lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-2/oneapi-mkl-sparse-set-csr-data.html" target="_self"&gt;oneapi::mkl::sparse::set_csr_data()&lt;/A&gt; API call.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gajanan&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 17:54:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521609#M35065</guid>
      <dc:creator>Gajanan_Choudhary</dc:creator>
      <dc:date>2023-09-07T17:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521621#M35066</link>
      <description>&lt;P&gt;To expand a little on Gajanan's great answer.&amp;nbsp; The user-provided data in the matrix handle is what is "sorted"; how it is sorted is based on the particular matrix format setup in the handle.&amp;nbsp; For instance, for CSR format, the colind and values arrays are sorted by smallest to largest column index subordinate to each row.&amp;nbsp; That is, it is essentially a batched sort function that sorts colind/value pairs on each "row" by colind values. Most sparse format have at least one "natural" concept of sortedness, with COO format having two that are "natural" (by column or by row). There are some which it is more difficult to define what is meant by sorted (think of an ELLPACK matrix where it is squished to the left, backfilled and then stored in a column major format -- sortedness is a "strided" kind of sorted in that case where it is again sorted on each row, even though the data is not stored contiguously on rows..) As different formats get added, we will try to be more specific in our documentation about what sort_matrix() means for that particular format :).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way, this is one of the few sparse blas functions that will modify user-provided data in the matrix handle and it's existence as an API is one of the reasons we don't have const properties on the provided matrix arrays in sparse::set_csr_data().&amp;nbsp; Our general policy is to not modify user-provided data in the matrix_handle unless the API being called explicitly says that it modifies it. &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Spencer&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 18:05:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521621#M35066</guid>
      <dc:creator>Spencer_P_Intel</dc:creator>
      <dc:date>2023-09-07T18:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521683#M35067</link>
      <description>&lt;P&gt;&lt;SPAN&gt;"It is essentially a batched sort function that sorts colind/value pairs on each "row" by colind value".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Then, is there an oneMKL function that sorts the values ?&amp;nbsp; I think the values can be sorted in cuSparse.&lt;/P&gt;&lt;P&gt;Thanks again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 21:03:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521683#M35067</guid>
      <dc:creator>sycl-developer</dc:creator>
      <dc:date>2023-09-07T21:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521692#M35070</link>
      <description>&lt;P&gt;no, there is no such onemkl sparse function that would sort based on values -- only sorting of matrix based on column indices.&amp;nbsp; You could look into onedpl for a general sort function (for instance&amp;nbsp;oneapi::dpl::sort_by_key) for an array or pair of arrays that could do this, but the batched part would be more of a challenge, since you are still wanting to sort within each row, right ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May I ask, what is the purpose of sorting a matrix by values?&amp;nbsp; In my mind, it is not a common thing to do for linear algebra or sparse algorithms, so I am curious to understand what it might be useful for &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Spencer&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 21:40:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521692#M35070</guid>
      <dc:creator>Spencer_P_Intel</dc:creator>
      <dc:date>2023-09-07T21:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521723#M35071</link>
      <description>&lt;P&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/96895"&gt;@Spencer_P_Intel&lt;/a&gt;&amp;nbsp;, I believe they meant sorting&amp;nbsp;&lt;EM&gt;the&lt;/EM&gt; values, not sorting&amp;nbsp;&lt;EM&gt;by&lt;/EM&gt; values:&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;SPAN&gt;is there an oneMKL function that sorts the values ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/282402"&gt;@sycl-developer&lt;/a&gt;, sort_matrix sorts both column indices and values together. The sorting happens by column indices for each row, and the values are associated to those column indices. In short, oneapi::mkl::sparse::sort_matrix() is the equivalent of &lt;A href="https://docs.nvidia.com/cuda/archive/12.2.1/cusparse/index.html#cusparsexcsrsort" target="_self"&gt;cusparseXcsrsort()&lt;/A&gt; function from cuSPARSE for CSR matrix format.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 00:42:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521723#M35071</guid>
      <dc:creator>Gajanan_Choudhary</dc:creator>
      <dc:date>2023-09-08T00:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521726#M35072</link>
      <description>&lt;P&gt;Thank you all for your answers and suggestions !&amp;nbsp; I thought the cusparseXcrsort() function sorts the values in a matrix by row. So a function equivalent to the CUDA function may be helpful. However,&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;Gajanan mentioned that "oneapi::mkl::sparse::sort_matrix() is the equivalent of cusparseXcsrsort()&amp;nbsp;function".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 01:11:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521726#M35072</guid>
      <dc:creator>sycl-developer</dc:creator>
      <dc:date>2023-09-08T01:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521744#M35073</link>
      <description>&lt;P&gt;For the sake of others landing here, allow me to add an example of what &lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-2/oneapi-mkl-sparse-sort-matrix.html" target="_self"&gt;oneapi::mkl::sort_matrix()&lt;/A&gt; does:&lt;/P&gt;&lt;P&gt;Consider a dense matrix with 6 non-zero values:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;         | 0  c  0  0 |
denseA = | a  0  e  0 |
         | b  d  0  f |&lt;/LI-CODE&gt;&lt;P&gt;Here's &lt;STRONG&gt;an&lt;/STRONG&gt; example of an unsorted CSR matrix representation of the above dense matrix in 0-based indexing:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;                     |&amp;lt;r1&amp;gt;|&amp;lt;--r2--&amp;gt;|&amp;lt;---r3---&amp;gt;|
sortedCsrARowPtr   = [ 0  |  1     |  3       | 6 ] &amp;lt;- Always sorted by definition
unsortedCsrAColInd = [ 1  |  2  0  |  3  0  1 ]     &amp;lt;- Unsorted
unsortedCsrAValues = [ c  |  e  a  |  f  b  d ]     &amp;lt;- Unsorted, associated to colInd&lt;/LI-CODE&gt;&lt;P&gt;Here's how the unique sorted representation of the above CSR matrix looks like, which is what &lt;A href="https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-2/oneapi-mkl-sparse-sort-matrix.html" target="_self"&gt;oneapi::mkl::sort_matrix()&lt;/A&gt; would give&amp;nbsp;&lt;STRONG&gt;in-place, modifying the user data&lt;/STRONG&gt; in the matrix handle:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;                     |&amp;lt;r1&amp;gt;|&amp;lt;--r2--&amp;gt;|&amp;lt;---r3---&amp;gt;|
sortedCsrARowPtr   = [ 0  |  1     |  3       | 6 ] &amp;lt;- Always sorted by definition
sortedCsrAColInd   = [ 1  |  0  2  |  0  1  3 ]     &amp;lt;- Sorted
sortedCsrAValues   = [ c  |  a  e  |  b  d  f ]     &amp;lt;- Sorted, associated to colInd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 02:32:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521744#M35073</guid>
      <dc:creator>Gajanan_Choudhary</dc:creator>
      <dc:date>2023-09-08T02:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521952#M35077</link>
      <description>&lt;P&gt;I copy and paste the CUDA function:&lt;/P&gt;&lt;P&gt;"This function sorts CSR format. The stable sorting is in-place.&lt;/P&gt;&lt;P&gt;The matrix type is regarded as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;CUSPARSE_MATRIX_TYPE_GENERAL&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;implicitly. In other words, any symmetric property is ignored.&lt;/P&gt;&lt;P&gt;This function&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrsort()&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;requires buffer size returned by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrsort_bufferSizeExt()&lt;/SPAN&gt;. The address of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;pBuffer&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;must be multiple of 128 bytes. If not,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;CUSPARSE_STATUS_INVALID_VALUE&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is returned.&lt;/P&gt;&lt;P&gt;The parameter&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;P&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is both input and output. If the user wants to compute sorted&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrVal&lt;/SPAN&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;P&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;must be set as 0:1:(nnz-1) before&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrsort()&lt;/SPAN&gt;, and after&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrsort()&lt;/SPAN&gt;, new sorted value array satisfies&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrVal_sorted&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;csrVal(P)&lt;/SPAN&gt;. "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 17:25:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1521952#M35077</guid>
      <dc:creator>sycl-developer</dc:creator>
      <dc:date>2023-09-08T17:25:24Z</dc:date>
    </item>
    <item>
      <title>Re:clarify mkl-sparse-sort</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1523751#M35123</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for posting in Intel Communities.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;gt;Thank you all for your answers and suggestions &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It's great to know that your issue is resolved, in case you run into any other issues please feel free to create a new thread.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Have a Good Day!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Varsha&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Sep 2023 14:51:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/clarify-mkl-sparse-sort/m-p/1523751#M35123</guid>
      <dc:creator>VarshaS_Intel</dc:creator>
      <dc:date>2023-09-14T14:51:52Z</dc:date>
    </item>
  </channel>
</rss>

