<?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 projection operation in MKL in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/projection-operation-in-MKL/m-p/1013374#M19330</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;For a projection operation, I should implement&lt;/P&gt;

&lt;P&gt;F = ( I - Mf*Vfr*Vfr^T ) * F&lt;/P&gt;

&lt;P&gt;where&lt;/P&gt;

&lt;P&gt;Mf is a sparse matrix of size sz_fXsz_f&lt;/P&gt;

&lt;P&gt;Vfr is a vector of sz_fX1&lt;/P&gt;

&lt;P&gt;F is a block of vectors of size sz_fXP, and stored as tfBlock2 in the code. tfBlock3 is also used to store intermediate results.&lt;/P&gt;

&lt;P&gt;How I implemented this is to, in some steps,&amp;nbsp; namely,&lt;/P&gt;

&lt;P&gt;1.) compute Vfr^T*F by using dgemm and store the result in r_dummy2, direct code&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;transa = 't'
transb = 'n'
a = 1.0_dbl
b = 0.0_dbl
r_dummy2 = 0.0_dbl
call dgemm( transa, transb, 1, P, &amp;amp;
     sz_f, a, vfr_r, &amp;amp;
     sz_f, tfBlock2, sz_f, b, r_dummy2, sz_f)&lt;/PRE&gt;

&lt;P&gt;2.) from previous operations I stored the matrix vector multiplication, Mf*Vfr so I am re-using that here&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;transa = 'n'
call dgemm( transa,transb, sz_f, P, 1,&amp;amp;
        a, Mfvfr_r,&amp;amp;
        sz_f, r_dummy2, P, b, tfBlock3, sz_f)&lt;/PRE&gt;

&lt;P&gt;3.) do the block subtraction with a simple loop( I can also use blas 3 level routines with a identity matrix of PXP for this I guess.)&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;v_scalar = -1.0_dbl
do k=1,P
   call daxpy(sz_f,v_scalar,tfBlock3(:,k),&amp;amp;
        incx,tfBlock2(:,k),incy)
end do&lt;/PRE&gt;

&lt;P&gt;However I ran into some problems, I checked the code and up to this point the results are more or less the same with MATLAB, for instance before performing this step, the norms of the columns of F(as given above) are almost the same, the relative error between MATLAB and MKL is on the order to 1e-13.&lt;/P&gt;

&lt;P&gt;However, after this projection the norms start to differ. A sample output is given below for the norms of the columns of the resulting matrix block F,&lt;/P&gt;

&lt;P&gt;MATLAB, for a block size of 3&lt;/P&gt;

&lt;P&gt;col1 9.9209570763674840e-05&lt;BR /&gt;
	col2 6.5649761997653081e-05&lt;BR /&gt;
	col3 4.2422350151641556e-05&lt;/P&gt;

&lt;P&gt;Fortran code with MKL with the same block size&lt;/P&gt;

&lt;P&gt;col1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.9300288425328761E-05&lt;BR /&gt;
	col2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.6337064666627222E-05&lt;BR /&gt;
	col3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.2422353749207066E-05&lt;/P&gt;

&lt;P&gt;with the least error on the last vector and %1 error on the second vector norm. Can someone shed some light on the above points and provide me with pointers on what could be going wrong? Any help is appreciated greatly.&lt;/P&gt;

&lt;P&gt;My compiler options are given as&lt;/P&gt;

&lt;P&gt;FC = ifort -ipo -unroll -fp-model strict -fp-stack-check -check all -fpe0 \&lt;BR /&gt;
	-traceback -ftrapuv -O2 -prec-div -prec-sqrt -debug all -fp-speculation=off&lt;/P&gt;

&lt;P&gt;Best regards,&lt;/P&gt;

&lt;P&gt;Umut&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 May 2014 17:04:10 GMT</pubDate>
    <dc:creator>utab</dc:creator>
    <dc:date>2014-05-13T17:04:10Z</dc:date>
    <item>
      <title>projection operation in MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/projection-operation-in-MKL/m-p/1013374#M19330</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;For a projection operation, I should implement&lt;/P&gt;

&lt;P&gt;F = ( I - Mf*Vfr*Vfr^T ) * F&lt;/P&gt;

&lt;P&gt;where&lt;/P&gt;

&lt;P&gt;Mf is a sparse matrix of size sz_fXsz_f&lt;/P&gt;

&lt;P&gt;Vfr is a vector of sz_fX1&lt;/P&gt;

&lt;P&gt;F is a block of vectors of size sz_fXP, and stored as tfBlock2 in the code. tfBlock3 is also used to store intermediate results.&lt;/P&gt;

&lt;P&gt;How I implemented this is to, in some steps,&amp;nbsp; namely,&lt;/P&gt;

&lt;P&gt;1.) compute Vfr^T*F by using dgemm and store the result in r_dummy2, direct code&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;transa = 't'
transb = 'n'
a = 1.0_dbl
b = 0.0_dbl
r_dummy2 = 0.0_dbl
call dgemm( transa, transb, 1, P, &amp;amp;
     sz_f, a, vfr_r, &amp;amp;
     sz_f, tfBlock2, sz_f, b, r_dummy2, sz_f)&lt;/PRE&gt;

&lt;P&gt;2.) from previous operations I stored the matrix vector multiplication, Mf*Vfr so I am re-using that here&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;transa = 'n'
call dgemm( transa,transb, sz_f, P, 1,&amp;amp;
        a, Mfvfr_r,&amp;amp;
        sz_f, r_dummy2, P, b, tfBlock3, sz_f)&lt;/PRE&gt;

&lt;P&gt;3.) do the block subtraction with a simple loop( I can also use blas 3 level routines with a identity matrix of PXP for this I guess.)&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;v_scalar = -1.0_dbl
do k=1,P
   call daxpy(sz_f,v_scalar,tfBlock3(:,k),&amp;amp;
        incx,tfBlock2(:,k),incy)
end do&lt;/PRE&gt;

&lt;P&gt;However I ran into some problems, I checked the code and up to this point the results are more or less the same with MATLAB, for instance before performing this step, the norms of the columns of F(as given above) are almost the same, the relative error between MATLAB and MKL is on the order to 1e-13.&lt;/P&gt;

&lt;P&gt;However, after this projection the norms start to differ. A sample output is given below for the norms of the columns of the resulting matrix block F,&lt;/P&gt;

&lt;P&gt;MATLAB, for a block size of 3&lt;/P&gt;

&lt;P&gt;col1 9.9209570763674840e-05&lt;BR /&gt;
	col2 6.5649761997653081e-05&lt;BR /&gt;
	col3 4.2422350151641556e-05&lt;/P&gt;

&lt;P&gt;Fortran code with MKL with the same block size&lt;/P&gt;

&lt;P&gt;col1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.9300288425328761E-05&lt;BR /&gt;
	col2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.6337064666627222E-05&lt;BR /&gt;
	col3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.2422353749207066E-05&lt;/P&gt;

&lt;P&gt;with the least error on the last vector and %1 error on the second vector norm. Can someone shed some light on the above points and provide me with pointers on what could be going wrong? Any help is appreciated greatly.&lt;/P&gt;

&lt;P&gt;My compiler options are given as&lt;/P&gt;

&lt;P&gt;FC = ifort -ipo -unroll -fp-model strict -fp-stack-check -check all -fpe0 \&lt;BR /&gt;
	-traceback -ftrapuv -O2 -prec-div -prec-sqrt -debug all -fp-speculation=off&lt;/P&gt;

&lt;P&gt;Best regards,&lt;/P&gt;

&lt;P&gt;Umut&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2014 17:04:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/projection-operation-in-MKL/m-p/1013374#M19330</guid>
      <dc:creator>utab</dc:creator>
      <dc:date>2014-05-13T17:04:10Z</dc:date>
    </item>
    <item>
      <title>Do you use the same computing</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/projection-operation-in-MKL/m-p/1013375#M19331</link>
      <description>&lt;P&gt;Do you use the same computing sequence in MATLAB and MKL?&lt;/P&gt;

&lt;P&gt;Can you attach the data that you feed to daxpy, namely the arrays tfBlock2 and tfBlock3, as well as the value of sz_f, P, incx, incy, etc.?&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2014 18:46:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/projection-operation-in-MKL/m-p/1013375#M19331</guid>
      <dc:creator>Zhang_Z_Intel</dc:creator>
      <dc:date>2014-05-13T18:46:06Z</dc:date>
    </item>
  </channel>
</rss>

