<?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 Looking for MKL FFT complementary functions  in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063625#M21808</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I migrated my DFT code from IPP to FFT code using MKL FFT functions, I'm looking forward for &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;performance&amp;nbsp;&lt;/SPAN&gt;improvement.&lt;/P&gt;

&lt;P&gt;1st, I want to do phase correlation in spectrum domain.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;In my algorithm I have 2 input images and the output is a correlation surface&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I do the following:&amp;nbsp;&lt;/P&gt;

&lt;P&gt;1. FFT both input images&amp;nbsp;&lt;/P&gt;

&lt;P&gt;2. for each element in the spatial domain, I'd like to multiply with complex conjugate, than normalize &amp;nbsp;each element:&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;2.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; (a1 + ib1) * (a2 - ib2)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;2.2 &amp;nbsp; &amp;nbsp; &amp;nbsp; (a + ib) / magnidute(a,b) &amp;nbsp;--&amp;gt; Z&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;3. inverse FFT Z&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I'm looking for&amp;nbsp;complementary functions &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;for FFT library&amp;nbsp;&lt;/SPAN&gt;that calculate a multiplication with complex &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;conjugate&lt;/SPAN&gt;, and function that calculate each element magnitude. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;I &lt;SPAN style="color: rgb(51, 51, 51); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"&gt;thought I'd be great to use:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT color="#333333" face="Helvetica Neue, Helvetica, Arial, sans-serif"&gt;&lt;SPAN style="font-size: 13px; line-height: 18px;"&gt;vcMulByConj&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT color="#333333" face="Helvetica Neue, Helvetica, Arial, sans-serif"&gt;&lt;SPAN style="font-size: 13px; line-height: 18px;"&gt;and&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;VCABS&amp;nbsp;&lt;/P&gt;

&lt;P&gt;functions that reside on "mkl_vml_functions.h"&amp;nbsp;&lt;/P&gt;

&lt;P&gt;However, here comes a problem of using MKL FFT memory model (DFTI_CONJUGATE_EVEN_STORAGE &amp;nbsp;in packed memory format ), I don't know how to access each element in the spatial domain, how to build the matrix back in packed format, and most important is how to make this thing work extremely&amp;nbsp;fast. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I'm looking for functions that already know how to work with packed format and execute such &lt;/SPAN&gt;functionality&amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;on packed format matrix,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Are there functions that gives such functionality?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Do I need to write this functionally by myself ? How to access each matrix element ?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;2nd, I'm also want to do FFT shift in the spatial domain by doing (-1)^(i+j) for each element. Is there a function that can do such thing (perhaps matrix pixel wise multiplication) ? Working with packed format.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;S&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>Sun, 17 Jul 2016 07:04:30 GMT</pubDate>
    <dc:creator>TripleS</dc:creator>
    <dc:date>2016-07-17T07:04:30Z</dc:date>
    <item>
      <title>Looking for MKL FFT complementary functions</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063625#M21808</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I migrated my DFT code from IPP to FFT code using MKL FFT functions, I'm looking forward for &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;performance&amp;nbsp;&lt;/SPAN&gt;improvement.&lt;/P&gt;

&lt;P&gt;1st, I want to do phase correlation in spectrum domain.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;In my algorithm I have 2 input images and the output is a correlation surface&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I do the following:&amp;nbsp;&lt;/P&gt;

&lt;P&gt;1. FFT both input images&amp;nbsp;&lt;/P&gt;

&lt;P&gt;2. for each element in the spatial domain, I'd like to multiply with complex conjugate, than normalize &amp;nbsp;each element:&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;2.1 &amp;nbsp; &amp;nbsp; &amp;nbsp; (a1 + ib1) * (a2 - ib2)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;2.2 &amp;nbsp; &amp;nbsp; &amp;nbsp; (a + ib) / magnidute(a,b) &amp;nbsp;--&amp;gt; Z&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;3. inverse FFT Z&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I'm looking for&amp;nbsp;complementary functions &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;for FFT library&amp;nbsp;&lt;/SPAN&gt;that calculate a multiplication with complex &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;conjugate&lt;/SPAN&gt;, and function that calculate each element magnitude. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;I &lt;SPAN style="color: rgb(51, 51, 51); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"&gt;thought I'd be great to use:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT color="#333333" face="Helvetica Neue, Helvetica, Arial, sans-serif"&gt;&lt;SPAN style="font-size: 13px; line-height: 18px;"&gt;vcMulByConj&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT color="#333333" face="Helvetica Neue, Helvetica, Arial, sans-serif"&gt;&lt;SPAN style="font-size: 13px; line-height: 18px;"&gt;and&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;VCABS&amp;nbsp;&lt;/P&gt;

&lt;P&gt;functions that reside on "mkl_vml_functions.h"&amp;nbsp;&lt;/P&gt;

&lt;P&gt;However, here comes a problem of using MKL FFT memory model (DFTI_CONJUGATE_EVEN_STORAGE &amp;nbsp;in packed memory format ), I don't know how to access each element in the spatial domain, how to build the matrix back in packed format, and most important is how to make this thing work extremely&amp;nbsp;fast. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I'm looking for functions that already know how to work with packed format and execute such &lt;/SPAN&gt;functionality&amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;on packed format matrix,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Are there functions that gives such functionality?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Do I need to write this functionally by myself ? How to access each matrix element ?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;2nd, I'm also want to do FFT shift in the spatial domain by doing (-1)^(i+j) for each element. Is there a function that can do such thing (perhaps matrix pixel wise multiplication) ? Working with packed format.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;S&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>Sun, 17 Jul 2016 07:04:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063625#M21808</guid>
      <dc:creator>TripleS</dc:creator>
      <dc:date>2016-07-17T07:04:30Z</dc:date>
    </item>
    <item>
      <title>Hi </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063626#M21809</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I guess, you are doing some convolution operation on Image, right? &amp;nbsp;The performance may depend on many factors, like your image size etc.&lt;/P&gt;

&lt;P&gt;1) About packed format&lt;/P&gt;

&lt;P&gt;If you do it with MKL FFT API. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Consolas, &amp;quot;Lucida Console&amp;quot;, Menlo, Monaco, &amp;quot;DejaVu Sans Mono&amp;quot;, monospace, sans-serif; font-size: 13.008px; line-height: 19.512px;"&gt;for example, if with DftiSetValue(h1,DFTI_CONJUGATE_EVEN_STORAGE,DFTI_COMPLEX_COMPLEX); you may don't need to take care of the packed model.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;If for the package format, you can refer to MKL manual in MKL documention (https://software.intel.com/en-us/articles/intel-math-kernel-library-documentation)&amp;nbsp; =&amp;gt; Section&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;DFTI_CCS_FORMAT for Two-dimensional Transforms&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;The following figure illustrates the storage of a two-dimensional (2D) M-by-N conjugate-even sequence in a&lt;BR /&gt;
	real array for the CCS packed format. This format requires an array of size (M+2)-by-(N+2). Row-major&lt;BR /&gt;
	layout and zero-based indexing are used. Different colors mark logically separate parts of the result. "n/u"&lt;BR /&gt;
	means "not used".&lt;BR /&gt;
	Storage of a 2D M-by-N Conjugate-even Sequence in a Real Array for the CCS Format&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;2) yes, you can use the function to do&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;(a + ib) / magnidute(a,b)&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;vcMulByConj&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;and&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;VCABS &amp;nbsp;or&amp;nbsp;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;v?LinearFrac&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;3)&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&amp;nbsp;FFT shift in the spatial domain by doing (-1)^(i+j) for each element. Is there a function that can do such thing (perhaps matrix pixel wise multiplication) ?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;yes, maybe matrix pixel wise multiplication by VML function, &amp;nbsp;or consider FFT&amp;nbsp;DFTI_FORWARD_SCALE, which allow you multiply some value to spatial.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Here is one use FFT for image reconstruction sample, for your reference.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&lt;A href="https://software.intel.com/en-us/node/507042" target="_blank"&gt;https://software.intel.com/en-us/node/507042&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Ying&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 05:53:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063626#M21809</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2016-07-18T05:53:10Z</dc:date>
    </item>
    <item>
      <title>Hey Ying </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063627#M21810</link>
      <description>&lt;P&gt;Hey Ying&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thank you for your reply&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I'd like to use:&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;DftiSetValue(h1,DFTI_CONJUGATE_EVEN_STORAGE,DFTI_COMPLEX_COMPLEX) &amp;nbsp;which don't take care of the packed memory format.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;I expected that the memory would save in conjugate even storage, which means for the number of elements in read and spatial domain the following:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;for Input size: sizeof(float) *&amp;nbsp;M * N &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;The output size would be : sizeof( complex float ) * M * ( N / 2 + 1 )&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Which is &lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;exactly&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;what am I trying to do, Please have a look at my following example, I'm trying to figure out what am I missing here.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;DftiComputeForward throws an exception. &lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;( Could be an output stride ? I thought the ouput stride should set by default to default parameters )&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&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;PRE class="brush:cpp;"&gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;mkl.h&amp;gt;
#include &amp;lt;mkl_dfti.h&amp;gt;
#include &amp;lt;mkl_cblas.h&amp;gt;

using namespace std;


static int Test()
{
	int m_nWorkingRows = 1024;
	int m_nWorkingCols = 1024;

	MKL_LONG mklStatus;
	DFTI_DESCRIPTOR_HANDLE handleDFTI_foward;

	MKL_LONG descSize[2] = { m_nWorkingRows, m_nWorkingCols };

	// Note: the output is DFTI_EVEN_STORAGE. store only the conjugate even domain by default, real data scope is d2 * d1, imaginary data scope is: d2 * (d1 / 2 + 1)
	mklStatus = DftiCreateDescriptor(&amp;amp;handleDFTI_foward, DFTI_SINGLE, DFTI_REAL, 2, descSize);
	if (mklStatus &amp;amp;&amp;amp; !DftiErrorClass(mklStatus, DFTI_NO_ERROR)) { /*printf("Error: %s\n", DftiErrorMessage(mklStatus));*/  return false; }

	mklStatus = DftiSetValue(handleDFTI_foward, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
	if (mklStatus &amp;amp;&amp;amp; !DftiErrorClass(mklStatus, DFTI_NO_ERROR)) { /*printf("Error: %s\n", DftiErrorMessage(mklStatus));*/  return false; }

	mklStatus = DftiSetValue(handleDFTI_foward, DFTI_CONJUGATE_EVEN_STORAGE, DFTI_COMPLEX_COMPLEX);
	if (mklStatus &amp;amp;&amp;amp; !DftiErrorClass(mklStatus, DFTI_NO_ERROR)) { /*printf("Error: %s\n", DftiErrorMessage(mklStatus));*/  return false; }

	mklStatus = DftiCommitDescriptor(handleDFTI_foward);
	if (mklStatus &amp;amp;&amp;amp; !DftiErrorClass(mklStatus, DFTI_NO_ERROR)) { /*printf("Error: %s\n", DftiErrorMessage(mklStatus));*/  return false; }


	
	//// 
	void* srcData = MKL_malloc(sizeof(float) * m_nWorkingRows * m_nWorkingCols, 64);
	void* dstData = MKL_malloc(sizeof(float) * 2 * m_nWorkingRows * (m_nWorkingCols / 2 + 1), 64);


	// THE FOLLOWING LINE THROWS AN EXCEPTION: Unhandled exception at 0x000007FEC9B7233C (mkl_mc3.dll) in xxxxx.exe: 0xC0000005: Access violation writing location 0x000000000B7BE080.
	mklStatus = DftiComputeForward(handleDFTI_foward, srcData, dstData);
	if (mklStatus &amp;amp;&amp;amp; !DftiErrorClass(mklStatus, DFTI_NO_ERROR)) { /*printf("Error: %s\n", DftiErrorMessage(mklStatus));*/  return false; }

	return true;
}
&lt;/PRE&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, 19 Jul 2016 08:53:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Looking-for-MKL-FFT-complementary-functions/m-p/1063627#M21810</guid>
      <dc:creator>TripleS</dc:creator>
      <dc:date>2016-07-19T08:53:15Z</dc:date>
    </item>
  </channel>
</rss>

