<?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: Re:error: expression is not assignable in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1268952#M1049</link>
    <description>&lt;P&gt;Hi Chris-&lt;/P&gt;
&lt;P&gt;The problem is that dv and cv are being captured in the lambda by 'copy', see here for clarification on how lambda captures work: &lt;A href="https://en.cppreference.com/w/cpp/language/lambda#Lambda_capture" target="_blank"&gt;https://en.cppreference.com/w/cpp/language/lambda#Lambda_capture&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Lambda objects (that is, the anonymous type that backs the lambda function) are const-by-default, so all their fields are as well.&amp;nbsp; In this case, the 'dv[i]' being referred to in the expression in question is actually a sliced copy of 'dv' from the larger scope.&amp;nbsp; That copy is 'const', since the lambda is const.&lt;/P&gt;
&lt;P&gt;Someone with better familiarity with the SYCL library can better clarify the 'right' way to modify host-state from a kernel, but I believe you are supposed to use accessors and buffers for that purpose.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Mar 2021 22:20:12 GMT</pubDate>
    <dc:creator>ErichKeane</dc:creator>
    <dc:date>2021-03-29T22:20:12Z</dc:date>
    <item>
      <title>error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264491#M1018</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a very simple "view" class&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;class MyBase{
protected:
  size_t sz;
  double* v;
public:
  inline double &amp;amp;operator[](const size_t i){ return v[i]; }
  inline double operator[](const size_t i) const{ return v[i]; }
};
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that acts as the base class of the MyContainer class (which contains the allocation and non-trivial functionality) in order to get around the burdensome restriction that objects accessed inside kernels must be trivially constructible. The allocation in MyContainer is performed with managed memory.&lt;/P&gt;
&lt;P&gt;I have a very simple kernel:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;      dv[i] = cv[i]*cv[i];
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where dv and cv are MyBase&amp;amp;&amp;nbsp; references. This fails to compile under oneapi/2020.12.15.005 on JLSE with the following error:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;test_a2a.C:95:13: error: expression is not assignable&lt;BR /&gt;dv[i] = cv[i]*cv[i];&lt;/P&gt;
&lt;P&gt;The code is obviously correct and compiles if I replace the accelerator loop with a regular for loop.&lt;/P&gt;
&lt;P&gt;Attached is the code. To make:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;test_a2a: test_a2a.C
	dpcpp test_a2a.C -o test_a2a  -fsycl-device-code-split=per_kernel -fsycl-device-lib=all&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 17:41:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264491#M1018</guid>
      <dc:creator>giltirn</dc:creator>
      <dc:date>2021-03-15T17:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264513#M1020</link>
      <description>&lt;P&gt;Follow-up: I've been able to bypass the compile error by replacing&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;inline double &amp;amp;operator[](const size_t i){ return v[i]; }&lt;/LI-CODE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;inline double &amp;amp;operator[](const size_t i) const{ return v[i]; }&lt;/LI-CODE&gt;
&lt;P&gt;Thus it seems that the kernel is capturing all variables as const. The above seems like a syntactic abuse of the meaning of a const method to me, is this truly the "blessed" way of writing an accessor in DPC++??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 19:00:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264513#M1020</guid>
      <dc:creator>giltirn</dc:creator>
      <dc:date>2021-03-15T19:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264760#M1021</link>
      <description>&lt;P&gt;Hi Christopher,&lt;/P&gt;
&lt;P&gt;Thanks for providing the source code and steps to reproduce your issue. We are able to reproduce the error which you are facing. We are working on it internally we will get back to you soon.&lt;/P&gt;
&lt;P&gt;However, as mentioned by you after adding &lt;STRONG&gt;const &lt;/STRONG&gt;to the operator overloading "&lt;I&gt;expression is not assignable" &lt;/I&gt;error was resolved whereas we got another error saying "&lt;I&gt;error: functions that differ only in their return type cannot be overloaded&lt;/I&gt;". We can see that you are trying to overload the operator twice. C&lt;SPAN style="font-family: inherit;"&gt;ould you please let us know is there any specific reason behind it? However, when we commented out one of the lines, we are able to compile and run the code successfully.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt; inline double &amp;amp;operator[](const size_t i) const{ return v[i]; }
 // inline double operator[](const size_t i) const{ return v[i]; }&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;when we try to print the values of &lt;/SPAN&gt;&lt;STRONG style="font-family: inherit;"&gt;&lt;I&gt;dv[i]&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;the first 10 values are as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;5.26354e-315 0 0 0 4.94066e-324 4.94066e-324 0 4.94066e-324 0 0&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is this the expected behaviour? If not, please let us know the expected behavior of the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Regards&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;Goutham&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="highlighter--hover-tools" style="display: none;"&gt;
&lt;DIV id="highlighter--hover-tools--container"&gt;
&lt;DIV class="highlighter--icon highlighter--icon-copy" title="Copy"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--separator"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--icon highlighter--icon-change-color" title="Change Color"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--separator"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--icon highlighter--icon-delete" title="Delete"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="highlighter--hover-tools" style="display: none;"&gt;
&lt;DIV id="highlighter--hover-tools--container"&gt;
&lt;DIV class="highlighter--icon highlighter--icon-copy" title="Copy"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--separator"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--icon highlighter--icon-change-color" title="Change Color"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--separator"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="highlighter--icon highlighter--icon-delete" title="Delete"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 Mar 2021 11:04:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264760#M1021</guid>
      <dc:creator>GouthamK_Intel</dc:creator>
      <dc:date>2021-03-16T11:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264785#M1025</link>
      <description>&lt;P&gt;Hi Goutham,&lt;/P&gt;
&lt;P&gt;I apologize, I should have mentioned that I also removed the other accessor. Adding it back in I see the same error as you.&lt;/P&gt;
&lt;P&gt;Regarding the output you quoted, the code provided is a minimal example of the compile issue and wasn't intended to actually do any relevant computation. The contents of the memory are not initialized so random nonsense is what I would expect to see if run.&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Chris&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 12:49:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1264785#M1025</guid>
      <dc:creator>giltirn</dc:creator>
      <dc:date>2021-03-16T12:49:38Z</dc:date>
    </item>
    <item>
      <title>Re:error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1265918#M1032</link>
      <description>&lt;P&gt;Hi Christopher,&lt;/P&gt;&lt;P&gt;We are working on your thread internally, we will get back to you soon. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Regards&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Goutham&lt;/I&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Mar 2021 07:21:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1265918#M1032</guid>
      <dc:creator>GouthamK_Intel</dc:creator>
      <dc:date>2021-03-19T07:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Re:error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1268952#M1049</link>
      <description>&lt;P&gt;Hi Chris-&lt;/P&gt;
&lt;P&gt;The problem is that dv and cv are being captured in the lambda by 'copy', see here for clarification on how lambda captures work: &lt;A href="https://en.cppreference.com/w/cpp/language/lambda#Lambda_capture" target="_blank"&gt;https://en.cppreference.com/w/cpp/language/lambda#Lambda_capture&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Lambda objects (that is, the anonymous type that backs the lambda function) are const-by-default, so all their fields are as well.&amp;nbsp; In this case, the 'dv[i]' being referred to in the expression in question is actually a sliced copy of 'dv' from the larger scope.&amp;nbsp; That copy is 'const', since the lambda is const.&lt;/P&gt;
&lt;P&gt;Someone with better familiarity with the SYCL library can better clarify the 'right' way to modify host-state from a kernel, but I believe you are supposed to use accessors and buffers for that purpose.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 22:20:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1268952#M1049</guid>
      <dc:creator>ErichKeane</dc:creator>
      <dc:date>2021-03-29T22:20:12Z</dc:date>
    </item>
    <item>
      <title>Re:error: expression is not assignable</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1286930#M1263</link>
      <description>&lt;P&gt;Mutable lambda could be a solution but it is not allowed by the compiler at this moment. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We will no longer respond to this thread.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jun 2021 16:02:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/error-expression-is-not-assignable/m-p/1286930#M1263</guid>
      <dc:creator>Alina_S_Intel</dc:creator>
      <dc:date>2021-06-03T16:02:04Z</dc:date>
    </item>
  </channel>
</rss>

