<?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 Using MKL arrays within objects in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800130#M2947</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Even if LAVector is dynamically allocated it is still programmer's responsibility to allocate memory for the m_elements (in the constructor). Am I correct?&lt;BR /&gt;&lt;BR /&gt;As Chao suggests you can allocate m_elements using mkl_alloc() and m_elements will be properly aligned. The class object itself can be allocated in any way you prefer.&lt;BR /&gt;&lt;BR /&gt;I hope that helps,&lt;BR /&gt;Regards,&lt;BR /&gt;Sergey</description>
    <pubDate>Fri, 24 Jun 2011 16:00:13 GMT</pubDate>
    <dc:creator>Sergey_M_Intel2</dc:creator>
    <dc:date>2011-06-24T16:00:13Z</dc:date>
    <item>
      <title>Using MKL arrays within objects</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800127#M2944</link>
      <description>I understand that the MKL operates better when arrays of values are 16 byte aligned. So for allocating simple arrays of values, it is best to use the mkl_malloc to ensure alignment. My question concerns array alignment when the array is a member of an encapsulating object in C++.&lt;BR /&gt;&lt;BR /&gt;So let's say I have the following object with a few private members&lt;BR /&gt;&lt;BR /&gt;class LAvector&lt;BR /&gt;{&lt;BR /&gt;/* Excluding constructors, member functions, etc. */&lt;BR /&gt;MKL_INT m_length;&lt;BR /&gt;double * m_elements;&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;If this LAvector object is dynamically allocated itself, isn't it true that the byte alignment of the m_elements array could be off (even if mkl_malloc was used to dynamically allocate the internal member m_elements)? Would I have to write an aligned new operator for this LAvector object?&lt;BR /&gt;&lt;BR /&gt;Also if the LAvector object is used as an element for an STL vector, etc, wouldn't I also need a special LAvector object allocator?&lt;BR /&gt;&lt;BR /&gt;Thanks for your time.</description>
      <pubDate>Thu, 23 Jun 2011 20:50:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800127#M2944</guid>
      <dc:creator>bstrouse</dc:creator>
      <dc:date>2011-06-23T20:50:18Z</dc:date>
    </item>
    <item>
      <title>Using MKL arrays within objects</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800128#M2945</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;Possibly you can have some clarification on the problem? My understanding that the class memory 'm_elements' is used by MKL function call, and it the memory is allocated by mkl_malloc (), the question is if the class still need to be allocated by mkl_malloc(), and make sure the address for the class is also aligned with 16 bytes? &lt;/P&gt;&lt;P&gt;If MKL function only use 'm_elements', it is not required that the class itself is aligned with 16 bytes, the alignment for 'm_elements' address will be fine. &lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Chao &lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2011 09:39:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800128#M2945</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2011-06-24T09:39:21Z</dc:date>
    </item>
    <item>
      <title>Using MKL arrays within objects</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800129#M2946</link>
      <description>Hi Chao,&lt;BR /&gt;&lt;BR /&gt;Thanks for the response.&lt;BR /&gt;&lt;BR /&gt;Yes, m_elements is the C style array that will be passed to the mkl functions. LAVector is a just a class wrapper around the array of data.&lt;BR /&gt;&lt;BR /&gt;I wasn't sure what happens to the alignment of the m_elements array if the LAVector class is defined dynamically. For example:&lt;BR /&gt;&lt;BR /&gt;vector1 = new LAVector(4);&lt;BR /&gt;&lt;BR /&gt;Since m_elements is a member of LAVector, I wanted to be sure that the allocation of LAVector didn't cause m_elements member to be off on its byte alignment. I also wanted to be sure that m_elements isn't off of alignment if the following happens:&lt;BR /&gt;&lt;BR /&gt;std::vector&lt;LAVECTOR&gt; vectorOfVectors;&lt;BR /&gt;LAVector vector2(1);&lt;BR /&gt;vectorOfVectors.push_back(vector2); &lt;BR /&gt;&lt;BR /&gt;The reason being here that the LAVector is being allocated by std::vector's default allocator when it's placed into the vector.&lt;BR /&gt;&lt;BR /&gt;Please confirm that the byte alignment of m_elements would be ok in these two situations.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/LAVECTOR&gt;</description>
      <pubDate>Fri, 24 Jun 2011 15:42:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800129#M2946</guid>
      <dc:creator>bstrouse</dc:creator>
      <dc:date>2011-06-24T15:42:46Z</dc:date>
    </item>
    <item>
      <title>Using MKL arrays within objects</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800130#M2947</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Even if LAVector is dynamically allocated it is still programmer's responsibility to allocate memory for the m_elements (in the constructor). Am I correct?&lt;BR /&gt;&lt;BR /&gt;As Chao suggests you can allocate m_elements using mkl_alloc() and m_elements will be properly aligned. The class object itself can be allocated in any way you prefer.&lt;BR /&gt;&lt;BR /&gt;I hope that helps,&lt;BR /&gt;Regards,&lt;BR /&gt;Sergey</description>
      <pubDate>Fri, 24 Jun 2011 16:00:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800130#M2947</guid>
      <dc:creator>Sergey_M_Intel2</dc:creator>
      <dc:date>2011-06-24T16:00:13Z</dc:date>
    </item>
    <item>
      <title>Using MKL arrays within objects</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800131#M2948</link>
      <description>Sergey,&lt;BR /&gt;&lt;BR /&gt;You are correct. It doesn't matter if the LAVector object is statically or dynamically allocated, regardless the m_elements member must have its array elements dynamically allocated during construction.&lt;BR /&gt;&lt;BR /&gt;I think this answers my question.&lt;BR /&gt;&lt;BR /&gt;Thanks guys.</description>
      <pubDate>Fri, 24 Jun 2011 16:29:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-arrays-within-objects/m-p/800131#M2948</guid>
      <dc:creator>bstrouse</dc:creator>
      <dc:date>2011-06-24T16:29:35Z</dc:date>
    </item>
  </channel>
</rss>

