[Openmp-dev] Segmentation fault libomptarget.so
Talita Perciano via Openmp-dev
openmp-dev at lists.llvm.org
Tue Feb 12 13:33:49 PST 2019
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20190212/5c0143b8/attachment.html>
More information about the Openmp-dev
mailing list