[Openmp-dev] Segmentation fault libomptarget.so

Talita Perciano via Openmp-dev openmp-dev at lists.llvm.org
Tue Feb 12 13:38:37 PST 2019


Thanks for your quick response Alexey. I've just tried what you suggested
and I'm still getting the same error.

Best,
Talita

On Tue, Feb 12, 2019 at 1:36 PM Alexey Bataev <a.bataev at outlook.com> wrote:

> Try to modify target pragma this way
>
> #pragma omp target map(from: x[:n]) map(tofrom:y[:n])
>
> -------------
> Best regards,
> Alexey Bataev
>
> 12.02.2019 16:33, Talita Perciano via Openmp-dev пишет:
>
> Hi,
>
> I'm trying openmp offloading to gpu and I'm getting a segfault when trying
> to run a test code. I followed the instructions explained here
> https://www.hahnjo.de/blog/2018/10/08/clang-7.0-openmp-offloading-nvidia.html
> .
>
> Here is the piece of code I'm trying to run:
>
> #include <malloc.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char* argv[])
> {
>     if (argc != 2)
>     {
>         printf("Usage: %s \n", argv[0]);
>         return 0;
>     }
>
>     int n = atoi(argv[1]);
>
>     double* x = (double*)malloc(sizeof(double) * n);
>     double* y = (double*)malloc(sizeof(double) * n);
>
>     double idrandmax = 1.0 / RAND_MAX;
>     double a = idrandmax * rand();
>     for (int i = 0; i < n; i++)
>     {
>         x[i] = idrandmax * rand();
>         y[i] = idrandmax * rand();
>     }
>     printf("Here\n\n");
>     #pragma omp target
>     #pragma omp parallel for
>     {
>         for (int i = 0; i < n; i++)
>             y[i] += a * x[i];
>     }
>
>     double avg = 0.0, min = y[0], max = y[0];
>     for (int i = 0; i < n; i++)
>     {
>         avg += y[i];
>         if (y[i] > max) max = y[i];
>         if (y[i] < min) min = y[i];
>     }
>
>     printf("min = %f, max = %f, avg = %f\n", min, max, avg / n);
>
>     free(x);
>     free(y);
>
>     return 0;
> }
>
> I'm compiling the code like this: clang -fopenmp -fopenmp-targets=nvptx64
> -O2 example.c
> When I run I get a Segmentation fault immediately.
>
> Any thoughts?
>
> Thanks!
> Talita
>
>
> _______________________________________________
> Openmp-dev mailing listOpenmp-dev at lists.llvm.orghttps://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev
>
>

-- 
Dr. Talita Perciano
Research Scientist - CRD, Lawrence Berkeley National Laboratory
Data Analytics & Visualization Group
Center for Advanced Mathematics for Energy Research Applications
One Cyclotron Road
Berkeley, CA 94720
059-3034B  M/S 59R3103
Work: (510) 486-5060
tperciano at lbl.gov
http://tperciano.wixsite.com/home
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190212/4f3a57b6/attachment.html>


More information about the Openmp-dev mailing list