- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Lenovo T570, Ubuntu 18.04.4, icpc (ICC) 2021.1 Beta 20200602
user@t570:~/OneAPI/OMP$ cat bug2.cpp
#include <omp.h>
#include <cstdio>
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<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)
If "data" in not declared "const" then things are fine:
user@t570:~/OneAPI/OMP$ cat bug2.cpp
#include <omp.h>
#include <cstdio>
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<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
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. (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.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
#include <omp.h>
#include <cstdio>
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<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;
}
This will solve your problem of accessing constants array. Please try the code and let us know if it is working for you.
Warm Regards,
Abhishek
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
#include <omp.h>
#include <cstdio>
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<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;
}
This will solve your problem of accessing constants array. Please try the code and let us know if it is working for you.
Warm Regards,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're really not defining a global constant anymore, but that does remove the error.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
Please set the following environment variable followed by compiling and running your application.
export LIBOMPTARGET_PLUGIN=OPENCL
And let us know if it resolves your issue.
Warm Regards,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please give us an update on your issue. We hope its resolved now.
Warm Regards,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As your issue is resolved we are closing this thread. Please post a new thread if you have any issues.
Thank you
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page