Openacc错误ibgomp:加载libgomp-plugin-host_nonshm.so.1时:libgomp-plugin-host_nonshm.so.1:不能

时间:2015-06-17 06:35:21

标签: openacc libgomp

我想编译一个简单的openacc示例(它被附加),它被正确编译但是当我运行时出现错误:

  1. 编译:gcc-5 -fopenacc accVetAdd.c -lm
  2. 以:./a.out
  3. 运行
  4. 运行时出错
  5.   

    错误: libgomp:加载libgomp-plugin-host_nonshm.so.1时:libgomp-plugin-host_nonshm.so.1:无法打开共享对象文件:没有这样的文件或目录

    我google它,只找到一页!然后我问如何解决这个问题?

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    int main(int argc, char* argv[])
    {
        // Size of vectors
        int n = 10000;
    
        // Input vectors
        double *restrict a;
        double *restrict b;
        // Output vector
        double *restrict c;
    
        // Size, in bytes, of each vector
        size_t bytes = n*sizeof(double);
    
        // Allocate memory for each vector
        a = (double*)malloc(bytes);
        b = (double*)malloc(bytes);
        c = (double*)malloc(bytes);
    
        // Initialize content of input vectors, vector a[i] = sin(i)^2 vector b[i] = cos(i)^2
        int i;
        for (i = 0; i<n; i++) {
            a[i] = sin(i)*sin(i);
            b[i] = cos(i)*cos(i);
        }
    
        // sum component wise and save result into vector c
        #pragma acc kernels copyin(a[0:n],b[0:n]), copyout(c[0:n])
        for (i = 0; i<n; i++) {
            c[i] = a[i] + b[i];
        }
        // Sum up vector c and print result divided by n, this should equal 1 within error
        double sum = 0.0;
        for (i = 0; i<n; i++) {
            sum += c[i];
        }
        sum = sum / n;
        printf("final result: %f\n", sum);
    
        // Release memory
        free(a);
        free(b);
        free(c);
        return 0;
    }
    

1 个答案:

答案 0 :(得分:1)

libgomp动态加载它支持的插件的共享对象文件,例如实现 host_nonshm 设备的插件。如果它们安装在非标准目录中(即不在系统的默认搜索路径中),则需要告诉动态链接器在哪里查找这些共享对象文件:使用-Wl,-rpath,[...]进行编译,或者设置LD_LIBRARY_PATH环境变量。