<?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 How to understand this `handler` in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1458880#M2858</link>
    <description>&lt;P&gt;We can use both `buffers` and `USM` implementations in `oneapi`,&lt;BR /&gt;In `USM`:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;queue q;
int *data1 = malloc_shared&amp;lt;int&amp;gt;(128, q);
for (int i = 0; i &amp;lt; N; i++) {
data1[i] = 10;
}
auto e1 = q.parallel_for(range&amp;lt;1&amp;gt;(N), [=](id&amp;lt;1&amp;gt; i) { data1[i] += 2; });&lt;/LI-CODE&gt;
&lt;P&gt;We use `q.parallel_for` to do parallel computing.&lt;/P&gt;
&lt;P&gt;In `buffers`&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;std::vector&amp;lt;int&amp;gt; vector1(128, 10);
buffer vector1_buffer(vector1);
queue q;
q.submit([&amp;amp;](handler &amp;amp;h) {
    accessor vector1_accessor (vector1_buffer,h);
    h.parallel_for(range&amp;lt;1&amp;gt;(N), [=](id&amp;lt;1&amp;gt; index) {
        vector1_accessor[index] += 1;
    });
});&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;We pass `handler` to the lambda function and use `h.parallel_for` to do parallel computing.&lt;/P&gt;
&lt;P&gt;My question is what is handler, how do I understand it? What is the different between `handler` and `queue`?&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2023 02:30:49 GMT</pubDate>
    <dc:creator>Klen</dc:creator>
    <dc:date>2023-02-24T02:30:49Z</dc:date>
    <item>
      <title>How to understand this `handler`</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1458880#M2858</link>
      <description>&lt;P&gt;We can use both `buffers` and `USM` implementations in `oneapi`,&lt;BR /&gt;In `USM`:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;queue q;
int *data1 = malloc_shared&amp;lt;int&amp;gt;(128, q);
for (int i = 0; i &amp;lt; N; i++) {
data1[i] = 10;
}
auto e1 = q.parallel_for(range&amp;lt;1&amp;gt;(N), [=](id&amp;lt;1&amp;gt; i) { data1[i] += 2; });&lt;/LI-CODE&gt;
&lt;P&gt;We use `q.parallel_for` to do parallel computing.&lt;/P&gt;
&lt;P&gt;In `buffers`&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;std::vector&amp;lt;int&amp;gt; vector1(128, 10);
buffer vector1_buffer(vector1);
queue q;
q.submit([&amp;amp;](handler &amp;amp;h) {
    accessor vector1_accessor (vector1_buffer,h);
    h.parallel_for(range&amp;lt;1&amp;gt;(N), [=](id&amp;lt;1&amp;gt; index) {
        vector1_accessor[index] += 1;
    });
});&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;We pass `handler` to the lambda function and use `h.parallel_for` to do parallel computing.&lt;/P&gt;
&lt;P&gt;My question is what is handler, how do I understand it? What is the different between `handler` and `queue`?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 02:30:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1458880#M2858</guid>
      <dc:creator>Klen</dc:creator>
      <dc:date>2023-02-24T02:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to understand this `handler`</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1460042#M2861</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for posting in Intel communities.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;gt;what is handler, how do I understand it? What is the different between `handler` and `queue`?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A command group usually contains code, that defines dependences running as part of the host program (so that the runtime knows what the dependences are) and device code running in the future once the dependences are satisfied.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A command group handler gives more control over how code is submitted to the queue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A DPC++ queue is employed to schedule and execute the command queues on the devices.&lt;/P&gt;
&lt;P&gt;Queue also uses a shortcut method that directly invoke parallel_for on the queue object instead of inside a lambda passed to the submit method (a command group).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Queues are used to schedule the execution of a set of handlers, ensuring that dependencies between commands are correctly managed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The handler encapsulates the details of a single parallel computation, while the queue manages the execution of a set of handlers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to the Data parallel C++ Textbook by James Reinders for more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Vankudothu Vaishnavi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 04:31:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1460042#M2861</guid>
      <dc:creator>VaishnaviV_Intel</dc:creator>
      <dc:date>2023-02-28T04:31:01Z</dc:date>
    </item>
    <item>
      <title>Re:How to understand this `handler`</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1461409#M2873</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has the information provided above helped? If yes, could you please confirm whether we can close this thread from our end?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Vankudothu Vaishnavi.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Mar 2023 09:42:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1461409#M2873</guid>
      <dc:creator>VaishnaviV_Intel</dc:creator>
      <dc:date>2023-03-03T09:42:20Z</dc:date>
    </item>
    <item>
      <title>Re:How to understand this `handler`</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1464077#M2886</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.&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;Vankudothu Vaishnavi.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Mar 2023 06:33:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/How-to-understand-this-handler/m-p/1464077#M2886</guid>
      <dc:creator>VaishnaviV_Intel</dc:creator>
      <dc:date>2023-03-10T06:33:32Z</dc:date>
    </item>
  </channel>
</rss>

