<?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: OpenMP example in GPU Compute Software</title>
    <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1409383#M596</link>
    <description>&lt;P&gt;I don't mind you closing.&amp;nbsp; I cannot see this going anywhere.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2022 09:30:53 GMT</pubDate>
    <dc:creator>Ian_Miller</dc:creator>
    <dc:date>2022-08-19T09:30:53Z</dc:date>
    <item>
      <title>OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1341774#M256</link>
      <description>&lt;P&gt;The page&amp;nbsp;&lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/software-development-process/composability/c-c-openmp-and-dpc-composability.html" target="_blank" rel="noopener"&gt;C/C++ OpenMP* and DPC++ Composability&lt;/A&gt;&amp;nbsp;contains an example of using OpenMP to "offload" to the GPU.&amp;nbsp; &amp;nbsp;However when I tried using this I found that the example actually took more CPU time if it is compiled with OpenMP pragmas, than it the pragmas are removed.&lt;/P&gt;
&lt;P&gt;I created two files openMP.cpp (exactly the example from the page) and noOpenMP.cpp (the same but with the pragmas commented out).&amp;nbsp; I ran them with the following results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ian@i3:~/openmp$ icpx -o withOpenMP -fsycl -fiopenmp -fopenmp-targets=spir64 openMP.cpp 
ian@i3:~/openmp$ icpx -o withoutOpenMP -fsycl -fiopenmp -fopenmp-targets=spir64 noOpenMP.cpp 
ian@i3:~/openmp$ time ./withOpenMP 
Vec[512] = 512
Pi = 3.14159

real	0m0.931s
user	0m1.561s
sys	0m0.125s
ian@i3:~/openmp$ time ./withoutOpenMP 
Vec[512] = 512
Pi = 3.14159

real	0m0.180s
user	0m0.155s
sys	0m0.024s
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the pragmas, the program takes 5 times as long and uses nearly 10 times as much CPU as if the pragmas are omitted.&amp;nbsp; &amp;nbsp;As an attempt to offload the CPU, this is spectacular failure.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there any examples where OpenMP can actually be used to offload the CPU?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2021 15:03:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1341774#M256</guid>
      <dc:creator>Ian_Miller</dc:creator>
      <dc:date>2021-12-06T15:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342087#M259</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, openMP&amp;nbsp;will run on the CPU.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we want to offload it to any specific GPU target, then only we use -fiopenmp -fopenmp-targets=spir64 option to enable offloading to a specified GPU target(Linux*) explicitly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see the below scenarios:&lt;/P&gt;
&lt;P&gt;1. To enable openMP and DPC++/SYCL constructs, use the below command:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;icpx -fsycl -fiopenmp -fopenmp-targets=spir64 offloadOmp_dpcpp.cpp
&lt;/LI-CODE&gt;
&lt;P&gt;-fsycl option enables DPC++&lt;/P&gt;
&lt;P&gt;-fiopenmp -fopenmp-targets=spir64 option enables OpenMP* offload for GPU&lt;BR /&gt;**&amp;nbsp;If we do not specify any target, then the default offloading&amp;nbsp;to host/CPU will be done.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;If the code does not contain OpenMP offload, but only normal OpenMP code, use the below command.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;icpx -fsycl -fiopenmp omp_dpcpp.cpp
&lt;/LI-CODE&gt;
&lt;P&gt;3.&amp;nbsp; If there is no openMP code, then use the below command.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;icpx -fsycl noOpenMP.cpp&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;We tried compiling and running the OpenMP &amp;amp; noOpenMP codes as below. And, we observed only a minimal change in time w.r.t&amp;nbsp;program and CPU for both cases.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;u67125@s001-n066:~/openmp$ icpx -fsycl -fiopenmp -fopenmp-targets=spir64 openMP.cpp -o withOpenMP
u67125@s001-n066:~/openmp$ time ./withOpenMP
Vec[512] = 512
Pi = 3.14159

real 0m0.415s
user 0m4.042s
sys 0m0.198s
u67125@s001-n066:~/openmp$ icpx -fsycl noOpenMP.cpp -o withoutOpenMP
u67125@s001-n066:~/openmp$ time ./withoutOpenMP
Vec[512] = 512
Pi = 3.14159

real 0m0.301s
user 0m1.950s
sys 0m0.115s&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 09:54:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342087#M259</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2021-12-08T09:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342089#M260</link>
      <description>&lt;P&gt;Thank you for your reply.&amp;nbsp; &amp;nbsp;I was aware of the need to use "&lt;SPAN&gt;&amp;nbsp;-fiopenmp -fopenmp-targets=spir64&amp;nbsp;" to offload to the GPU.&amp;nbsp; Indeed as you will see from my original question, I used those options.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Whereas you have much less difference (probably due to the different hardware), you also had more CPU used in the "offload" case, than in the pure CPU case.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My original question, "&lt;SPAN&gt;Are there any examples where OpenMP can actually be used to offload the CPU?", remains.&amp;nbsp; &amp;nbsp;Can you provide an example of offloading significantly reducing CPU usage?&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 11:57:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342089#M260</guid>
      <dc:creator>Ian_Miller</dc:creator>
      <dc:date>2021-12-07T11:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342433#M263</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to the example code attached below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can see from the below screenshot that using OpenMP,&amp;nbsp; CPU usage has been reduced to half the time when compared to that of not using OpenMP.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EXAMPLE.png" style="width: 999px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/24675iD5D73FE89130A56F/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="EXAMPLE.png" alt="EXAMPLE.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 11:08:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342433#M263</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2021-12-08T11:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342443#M265</link>
      <description>&lt;P&gt;What is this "screenshot" that you refer to?&amp;nbsp; &amp;nbsp;Do you the terminal dialogue on host "&lt;A href="mailto:u67125@s001-n066&amp;quot;" target="_blank"&gt;u67125@s001-n066"?&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In that case the "withOpenMP" case takes 4.042s + 0.198s = 4.240s CPU&lt;/P&gt;
&lt;P&gt;whereas the "&lt;SPAN&gt;withoutOpenMP" case takes 1.950s + 0.115s = 2.065s CPU.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The with OpenMP case takes over twice as much CPU as the withoutOpenMP case.&amp;nbsp; Far from offloading the CPU, it is doubling the CPU load.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you are not referring to that terminal dialogue, what are you referring to?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 11:18:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342443#M265</guid>
      <dc:creator>Ian_Miller</dc:creator>
      <dc:date>2021-12-08T11:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342453#M266</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="background-color: var(--lwc-colorbackgroundinput,#ffffff); color: var(--lwc-colortextweak,#3e3e3c); font-size: var(--lwc-fontSize3,0.8125rem); font-family: var(--lwc-fontFamily,-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol');"&gt;&amp;gt;&amp;gt;"&lt;/SPAN&gt;&lt;SPAN style="background-color: var(--lwc-colorbackgroundinput,#ffffff); color: var(--lwc-colortextweak,#3e3e3c);"&gt;If you are not referring to that terminal dialogue, what are you referring to?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I was referring to the screenshot provided in my previous post. (The screenshot might take a few seconds to be updated at your end.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can see from the below screenshot that using OpenMP,&amp;nbsp;CPU usage has been reduced to half the time when compared to that of not using OpenMP.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EXAMPLE.png" style="width: 999px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/24675iD5D73FE89130A56F/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="EXAMPLE.png" alt="EXAMPLE.png" /&gt;&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;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 12:01:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342453#M266</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2021-12-08T12:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342466#M267</link>
      <description>&lt;P&gt;What is the hardware for this speed improvement?&amp;nbsp; What CPU and what GPU?&lt;/P&gt;
&lt;P&gt;I am using a&amp;nbsp;Celeron&amp;nbsp; 3965U&amp;nbsp;CPU, and a Kaby Lake HD 610 (device 5906) GPU.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you are achieving some CPU reduction, halving the CPU when you are offloading the complete task is pretty lame.&amp;nbsp; My previous experience of offloading (about ten years ago using CUDA), I took a task that would have taken the CPU a few times over and used about 2% of CPU when offloaded to the GPU.&amp;nbsp; &amp;nbsp;I wasn't necessarily expecting the offload to be that good, but I was definitely hoping for a factor 10 reduction in CPU.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 12:35:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1342466#M267</guid>
      <dc:creator>Ian_Miller</dc:creator>
      <dc:date>2021-12-08T12:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1344221#M276</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My CPU &amp;amp; GPU details are given below:&lt;/P&gt;
&lt;P&gt;CPU: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz&lt;/P&gt;
&lt;P&gt;GPU: Intel(R) UHD Graphics 630 [0x3e98]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please let us know the CPU details that you have used 10 years ago?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&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>Wed, 15 Dec 2021 07:37:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1344221#M276</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2021-12-15T07:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1344231#M277</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Santosh,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I regret that I do not still have the hardware or remember precisely what it was.&amp;nbsp; I have checked the project archives.&amp;nbsp; It includes all of the code, but does not record the precise hardware.&lt;/P&gt;
&lt;P&gt;The PC was a reasonably typical desktop machine of the time.&amp;nbsp; The NVIDIA GPU was a mid-range one,&amp;nbsp; one of the cheaper ones capable of GPGPU processing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry I cannot be more precise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ian&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 08:18:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1344231#M277</guid>
      <dc:creator>Ian_Miller</dc:creator>
      <dc:date>2021-12-15T08:18:55Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1345580#M278</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We are working on your issue internally and will get back to you soon.&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;Santosh&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2021 05:14:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1345580#M278</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2021-12-21T05:14:51Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1369086#M362</link>
      <description>&lt;P&gt;Hi Ian,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I've searched internally but couldn't find any examples which match what you are looking for.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sorry for the inconvenience. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Mar 2022 21:20:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1369086#M362</guid>
      <dc:creator>Viet_H_Intel</dc:creator>
      <dc:date>2022-03-15T21:20:43Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1408860#M593</link>
      <description>&lt;P&gt;Hi Ian,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Can we close this thread?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Aug 2022 15:03:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1408860#M593</guid>
      <dc:creator>Viet_H_Intel</dc:creator>
      <dc:date>2022-08-17T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1409383#M596</link>
      <description>&lt;P&gt;I don't mind you closing.&amp;nbsp; I cannot see this going anywhere.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 09:30:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1409383#M596</guid>
      <dc:creator>Ian_Miller</dc:creator>
      <dc:date>2022-08-19T09:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP example</title>
      <link>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1415576#M626</link>
      <description>&lt;P&gt;A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 08:32:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/GPU-Compute-Software/OpenMP-example/m-p/1415576#M626</guid>
      <dc:creator>paanjii2</dc:creator>
      <dc:date>2022-09-19T08:32:10Z</dc:date>
    </item>
  </channel>
</rss>

