<?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 offload quirk (maybe problem if mapping ... in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1194895#M6969</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As your issue is resolved we are closing this thread. Please post a new thread if you have any issues.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 27 Jul 2020 07:05:15 GMT</pubDate>
    <dc:creator>AbhishekD_Intel</dc:creator>
    <dc:date>2020-07-27T07:05:15Z</dc:date>
    <item>
      <title>OpenMP offload quirk (maybe problem if mapping const array?)</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1191653#M6911</link>
      <description>&lt;P&gt;Lenovo T570, Ubuntu 18.04.4,&amp;nbsp;icpc (ICC) 2021.1 Beta 20200602&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;user@t570:~/OneAPI/OMP$ cat bug2.cpp

#include &amp;lt;omp.h&amp;gt;
#include &amp;lt;cstdio&amp;gt;
void
fn(const unsigned int data[7], int n)
{
#pragma omp target teams distribute parallel for map(to:data[:7])
  for (int i=0; i&amp;lt;n; i++) printf("data[%d] = %d\n", i, data[i]);
}

const unsigned int data[7] = {1,2,3,4,5,6,7};
int
main(int argc, char *argv[])
{
  fn(data, 7);
}
user@t570:~/OneAPI/OMP$ make bug2
icpc -std=c++17 -O3 -o bug2 bug2.cpp -qnextgen -fiopenmp -fopenmp-targets=spir64
user@t570:~/OneAPI/OMP$ ./bug2
Abort was called at 719 line in file:
../neo/level_zero/core/source/device/device_imp.cpp
Aborted (core dumped)
&lt;/LI-CODE&gt;
&lt;P&gt;If "data" in not declared "const" then things are fine:&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;user@t570:~/OneAPI/OMP$ cat bug2.cpp

#include &amp;lt;omp.h&amp;gt;
#include &amp;lt;cstdio&amp;gt;
void
fn(const unsigned int data[7], int n)
{
#pragma omp target teams distribute parallel for map(to:data[:7])
  for (int i=0; i&amp;lt;n; i++) printf("data[%d] = %d\n", i, data[i]);
}

unsigned int data[7] = {1,2,3,4,5,6,7};
int
main(int argc, char *argv[])
{
  fn(data, 7);
}
user@t570:~/OneAPI/OMP$ make bug2
icpc -std=c++17 -O3 -o bug2 bug2.cpp -qnextgen -fiopenmp -fopenmp-targets=spir64
user@t570:~/OneAPI/OMP$ ./bug2
data[0] = 1
data[1] = 2
data[2] = 3
data[3] = 4
data[4] = 5
data[5] = 6
data[6] = 7
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I'm not sure why "data" can't be const in the above, but in any case, the diagnostic provides no insight into the problem.&amp;nbsp; &amp;nbsp;(It took me quite a while to pare down my application and "fuzz" my code before I was able to attribute the error to the "const" so maybe this will help someone else Googling for this error in the future.)&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 21:10:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1191653#M6911</guid>
      <dc:creator>CFR</dc:creator>
      <dc:date>2020-07-11T21:10:05Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP offload quirk (maybe problem if mapping ...</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1192201#M6923</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the code sample, you have provided we can see that you want to access a constant array for offload. For handling constant array you can try declaring them inside the main() so that you can use it for offload. Please refer to the below code for more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;omp.h&amp;gt;
#include &amp;lt;cstdio&amp;gt;

void fn(const unsigned int data[7], int n){

#pragma omp target teams distribute parallel for map(to:data[:7])
  for (int i=0; i&amp;lt;n; i++) printf("data[%d] = %d\n", i, data[i]);

}

int main(int argc, char *argv[]){

  const unsigned int data[7] = {1,2,3,4,5,6,7};
  fn(data, 7);
  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;This will solve your problem of accessing constants array. Please try the code and let us know if it is working for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm Regards,&lt;/P&gt;
&lt;P&gt;Abhishek&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 12:09:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1192201#M6923</guid>
      <dc:creator>AbhishekD_Intel</dc:creator>
      <dc:date>2020-07-15T12:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Re:OpenMP offload quirk (maybe problem if mapping ...</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1192412#M6929</link>
      <description>&lt;P&gt;You're really not defining a global constant anymore, but that does remove the error.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 02:11:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1192412#M6929</guid>
      <dc:creator>CFR</dc:creator>
      <dc:date>2020-07-15T02:11:56Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP offload quirk (maybe problem if mapping ...</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1193524#M6947</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to access a global constant array then please change the backend to the OpenCL this will resolve your error and you can execute your code with a global constant array.&lt;/P&gt;
&lt;P&gt;Please set the following environment variable followed by compiling and running your application.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;export LIBOMPTARGET_PLUGIN=OPENCL&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And let us know if it resolves your issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm Regards,&lt;/P&gt;
&lt;P&gt;Abhishek&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 05:59:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1193524#M6947</guid>
      <dc:creator>AbhishekD_Intel</dc:creator>
      <dc:date>2020-07-20T05:59:15Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP offload quirk (maybe problem if mapping ...</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1194016#M6954</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please give us an update on your issue. We hope its resolved now.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Jul 2020 06:20:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1194016#M6954</guid>
      <dc:creator>AbhishekD_Intel</dc:creator>
      <dc:date>2020-07-22T06:20:09Z</dc:date>
    </item>
    <item>
      <title>Re:OpenMP offload quirk (maybe problem if mapping ...</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1194895#M6969</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As your issue is resolved we are closing this thread. Please post a new thread if you have any issues.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jul 2020 07:05:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-offload-quirk-maybe-problem-if-mapping-const-array/m-p/1194895#M6969</guid>
      <dc:creator>AbhishekD_Intel</dc:creator>
      <dc:date>2020-07-27T07:05:15Z</dc:date>
    </item>
  </channel>
</rss>

