<?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: A fairly trivial question in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/A-fairly-trivial-question/m-p/864574#M7759</link>
    <description>&lt;P&gt;In most cases the following example will be faster:&lt;/P&gt;
&lt;P&gt; for ( i=0 ; i &amp;lt; n; i++ )&lt;BR /&gt; {&lt;BR /&gt;sumOfSquares += a&lt;I&gt;*a&lt;I&gt;;&lt;BR /&gt; }&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;If your compiler will not be able to vectorise this code, then the following code might be faster then the previous example (but accuracy will suffer):&lt;/P&gt;
&lt;P&gt; sumOfSquares = snrm2(&amp;amp;n, a, &amp;amp;incx );&lt;BR /&gt; sumOfSquares *= sumOfSquares;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jul 2008 13:45:03 GMT</pubDate>
    <dc:creator>Ilya_B_Intel</dc:creator>
    <dc:date>2008-07-02T13:45:03Z</dc:date>
    <item>
      <title>A fairly trivial question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/A-fairly-trivial-question/m-p/864573#M7758</link>
      <description>&lt;P&gt;&lt;FONT face="Verdana" size="2"&gt;A seemingly trivial question really.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Verdana" size="2"&gt;I am trying to calculate the sum of squares or a vector of single precision values whilst maximizing performance and minimizing the accumulated error typically found in summing floats.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Verdana" size="2"&gt;Currently I am using a method like the following:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;---------8&amp;lt;---------&lt;BR /&gt;&lt;FONT color="#008000"&gt;// Use vspowx to square the values in a vector&lt;BR /&gt;&lt;/FONT&gt;vspowx(n, a, 2, y);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#008000"&gt;// Sum the values in a loop&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;float&lt;/FONT&gt; sumOfSquares();&lt;BR /&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT color="#0000ff"&gt;for&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ( &lt;FONT color="#0000ff"&gt;int&lt;/FONT&gt; i(); i &amp;lt; n; i++ ){&lt;BR /&gt; sumOfSquares += y&lt;I&gt;;&lt;BR /&gt; }&lt;BR /&gt;---------8&amp;lt;---------&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Verdana" size="2"&gt;Can anyone think ofa faster and/or more accurate MKL way of summing a vector of floats (in this case absolute values) without casting to doubles ?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2008 13:12:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/A-fairly-trivial-question/m-p/864573#M7758</guid>
      <dc:creator>Deleted_U_Intel</dc:creator>
      <dc:date>2008-07-02T13:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: A fairly trivial question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/A-fairly-trivial-question/m-p/864574#M7759</link>
      <description>&lt;P&gt;In most cases the following example will be faster:&lt;/P&gt;
&lt;P&gt; for ( i=0 ; i &amp;lt; n; i++ )&lt;BR /&gt; {&lt;BR /&gt;sumOfSquares += a&lt;I&gt;*a&lt;I&gt;;&lt;BR /&gt; }&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;If your compiler will not be able to vectorise this code, then the following code might be faster then the previous example (but accuracy will suffer):&lt;/P&gt;
&lt;P&gt; sumOfSquares = snrm2(&amp;amp;n, a, &amp;amp;incx );&lt;BR /&gt; sumOfSquares *= sumOfSquares;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2008 13:45:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/A-fairly-trivial-question/m-p/864574#M7759</guid>
      <dc:creator>Ilya_B_Intel</dc:creator>
      <dc:date>2008-07-02T13:45:03Z</dc:date>
    </item>
  </channel>
</rss>

