<?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 Adding a value to all double-vector items in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832879#M5775</link>
    <description>Please take a look at the IPP Library function ippiScale.&lt;BR /&gt;&lt;BR /&gt;For something so simple as performing a linear transformation, there is no need to call functions. In fact, the calculation that you described (or, taking for example the generation of a set of temperatures in Kelvin between the freezing and boiling points of water) can be performed in Fortran with the code&lt;BR /&gt;&lt;PRE&gt;[fortran]program scale&lt;BR /&gt;integer, parameter :: iVLen = 5000000&lt;BR /&gt;real, dimension (iVLen) :: dXValue, dPointX&lt;BR /&gt;real,volatile :: t0,t1,s&lt;BR /&gt;&lt;BR /&gt;call random_number(dXValue)&lt;BR /&gt;&lt;BR /&gt;call cpu_time(t0)&lt;BR /&gt;dPointX = 273.15 + 100.0*dXValue   ! linear transformation&lt;BR /&gt;call cpu_time(t1)&lt;BR /&gt;&lt;BR /&gt;s=sum(dPointX)/size(dPointX)&lt;BR /&gt;write(*,*)t1-t0,s&lt;BR /&gt;&lt;BR /&gt;end program scale&lt;BR /&gt;[/fortran]&lt;/PRE&gt; I put in the calculation of the mean of dPointX to prevent the optimizer from eliminating the entire calculation.&lt;BR /&gt;&lt;BR /&gt;An optimizing compiler can perform the core operation inline and with great efficiency. With the -xSSSE3 -O3 options, the Intel Fortran compiler converts the linear transformation into a loop with iVLen/8 repetitions, with each iteration of the loop producing 8 elements of the array.&lt;PRE&gt;[plain]..B1.7:                         # Preds ..B1.7 ..B1.6&lt;BR /&gt;        movaps    scale_$DXVALUE.0.1(,%rax,4), %xmm2            #8.1&lt;BR /&gt;        movaps    16+scale_$DXVALUE.0.1(,%rax,4), %xmm3         #8.1&lt;BR /&gt;        mulps     %xmm1, %xmm2                                  #8.25&lt;BR /&gt;        addps     %xmm0, %xmm2                                  #8.1&lt;BR /&gt;        movaps    %xmm2, scale_$DPOINTX.0.1(,%rax,4)            #8.1&lt;BR /&gt;        mulps     %xmm1, %xmm3                                  #8.25&lt;BR /&gt;        addps     %xmm0, %xmm3                                  #8.1&lt;BR /&gt;        movaps    %xmm3, 16+scale_$DPOINTX.0.1(,%rax,4)         #8.1&lt;BR /&gt;        addq      $8, %rax                                      #8.1&lt;BR /&gt;        cmpq      $500000, %rax                                 #8.1&lt;BR /&gt;        jb        ..B1.7        # Prob 99%                      #8.1&lt;BR /&gt;[/plain]&lt;/PRE&gt; You may attempt to do the equivalent in C++, or you may use the C interoperability features of Fortran 2003.</description>
    <pubDate>Mon, 30 Aug 2010 14:16:54 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2010-08-30T14:16:54Z</dc:date>
    <item>
      <title>Adding a value to all double-vector items</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832876#M5772</link>
      <description>Hi all, &lt;BR /&gt;&lt;BR /&gt;I'd like to convert hundreds ofmillions of data points as coordinates on screen, so I'll need to optimize the calculation. The formula is simple, for X coordinate transform:&lt;BR /&gt;&lt;BR /&gt;dPointX = dLeft + (dXValue - xAxisMin) * dXFactor, where dXValue is a series point X value. dLeft, xAxisMin and dXFactor are the same for all items. &lt;BR /&gt;&lt;BR /&gt;By using C#, &lt;BR /&gt;int iVectorLen = 500000; &lt;BR /&gt;double[] mklVector = new double[iVectorLen]; &lt;BR /&gt;for(int i=iVectorLen-1;i&amp;gt;=0;--i)&lt;BR /&gt; mklVector&lt;I&gt; = xSeriesPoints&lt;I&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then, I would like to do &lt;BR /&gt;AddToVectorValues(mklVector, iVectorLen, -xAxisMin);&lt;BR /&gt;MultiplyVectorValues(mklVector,iVectorLen,dXFactor); &lt;BR /&gt;AddToVectorValues(mklVector, iVectorLen, dLeft);&lt;BR /&gt;&lt;BR /&gt;Now, I found &lt;STRONG&gt;dscal&lt;/STRONG&gt;function, which works for MultiplyVectorValues purposejust fine. But, is there any function toapply the sum operation, for AddToVectorValues purpose? I really couldn't find one, and neither my more MKL-experienced associate. &lt;BR /&gt;&lt;BR /&gt;ByimplementingAddToVectorValues with a for-loop, it will take about ten times more CPU time than a dscal function call. &lt;BR /&gt;&lt;BR /&gt;Any suggestions? &lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Pasi Tuomainen&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Mon, 30 Aug 2010 07:33:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832876#M5772</guid>
      <dc:creator>Pasi_Tuomainen</dc:creator>
      <dc:date>2010-08-30T07:33:36Z</dc:date>
    </item>
    <item>
      <title>Adding a value to all double-vector items</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832877#M5773</link>
      <description>Please see at thedaxpy routine. You can try to use them.&lt;DIV&gt;--Gennady&lt;/DIV&gt;</description>
      <pubDate>Mon, 30 Aug 2010 08:04:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832877#M5773</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2010-08-30T08:04:29Z</dc:date>
    </item>
    <item>
      <title>Adding a value to all double-vector items</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832878#M5774</link>
      <description>Thanks, &lt;BR /&gt;&lt;BR /&gt;however, this doesn't seem to give any performance gain. I have to create a separate vector for dLeft values, and initialize it with dLeft valueswith a for loop... Or do you know a MKL routine for initializing a vector with same double-value for each item? &lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Pasi</description>
      <pubDate>Mon, 30 Aug 2010 08:54:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832878#M5774</guid>
      <dc:creator>Pasi_Tuomainen</dc:creator>
      <dc:date>2010-08-30T08:54:26Z</dc:date>
    </item>
    <item>
      <title>Adding a value to all double-vector items</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832879#M5775</link>
      <description>Please take a look at the IPP Library function ippiScale.&lt;BR /&gt;&lt;BR /&gt;For something so simple as performing a linear transformation, there is no need to call functions. In fact, the calculation that you described (or, taking for example the generation of a set of temperatures in Kelvin between the freezing and boiling points of water) can be performed in Fortran with the code&lt;BR /&gt;&lt;PRE&gt;[fortran]program scale&lt;BR /&gt;integer, parameter :: iVLen = 5000000&lt;BR /&gt;real, dimension (iVLen) :: dXValue, dPointX&lt;BR /&gt;real,volatile :: t0,t1,s&lt;BR /&gt;&lt;BR /&gt;call random_number(dXValue)&lt;BR /&gt;&lt;BR /&gt;call cpu_time(t0)&lt;BR /&gt;dPointX = 273.15 + 100.0*dXValue   ! linear transformation&lt;BR /&gt;call cpu_time(t1)&lt;BR /&gt;&lt;BR /&gt;s=sum(dPointX)/size(dPointX)&lt;BR /&gt;write(*,*)t1-t0,s&lt;BR /&gt;&lt;BR /&gt;end program scale&lt;BR /&gt;[/fortran]&lt;/PRE&gt; I put in the calculation of the mean of dPointX to prevent the optimizer from eliminating the entire calculation.&lt;BR /&gt;&lt;BR /&gt;An optimizing compiler can perform the core operation inline and with great efficiency. With the -xSSSE3 -O3 options, the Intel Fortran compiler converts the linear transformation into a loop with iVLen/8 repetitions, with each iteration of the loop producing 8 elements of the array.&lt;PRE&gt;[plain]..B1.7:                         # Preds ..B1.7 ..B1.6&lt;BR /&gt;        movaps    scale_$DXVALUE.0.1(,%rax,4), %xmm2            #8.1&lt;BR /&gt;        movaps    16+scale_$DXVALUE.0.1(,%rax,4), %xmm3         #8.1&lt;BR /&gt;        mulps     %xmm1, %xmm2                                  #8.25&lt;BR /&gt;        addps     %xmm0, %xmm2                                  #8.1&lt;BR /&gt;        movaps    %xmm2, scale_$DPOINTX.0.1(,%rax,4)            #8.1&lt;BR /&gt;        mulps     %xmm1, %xmm3                                  #8.25&lt;BR /&gt;        addps     %xmm0, %xmm3                                  #8.1&lt;BR /&gt;        movaps    %xmm3, 16+scale_$DPOINTX.0.1(,%rax,4)         #8.1&lt;BR /&gt;        addq      $8, %rax                                      #8.1&lt;BR /&gt;        cmpq      $500000, %rax                                 #8.1&lt;BR /&gt;        jb        ..B1.7        # Prob 99%                      #8.1&lt;BR /&gt;[/plain]&lt;/PRE&gt; You may attempt to do the equivalent in C++, or you may use the C interoperability features of Fortran 2003.</description>
      <pubDate>Mon, 30 Aug 2010 14:16:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Adding-a-value-to-all-double-vector-items/m-p/832879#M5775</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-08-30T14:16:54Z</dc:date>
    </item>
  </channel>
</rss>

