- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
When testing offload computation to intel GPU with OpenMP, I obtain a segmentation fault at execution with this code :
int main() { const int N=350000; double a; double b ; double c ; // double *a = new double ; // double *b = new double ; // double *c = new double ; for (int i=0; i<N; i++) { a = i; b = 1./i; } #pragma omp target data map(to:a,b) map(from:c) // #pragma omp target data map(to:a[0:N],b[0:N]) map(from:c[0:N]) { #pragma omp target teams distribute parallel for simd for (int i=0; i<N; i++) { c = a+b; } } // delete[] a; // delete[] b; // delete[] c; return 0; }
The error does not happen if I take N=300000 or if I use pointers instead of arrays (use of commented lines). With pointers it works even with N=100000000 (not tested above).
When looking with gdb, segmentation fault happens at line 12, but I cannot access exact value i, even with -O0.
My configuration :
- Gentoo Linux
- CPU i5-7300U with HD Graphics 620
- oneAPI HPC Toolkit 2021.1 beta06
- neo-20.16.16582
- intel-graphics-compiler-1.0.3826
- level-zero-0.91.10
- I used "-qnextgen -fiopenmp -fopenmp-targets=spir64" for compilation
Thanks,
Sylvain
- Tags:
- General Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sylvain,
We tried the code given by you and it is not giving segfault if I take N=300000. But we observe segfault if we take N>500000, and it is oblivious as it is exceeding maximum stack size for us. Whereas for the pointer (commented part of your code) it will work without segfault for N=100000000 as it is using heap instead of the stack.
If you want to check the stack size you can use ulimit -a command and you will get the reason for segfault.
If you use gdb you will definitely get a segfault on line 12(of your code) but if you try something like below code snippet :
const int N=600000; double a; double b ; // double c ; for (int i=0; i<N; i++) { a = i; b = 1./i; } std::cout<<"here\n"; double c ;
In the above case, we will see that you will get segfault after "std::cout" as stack size is exceeding after std::cout statement.
So if you have a requirement of large size array then we will recommend you use dynamic memory allocation instead of using stack.
I hope this helps. Do let us know if your issue is resolved.
Warm Regards,
Abhishek
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sylvain,
We tried the code given by you and it is not giving segfault if I take N=300000. But we observe segfault if we take N>500000, and it is oblivious as it is exceeding maximum stack size for us. Whereas for the pointer (commented part of your code) it will work without segfault for N=100000000 as it is using heap instead of the stack.
If you want to check the stack size you can use ulimit -a command and you will get the reason for segfault.
If you use gdb you will definitely get a segfault on line 12(of your code) but if you try something like below code snippet :
const int N=600000; double a; double b ; // double c ; for (int i=0; i<N; i++) { a = i; b = 1./i; } std::cout<<"here\n"; double c ;
In the above case, we will see that you will get segfault after "std::cout" as stack size is exceeding after std::cout statement.
So if you have a requirement of large size array then we will recommend you use dynamic memory allocation instead of using stack.
I hope this helps. Do let us know if your issue is resolved.
Warm Regards,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sylvain,
Please confirm if your issue has been resolved so that we can close the thread.
You can always post a new thread if you face any issue.
Warm Regards,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Sylvain for the conformation we are closing this thread.
You can always post a new thread if you face any issue.
Warm Regards,
Abhishek
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page