<?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 Calling function from kernel scope. SYCL_EXTERNAL in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361021#M1889</link>
    <description>&lt;P&gt;I have my_func.cpp/.hpp with some fuction&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;LI-CODE lang="markup"&gt;/* my_func.hpp */
void my_func();

/* my_func.cpp */
void my_func() {
// do some stuff   
// call some other funcs
}&lt;/LI-CODE&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;In my main.cpp I wrote a simple kernel, which just calls my_func()&lt;/P&gt;
&lt;P&gt;When compiling it with VS2022 compiler says, that my_func() should have SYCL_EXTERNAL attribute?&lt;/P&gt;
&lt;P&gt;How do i get over this error?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 22:27:41 GMT</pubDate>
    <dc:creator>Xeenych</dc:creator>
    <dc:date>2022-02-16T22:27:41Z</dc:date>
    <item>
      <title>Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361021#M1889</link>
      <description>&lt;P&gt;I have my_func.cpp/.hpp with some fuction&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;LI-CODE lang="markup"&gt;/* my_func.hpp */
void my_func();

/* my_func.cpp */
void my_func() {
// do some stuff   
// call some other funcs
}&lt;/LI-CODE&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;In my main.cpp I wrote a simple kernel, which just calls my_func()&lt;/P&gt;
&lt;P&gt;When compiling it with VS2022 compiler says, that my_func() should have SYCL_EXTERNAL attribute?&lt;/P&gt;
&lt;P&gt;How do i get over this error?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 22:27:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361021#M1889</guid>
      <dc:creator>Xeenych</dc:creator>
      <dc:date>2022-02-16T22:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361202#M1892</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;&lt;I&gt;&amp;gt;&amp;gt;How do i get over this error?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SYCL_EXTERNAL is an optional macro that enables external linkage of SYCL functions and methods to be included in an SYCL kernel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we want to call a function from a kernel, that function(in our case void my_func()) should be preceded with SYCL_EXTERNAL in the header file, then you can get rid of this compiler error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have tried the following code with dpc++ version 2022.0.0 and it worked for us.&lt;/P&gt;
&lt;P&gt;Please find the below code snippets.&lt;/P&gt;
&lt;P&gt;Header.h&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#pragma once
#include&amp;lt;CL/sycl.hpp&amp;gt;
extern SYCL_EXTERNAL void my_func();&lt;/LI-CODE&gt;
&lt;P&gt;my_fun.cpp&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#include &amp;lt;CL/sycl.hpp&amp;gt;
#include "Header.h"
void my_func() {
}&lt;/LI-CODE&gt;
&lt;P&gt;main.cpp&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#include &amp;lt;CL/sycl.hpp&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include "Header.h"
#define numElements 10
using namespace std;

int main(void) 
{
cl::sycl::queue queue(cl::sycl::host_selector{});
std::cout &amp;lt;&amp;lt; "Running on " &amp;lt;&amp;lt; queue.get_device().get_info&amp;lt;cl::sycl::info::device::name&amp;gt;() &amp;lt;&amp;lt; "\n";

{
queue.submit(
[&amp;amp;](cl::sycl::handler&amp;amp; cgh) {
cgh.parallel_for&amp;lt;class vectorAdd_e83213&amp;gt;(
cl::sycl::range&amp;lt;1&amp;gt;{numElements}, [=](cl::sycl::item&amp;lt;1&amp;gt; item_ct1) {
my_func(); 
});
});
}
queue.wait();
return 0;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this resolves your issue, make sure to accept this as a solution. This would help others with a similar issue.&lt;/P&gt;
&lt;P&gt;If your issue still persists, please do let us know which oneAPI version is being used.&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, 17 Feb 2022 11:10:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361202#M1892</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2022-02-17T11:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361204#M1893</link>
      <description>&lt;P&gt;Ok, this works, but:&lt;/P&gt;
&lt;P&gt;my_func() calls tons of other functions.&lt;/P&gt;
&lt;P&gt;I have to add SYCL_EXTERNAL to every declaration in .hpp and every definition in.cpp of all functions in a call-tree of my_func()&lt;/P&gt;
&lt;P&gt;This introduces a dependancy on DPC++ headers in my_func() and other sources&lt;/P&gt;
&lt;P&gt;I could have written something like this for every function in a call-tree of my_func().&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#if defined __INTEL_LLVM_COMPILER &amp;amp;&amp;amp; SYCL_LANGUAGE_VERISON
#include &amp;lt;CL/sycl.hpp&amp;gt;
#else
#define SYCL_EXTERNAL
#endif

SYCL_EXTERNAL void my_func();&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to avoid this?&lt;/P&gt;
&lt;P&gt;Is there a linker script or some command-line arguments for compiler to list functions to be included in SYCL kernel without specifying SYCL_EXTERNAL?&lt;/P&gt;
&lt;P&gt;I thought, that intel compiler is advanced enough to determine functions to be included in kernel and link them accordingly.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 11:12:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1361204#M1893</guid>
      <dc:creator>Xeenych</dc:creator>
      <dc:date>2022-02-17T11:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1363700#M1909</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&amp;gt;&amp;gt;Is there a linker script or some command-line arguments for compiler to list functions to be included in SYCL kernel without specifying SYCL_EXTERNAL?&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for causing any inconvenience, there is no such script or command-line argument to list the functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As of now, we need to use macro definitions to add SYCL_EXTERNAL for every function as you have mentioned in the earlier post.&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;Noorjahan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:27:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1363700#M1909</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2022-03-10T09:27:47Z</dc:date>
    </item>
    <item>
      <title>Re:Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1365784#M1927</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Could you please provide an update on your issue?&lt;/P&gt;&lt;P&gt;If the information provided above helped, Could you also please confirm whether can we close this issue from our end.&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, 04 Mar 2022 09:56:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1365784#M1927</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2022-03-04T09:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1365804#M1928</link>
      <description>&lt;P&gt;Yes, this helped. You can close the issue.&lt;/P&gt;
&lt;P&gt;P.S.&lt;/P&gt;
&lt;P&gt;Looks like my account was banned for several days, but now it works.&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>Fri, 04 Mar 2022 10:51:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1365804#M1928</guid>
      <dc:creator>Xeenych</dc:creator>
      <dc:date>2022-03-04T10:51:43Z</dc:date>
    </item>
    <item>
      <title>Re:Calling function from kernel scope. SYCL_EXTERNAL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1365822#M1929</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&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. If you need any additional information, please submit a new question as this thread will no longer be monitored.&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, 04 Mar 2022 11:49:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Calling-function-from-kernel-scope-SYCL-EXTERNAL/m-p/1365822#M1929</guid>
      <dc:creator>NoorjahanSk_Intel</dc:creator>
      <dc:date>2022-03-04T11:49:49Z</dc:date>
    </item>
  </channel>
</rss>

