<?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/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117572#M24729</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Could you please tell some information like&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;How the matrix is stored? in continuous way or not. &amp;nbsp;and what is the matrix's size ? &lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Your OS and cpu processor etc, Intel fortran compiler &amp;nbsp;? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;do you use threaded MKL (mkl_intel_thread.x) or sequential MKL (mkl_sequential)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;In generally, the continuous matrix in Fortran should be same as vector, &amp;nbsp;so you can use the MKL dot of vector. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;And the MKL dot are threaded. it may run in parallel in multi-core machine.&amp;nbsp;&lt;/P&gt;

&lt;P style="font-size: 13.008px; line-height: 19.512px;"&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Threaded BLAS Level1 and Level2 Routines&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="font-size: 13.008px; line-height: 19.512px;"&gt;In the following list, ? stands for a precision prefix of each flavor of the respective routine and may have the&lt;BR /&gt;
	value of s, d, c, or z.&lt;BR /&gt;
	The following routines are threaded with OpenMP* for Intel® Core™2 Duo and Intel® Core™ i7 processors:&lt;BR /&gt;
	• Level1 BLAS:&lt;BR /&gt;
	?axpy, ?copy, ?swap, ddot/sdot, cdotc, drot/srot&lt;BR /&gt;
	• Level2 BLAS:&lt;BR /&gt;
	?gemv, ?trmv, dsyr/ssyr, dsyr2/ssyr2, dsymv/ssymv&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Regarding &amp;nbsp;"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;directly calculate the element-by-element product of the two matrix, and then sum up all the elements of resulting product matrix using the "sum subroutine". so are they two loops to &amp;nbsp;element-by-element product with Intel Fotran compiler &amp;nbsp;, then &amp;nbsp;sum function? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Considering Intel Fotran compiler can optimize such loop code, &amp;nbsp;like &amp;nbsp;Some fortran routine or Array notation&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://software.intel.com/en-us/articles/explicit-vector-programming-in-fortran,&amp;nbsp;" target="_blank"&gt;https://software.intel.com/en-us/articles/explicit-vector-programming-in-fortran,&amp;nbsp;&lt;/A&gt;;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt; &amp;nbsp;whatever your matrix looks like, you may compare two implementation and select &amp;nbsp;the better performance.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying H.&lt;/P&gt;

&lt;P&gt;Intel MKL Support&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2016 01:58:25 GMT</pubDate>
    <dc:creator>Ying_H_Intel</dc:creator>
    <dc:date>2016-03-21T01:58:25Z</dc:date>
    <item>
      <title>Is there a more efficient way for element-by-element multiplication for matrix?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117571#M24728</link>
      <description>&lt;P&gt;Hi, everyone.&lt;BR /&gt;
	&lt;BR /&gt;
	I was writing some FORTRAN codes for computing the &lt;STRONG&gt;DOT of two matrix&lt;/STRONG&gt; which idea is as same as dot of vectors. Firstly, it calculates the element-wise product of the two matrix. Secondly, it calculates the sum of all the elements of the matrix returned in the first-step calculation. So&amp;nbsp;I thought about two ways that would help.&amp;nbsp;&lt;BR /&gt;
	&lt;BR /&gt;
	In the first way, I will transfer the two matrix to respective vectors. And then, I can use the "&lt;STRONG&gt;dot subroutine&amp;nbsp;of vectors&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;" in BLAS(MKL) directly. Considering some specific problems, I prefer matrix calculation to vector calculation. In the second and prefered way, I directly calculate the element-by-element product of the two matrix, and then sum up all the elements of resulting product matrix using the "sum subroutine".&lt;BR /&gt;
	&lt;BR /&gt;
	However,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I doubt if the two alternative solutions is most efficient, since the matrix are extremly large.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 12:29:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117571#M24728</guid>
      <dc:creator>Lewis__Rubin</dc:creator>
      <dc:date>2016-03-19T12:29:12Z</dc:date>
    </item>
    <item>
      <title>Hi, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117572#M24729</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Could you please tell some information like&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;How the matrix is stored? in continuous way or not. &amp;nbsp;and what is the matrix's size ? &lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Your OS and cpu processor etc, Intel fortran compiler &amp;nbsp;? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;do you use threaded MKL (mkl_intel_thread.x) or sequential MKL (mkl_sequential)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;In generally, the continuous matrix in Fortran should be same as vector, &amp;nbsp;so you can use the MKL dot of vector. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;And the MKL dot are threaded. it may run in parallel in multi-core machine.&amp;nbsp;&lt;/P&gt;

&lt;P style="font-size: 13.008px; line-height: 19.512px;"&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Threaded BLAS Level1 and Level2 Routines&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="font-size: 13.008px; line-height: 19.512px;"&gt;In the following list, ? stands for a precision prefix of each flavor of the respective routine and may have the&lt;BR /&gt;
	value of s, d, c, or z.&lt;BR /&gt;
	The following routines are threaded with OpenMP* for Intel® Core™2 Duo and Intel® Core™ i7 processors:&lt;BR /&gt;
	• Level1 BLAS:&lt;BR /&gt;
	?axpy, ?copy, ?swap, ddot/sdot, cdotc, drot/srot&lt;BR /&gt;
	• Level2 BLAS:&lt;BR /&gt;
	?gemv, ?trmv, dsyr/ssyr, dsyr2/ssyr2, dsymv/ssymv&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Regarding &amp;nbsp;"&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;directly calculate the element-by-element product of the two matrix, and then sum up all the elements of resulting product matrix using the "sum subroutine". so are they two loops to &amp;nbsp;element-by-element product with Intel Fotran compiler &amp;nbsp;, then &amp;nbsp;sum function? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Considering Intel Fotran compiler can optimize such loop code, &amp;nbsp;like &amp;nbsp;Some fortran routine or Array notation&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://software.intel.com/en-us/articles/explicit-vector-programming-in-fortran,&amp;nbsp;" target="_blank"&gt;https://software.intel.com/en-us/articles/explicit-vector-programming-in-fortran,&amp;nbsp;&lt;/A&gt;;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt; &amp;nbsp;whatever your matrix looks like, you may compare two implementation and select &amp;nbsp;the better performance.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying H.&lt;/P&gt;

&lt;P&gt;Intel MKL Support&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 01:58:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117572#M24729</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2016-03-21T01:58:25Z</dc:date>
    </item>
    <item>
      <title>Hi, Ying.</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117573#M24730</link>
      <description>&lt;P&gt;Hi, Ying.&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks for your suggetions an very sorry for the late response.&lt;BR /&gt;
	&lt;BR /&gt;
	Here is my supplementary information acording to your request.&lt;BR /&gt;
	&lt;BR /&gt;
	Most of the matrices &amp;nbsp;are stored in a discontious way. And the matrix's size might be up to, for example, 100*100*80, such as &lt;STRONG&gt;REAL(8) :: A(100,100,80)&lt;/STRONG&gt;. So does that mean the optimization for the loop won't work?&amp;nbsp;&lt;BR /&gt;
	&lt;BR /&gt;
	At present I only consider &lt;STRONG&gt;the&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&lt;STRONG&gt;sequential MKL&lt;/STRONG&gt;. But in the future i might have to use the parallel MKL in case of the low efficiency.&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;BR /&gt;
	My program will run in Windows OS. And I built it with &amp;nbsp;&lt;STRONG style="box-sizing: border-box; color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 14px; line-height: 21px;"&gt;Intel® Parallel Studio XE Cluster Edition for students.(&amp;nbsp;&lt;A href="https://software.intel.com/en-us/qualify-for-free-software/student"&gt;https://software.intel.com/en-us/qualify-for-free-software/student&lt;/A&gt;&amp;nbsp;).&lt;/STRONG&gt;&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;STRONG style="box-sizing: border-box; color: rgb(102, 102, 102); font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 14px; line-height: 21px;"&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;
	Many thanks in advance.&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;FONT color="#666666" face="Arial, Tahoma, Helvetica, sans-serif"&gt;&lt;SPAN style="font-size: 14px; line-height: 21px;"&gt;&lt;B&gt;&amp;nbsp;&lt;/B&gt;Rubin.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 02:57:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117573#M24730</guid>
      <dc:creator>Lewis__Rubin</dc:creator>
      <dc:date>2016-03-30T02:57:21Z</dc:date>
    </item>
    <item>
      <title>Hi Rubin,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117574#M24731</link>
      <description>&lt;P&gt;Hi Rubin,&lt;/P&gt;

&lt;P&gt;Thank you&amp;nbsp;for the information.&amp;nbsp; as you understand,&amp;nbsp; you may want to do&amp;nbsp;bunch of &amp;nbsp;&amp;nbsp;&lt;STRONG&gt;REAL(8) :: AI(100,100,80) ,&amp;nbsp; REAL(8) :: BI(100,100,80)&amp;nbsp;&amp;nbsp; sum(&amp;nbsp;AI*.BI), right? &lt;/STRONG&gt;&amp;nbsp;Then I may suggest you try some MKL function(example) in MKL install directory, for example,&lt;/P&gt;

&lt;P&gt;ddotx.f&lt;/P&gt;

&lt;P&gt;ddot(100x100x80, A1(:,:,:), 1, B1(:,:,:), 1)&lt;/P&gt;

&lt;P&gt;and if these operation are batched, you can consider combine&amp;nbsp; these matrix to do&lt;/P&gt;

&lt;P&gt;one dgemm&lt;/P&gt;

&lt;P&gt;or&amp;nbsp; batched dgemm.&lt;/P&gt;

&lt;P&gt;dgemm_batchx.f&lt;/P&gt;

&lt;P&gt;etc.&lt;/P&gt;

&lt;P&gt;the optimization for the loop can work.&amp;nbsp; and &lt;STRONG&gt;&amp;nbsp; both sequential MKL and &lt;/STRONG&gt;&amp;nbsp;parallel MKL&amp;nbsp; can work also.&amp;nbsp; If you work on multi-core cpu, the parallel MKL may have better efficiency.&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 08:21:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117574#M24731</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2016-03-30T08:21:26Z</dc:date>
    </item>
    <item>
      <title>Ying,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117575#M24732</link>
      <description>&lt;P&gt;Ying,&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks. I will try this:&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&lt;STRONG&gt;ddot(100x100x80, A1(:,:,:), 1, B1(:,:,:), 1)&lt;/STRONG&gt;.&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;BR /&gt;
	Rubin.&lt;/SPAN&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 23:58:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Is-there-a-more-efficient-way-for-element-by-element/m-p/1117575#M24732</guid>
      <dc:creator>Lewis__Rubin</dc:creator>
      <dc:date>2016-03-30T23:58:50Z</dc:date>
    </item>
  </channel>
</rss>

