<?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: malloc_device a 2D array in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308100#M1503</link>
    <description>&lt;P&gt;Hello Noorjahan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for my late reply. I was traveling!&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt; The one which i have referred in previous response is page no. of pdf. Apologies for any confusion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The page number is not still clear to me. Could you please repeat that? Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than that. The resources are helpful. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Leila&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Aug 2021 13:49:10 GMT</pubDate>
    <dc:creator>leilag</dc:creator>
    <dc:date>2021-08-19T13:49:10Z</dc:date>
    <item>
      <title>malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1298936#M1418</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is mainly a follow-up on&amp;nbsp;&lt;A href="https://community.intel.com/t5/Intel-oneAPI-Data-Parallel-C/2D-array-on-GPU-with-USM/m-p/1298020/highlight/true#M1407" target="_self"&gt;my previous issue&lt;/A&gt;&amp;nbsp;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/153633"&gt;@NoorjahanSk_Intel&lt;/a&gt;&amp;nbsp;recommended creating a 1D pointer and iterating through "&lt;SPAN&gt;row*array_width+column". But the point in creating those three row arrays was to treat each of those rows separately. Basically, like the previous example, we would loop over all of the indices in a row in one kernel and we loop over the elements of other rows in different kernels. This means that if I want to create a 1D array instead of my current 2D arrays, I would need to pass the whole array to a kernel and define the range such that it contains certain elements of the array (i.e. one third of the array). I haven't seen any examples or functionalities in DPC++ that can define a range which is a sub-array of the original array (or even with a specific stride). Am I missing some concepts in DPC++ or is this kind of functionality not supported by DPC++ yet?&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;I tried &lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/153633"&gt;@NoorjahanSk_Intel&lt;/a&gt;&amp;nbsp;'s solution and it did work using "malloc_shared" but this isn't my ultimate goal. I was hoping to be able to manage memory explicitly and allocating memory on the device but the code crashes running on intel's gpus with segmentation fault. Here is the code:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;LI-CODE lang="markup"&gt;#include &amp;lt;CL/sycl.hpp&amp;gt;
#include &amp;lt;array&amp;gt;
#include &amp;lt;iostream&amp;gt;
#if FPGA || FPGA_EMULATOR
#include &amp;lt;CL/sycl/INTEL/fpga_extensions.hpp&amp;gt;
#endif

using namespace sycl;

#define M 4
#define N 5
#define M_LEN (M + 2)
#define N_LEN (N + 2)
constexpr size_t  DOMAIN_SIZE = M_LEN*N_LEN;
#define DIM 1

int main() {
    auto R = range&amp;lt;1&amp;gt;{DOMAIN_SIZE};
    default_selector d_selector;
    queue q(d_selector);

    int **u = malloc_device&amp;lt;int *&amp;gt;(DOMAIN_SIZE, q);
    int **v = malloc_device&amp;lt;int *&amp;gt;(DOMAIN_SIZE, q);
    int **p = malloc_device&amp;lt;int *&amp;gt;(DOMAIN_SIZE, q);
    for(int i=0;i&amp;lt;3;i++) {
            u[i] = malloc_device&amp;lt;int&amp;gt;(DOMAIN_SIZE, q);
            v[i] = malloc_device&amp;lt;int&amp;gt;(DOMAIN_SIZE, q);
            p[i] = malloc_device&amp;lt;int&amp;gt;(DOMAIN_SIZE, q);
    }
   free(u,q);
   free(v,q);
   free(p,q);
   return 0;
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Am I doing something wrong or is this kind of memory allocation not supported on the device?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Leila&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 20:49:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1298936#M1418</guid>
      <dc:creator>leilag</dc:creator>
      <dc:date>2021-07-15T20:49:45Z</dc:date>
    </item>
    <item>
      <title>Re:malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1299183#M1422</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for Reaching out to us.&lt;/P&gt;&lt;P&gt;&amp;nbsp;1)To pass a sub-array of original array we can try using explicit memory operations which is a action part in command group handler.&lt;/P&gt;&lt;P&gt;In this operation we have an action that copies data between different indexes.&lt;/P&gt;&lt;P&gt;Please refer textbook DataPrallel C++ textbook by James Reinders page no:80.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;2)&amp;gt;&amp;gt;&lt;I&gt;segmentation fault&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;If we use malloc_device()allocation type ,it allocates memory on device which is not accessible on host. If we want to move data from device to host and vice-versa we should use memcpy() operation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;We can use memset function for malloc_device() allocation type. This function is used to initialize the memory.Instead of using for loop on host we can use memset as it works in parallel way.&lt;/P&gt;&lt;P&gt;We can also achieve this through writing kernels to fill the memory.&lt;/P&gt;&lt;P&gt;Please refer textbook DataPrallel C++ textbook by James Reinders page no:184.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Noorjahan.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jul 2021 13:21:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1299183#M1422</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2021-07-16T13:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1300032#M1426</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/153633"&gt;@NoorjahanSk_Intel&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your reply.&lt;/P&gt;
&lt;P&gt;I need to spend some more time to go through the book and understand your response.&lt;/P&gt;
&lt;P&gt;I am writing to request you to keep this thread open until I am done with some of the deadlines in the next couple of weeks. I would like to follow up on this topic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Leila&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 16:07:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1300032#M1426</guid>
      <dc:creator>leilag</dc:creator>
      <dc:date>2021-07-20T16:07:52Z</dc:date>
    </item>
    <item>
      <title>Re:malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1303287#M1449</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Reminder:&lt;/P&gt;&lt;P&gt; Could you please let us know whether you have any issues related to the information provided above. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Noorjahan&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Aug 2021 12:18:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1303287#M1449</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2021-08-03T12:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1303979#M1459</link>
      <description>&lt;P&gt;Hello Noorjahan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your followup.&lt;/P&gt;
&lt;P&gt;I did look into those pages from the book but I saw examples of the buffer model. I couldn't quite understand what you meant. Are there any sources with examples for the USM model that I could look at.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I just realized that I could check out the SYCL tutorials/sources as well to learn about DPC++! Would you recommend any sources in that direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Leila&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 14:03:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1303979#M1459</guid>
      <dc:creator>leilag</dc:creator>
      <dc:date>2021-08-05T14:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1306216#M1481</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&lt;I&gt;Are there any sources with examples for the USM model that I could look at.&lt;/I&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one which i have referred in previous response is page no. of pdf. Apologies for any confusion.&lt;/P&gt;
&lt;P&gt;You can find below page numbers of textbook&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer textbook DataParallel C++ textbook by James Reinders page no: 54&lt;/P&gt;
&lt;P&gt;Please refer textbook DataParallel C++ textbook by James Reinders page no: 160&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&lt;I&gt;Would you recommend any sources in that direction?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer below links&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://techdecoded.intel.io/essentials/dpc-part-1-an-introduction-to-the-new-programming-model/#gs.8r8j97" target="_blank" rel="noopener"&gt;https://techdecoded.intel.io/essentials/dpc-part-1-an-introduction-to-the-new-programming-model/#gs.8r8j97&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://techdecoded.intel.io/essentials/dpc-part-2-programming-best-practices/#gs.8r8md1" target="_blank" rel="noopener"&gt;https://techdecoded.intel.io/essentials/dpc-part-2-programming-best-practices/#gs.8r8md1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://software.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top.html" target="_blank" rel="noopener"&gt;https://software.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;DataPrallel C++ textbook by James Reinders Textbook.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;
&lt;P&gt;Noorjahan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 12:42:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1306216#M1481</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2021-08-23T12:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308064#M1501</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Has the information provided helped?&amp;nbsp;If yes then could you please confirm whether we can close this thread from our end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;
&lt;P&gt;Noorjahan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 12:39:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308064#M1501</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2021-09-09T12:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308100#M1503</link>
      <description>&lt;P&gt;Hello Noorjahan,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for my late reply. I was traveling!&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt; The one which i have referred in previous response is page no. of pdf. Apologies for any confusion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The page number is not still clear to me. Could you please repeat that? Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than that. The resources are helpful. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Leila&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 13:49:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308100#M1503</guid>
      <dc:creator>leilag</dc:creator>
      <dc:date>2021-08-19T13:49:10Z</dc:date>
    </item>
    <item>
      <title>Re:malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308962#M1506</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;T&lt;I&gt;he page number is not still clear to me. Could you please repeat that?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;1) To pass part of a array we can try using explicit memory operations one of the action part of command group handler.&lt;/P&gt;&lt;P&gt;Using these operations we can copy data between pointers/accessors.&lt;/P&gt;&lt;P&gt;Please go through Chapter:2(page no:54) from&amp;nbsp;DataParallel C++ textbook by James Reinder for better understanding.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;2) malloc_device() allocation type is accessible only on device side.&lt;/P&gt;&lt;P&gt;To initialize the memory we can use memset function that allocates memory which is available on both device and host for malloc_device() allocation type.&lt;/P&gt;&lt;P&gt;Please go through Chapter:6 (page no:160) from&amp;nbsp;DataParallel C++ textbook by James Reinder for better understanding.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I hope this will clear your queries.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As you marked as a solution, can we close this thread.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Noorjahan&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Aug 2021 12:41:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308962#M1506</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2021-08-23T12:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308983#M1507</link>
      <description>&lt;P&gt;Thanks for the clarification.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 12:52:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1308983#M1507</guid>
      <dc:creator>leilag</dc:creator>
      <dc:date>2021-08-23T12:52:14Z</dc:date>
    </item>
    <item>
      <title>Re:malloc_device a 2D array</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1309262#M1508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the confirmation!&lt;/P&gt;&lt;P&gt;As this issue has been resolved, we will no longer respond to this thread.&lt;/P&gt;&lt;P&gt;If you require any additional assistance from Intel, please start a new thread.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Noorjahan.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 24 Aug 2021 06:57:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/malloc-device-a-2D-array/m-p/1309262#M1508</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2021-08-24T06:57:00Z</dc:date>
    </item>
  </channel>
</rss>

