<?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: problems about SYCL reduction variables using oneAPI in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1456038#M2816</link>
    <description>&lt;P&gt;Hi,&amp;nbsp; SeshaP,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately I cannot compile you code in visual studio 2022..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error message is "error : SYCL kernel cannot call a variadic function"&lt;/P&gt;
&lt;P&gt;and "error : SYCL kernel cannot call an undefined function without SYCL_EXTERNAL attribute"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me with that?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 05:12:56 GMT</pubDate>
    <dc:creator>PC-1</dc:creator>
    <dc:date>2023-02-15T05:12:56Z</dc:date>
    <item>
      <title>problems about SYCL reduction variables using oneAPI</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1454057#M2774</link>
      <description>&lt;P&gt;Hi, I'm new to SYCL and am trying to run an example about reduction variables from the SYCL Specification with oneAPI 2023.0.0. I revise the code a little and the final version is shown as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;sycl/sycl.hpp&amp;gt;
#include &amp;lt;numeric&amp;gt;

using namespace sycl;

int main() {
	buffer&amp;lt;int&amp;gt; valuesBuf{ 1024 };
	{
		host_accessor a{ valuesBuf };
        // std::iota(a.begin(), a.end(), 0);
        std::iota(&amp;amp;(a[0]), &amp;amp;(a[1023]), 0);
	}

	int sumResult = 0;
	buffer&amp;lt;int&amp;gt; sumBuf{ &amp;amp;sumResult, 1 };
	int maxResult = 0;
	buffer&amp;lt;int&amp;gt; maxBuf{ &amp;amp;maxResult, 1 };

	queue myQueue;

	myQueue.submit([&amp;amp;](handler&amp;amp; cgh) {
		auto inputValues = valuesBuf.get_access&amp;lt;access_mode::read&amp;gt;(cgh);
	auto sumReduction = reduction(sumBuf, cgh, plus&amp;lt;&amp;gt;());
	auto maxReduction = reduction(maxBuf, cgh, maximum&amp;lt;&amp;gt;());

    /*
	 cgh.parallel_for(range&amp;lt;1&amp;gt; {2048, 1024}, sumReduction, maxReduction,
		[=](nd_item&amp;lt;1&amp;gt; it, auto&amp;amp; sum, auto&amp;amp; max) {
			sum += inputValues[it.get_local_id()];
			max.combine(inputValues[it.get_global_id()]);
		});
    */

    cgh.parallel_for(nd_range&amp;lt;1&amp;gt; {2048, 1024}, sumReduction, maxReduction,
		[=](nd_item&amp;lt;1&amp;gt; it, auto&amp;amp; sum, auto&amp;amp; max) {
			sum += inputValues[it.get_local_id()];
	        max.combine(inputValues[it.get_local_id()]);
		});
    });

	// assert(maxBuf.get_host_access()[0] == 1023 &amp;amp;&amp;amp; sumBuf.get_host_access()[0] == 523776);
    std::cout &amp;lt;&amp;lt; maxBuf.get_host_access()[0] &amp;lt;&amp;lt; std::endl;
    std::cout &amp;lt;&amp;lt; sumBuf.get_host_access()[0] &amp;lt;&amp;lt; std::endl;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the program compiled with icpx in cmd does not work as expected. The program typically prints out nothing and exits with a meaningless value. The result is shown below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;C:\Users\a1595\Desktop\dr\c&amp;gt;icpx -fsycl c.cpp -o c.exe

C:\Users\a1595\Desktop\dr\c&amp;gt;c.exe

C:\Users\a1595\Desktop\dr\c&amp;gt;echo %ERRORLEVEL%
-1073740791​&lt;/LI-CODE&gt;
&lt;P&gt;I am wondering whether there is anything wrong with the code, compilation or anything else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking forward to any help. Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 09:30:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1454057#M2774</guid>
      <dc:creator>JamesFBM</dc:creator>
      <dc:date>2023-02-07T09:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: problems about SYCL reduction variables using oneAPI</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1454787#M2780</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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the below modified DPC++ source code which is producing the correct values after the execution.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;CL/sycl.hpp&amp;gt;
#include &amp;lt;numeric&amp;gt;
using namespace sycl;

int main()
{
    buffer&amp;lt;int&amp;gt; valuesBuf { 1024 };
    {
        host_accessor a { valuesBuf };
        std::iota(&amp;amp;a[0], &amp;amp;a[0] + 1024, 0);
    }
    
    int sumResult = 0;
    buffer&amp;lt;int&amp;gt; sumBuf { &amp;amp;sumResult, 1 };
    
    int maxResult = 0;
    buffer&amp;lt;int&amp;gt; maxBuf{ &amp;amp;maxResult, 1 };
    
    queue myQueue;
    myQueue.submit([&amp;amp;](handler&amp;amp; cgh) {
        
        auto inputValues = valuesBuf.get_access&amp;lt;access_mode::read&amp;gt;(cgh);       
        auto sumReduction = reduction(sumBuf, cgh, plus&amp;lt;&amp;gt;());
        auto maxReduction = reduction(maxBuf, cgh, maximum&amp;lt;&amp;gt;());
                                    
        cgh.parallel_for(nd_range&amp;lt;1&amp;gt; {1024, 256}, sumReduction, maxReduction,
                         [=](nd_item&amp;lt;1&amp;gt; it, auto&amp;amp; sum, auto&amp;amp; max) {
                             sum+= inputValues[it.get_global_id()];
                             max.combine(inputValues[it.get_global_id()]);
                         });
    });
   
    std::cout &amp;lt;&amp;lt; "maxReduction = "&amp;lt;&amp;lt;maxBuf.get_host_access()[0] &amp;lt;&amp;lt; std::endl;
    std::cout &amp;lt;&amp;lt; "sumReduction = "&amp;lt;&amp;lt;sumBuf.get_host_access()[0] &amp;lt;&amp;lt; std::endl;
    return 0;
}&lt;/LI-CODE&gt;
&lt;P&gt;Please find the output screenshot below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SeshaP_Intel_0-1675919697364.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/37918iA7286668DD3F9BEA/image-size/medium?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="SeshaP_Intel_0-1675919697364.png" alt="SeshaP_Intel_0-1675919697364.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hope this resolves your issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and Regards,&lt;/P&gt;
&lt;P&gt;Pendyala Sesha Srinivas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 05:15:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1454787#M2780</guid>
      <dc:creator>SeshaP_Intel</dc:creator>
      <dc:date>2023-02-09T05:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: problems about SYCL reduction variables using oneAPI</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1455691#M2812</link>
      <description>&lt;P&gt;Hi, Sesha. Thanks a lot for your help. Your code works on my computer and I simply misunderstood the usage of nd_range.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 13:33:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1455691#M2812</guid>
      <dc:creator>JamesFBM</dc:creator>
      <dc:date>2023-02-14T13:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: problems about SYCL reduction variables using oneAPI</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1456038#M2816</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; SeshaP,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately I cannot compile you code in visual studio 2022..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error message is "error : SYCL kernel cannot call a variadic function"&lt;/P&gt;
&lt;P&gt;and "error : SYCL kernel cannot call an undefined function without SYCL_EXTERNAL attribute"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me with that?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 05:12:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1456038#M2816</guid>
      <dc:creator>PC-1</dc:creator>
      <dc:date>2023-02-15T05:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: problems about SYCL reduction variables using oneAPI</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1456063#M2817</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for accepting our solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt; &lt;EM&gt;Unfortunately I cannot compile you code in visual studio 2022.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Please refer to the below output screenshot built on Visual Studio in Release Mode.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SeshaP_Intel_0-1676441264517.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/38052i36A77AB2668FEF3F/image-size/medium?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="SeshaP_Intel_0-1676441264517.png" alt="SeshaP_Intel_0-1676441264517.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and Regards,&lt;/P&gt;
&lt;P&gt;Pendyala Sesha Srinivas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 06:07:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/problems-about-SYCL-reduction-variables-using-oneAPI/m-p/1456063#M2817</guid>
      <dc:creator>SeshaP_Intel</dc:creator>
      <dc:date>2023-02-15T06:07:56Z</dc:date>
    </item>
  </channel>
</rss>

