GCC中的OpenMP 4.0:卸载到nVidia GPU

时间:2015-03-27 09:55:50

标签: gcc cuda openmp gpgpu nvidia

TL; DR - GCC(主干)是否已支持OpenMP 4.0卸载到nVidia GPU?

如果是这样,我做错了什么? (以下描述)。


我正在运行 Ubuntu 14.04.2 LTS

我查看了最近的 GCC主干(2015年3月25日)。

我已根据Getting Started on Ubuntu指南安装了 CUDA 7.0 工具包。 CUDA样本成功运行,即deviceQuery检测到我的GeForce GT 730。

我已按照https://gcc.gnu.org/wiki/Offloading以及https://gcc.gnu.org/install/specific.html#nvptx-x-none

的说明进行操作

我已安装 nvptx-tools nvptx-newlib configuremakesudo make install),newlib也已关联在GCC的主干目录中使用ln -s

然后我构建了目标加速器nvptx-none 编译器:

../../trunk/configure --target=nvptx-none --enable-as-accelerator-for=x86_64-pc-linux-gnu --with-build-time-tools=/usr/local/nvptx-none/bin --disable-sjlj-exceptions --enable-newlib-io-long-long
make -j 9
sudo make install DESTDIR=/install

...和主机GCC 编译器本身:

../trunk/configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --enable-offload-targets=nvptx-none=/install/prefix --with-cuda-driver=/usr/local/cuda --enable-languages=c,c++
make -j 9
sudo make install DESTDIR=/install

我已相应地设置 LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/install/usr/local/lib64:/install/usr/local/lib/gcc/nvptx-none/5.0.0/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH

当然,构建了 mkoffload 工具:

/install/usr/local/libexec/gcc/x86_64-pc-linux-gnu/5.0.0/accel/nvptx-none/mkoffload

目标和主机编译器也在那里:

/install/usr/local/bin/x86_64-pc-linux-gnu-gcc
/install/usr/local/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc

但是,当我编译一个查询带有omp_get_num_devices()的设备数量的示例代码时,我得到了响应0

$ /install/usr/local/bin/x86_64-pc-linux-gnu-gcc -fopenmp -foffload=nvptx-none main.c
$ ./a.out
0

当我向目标编译器选项添加-v(详细)选项时,我得到以下输出:

$ /install/usr/local/bin/x86_64-pc-linux-gnu-gcc -fopenmp -foffload=nvptx-none="-v" main.c

Using built-in specs.
COLLECT_GCC=/install/usr/local/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc
Target: nvptx-none
Configured with: ../../trunk/configure --target=nvptx-none --enable-as-accelerator-for=x86_64-pc-linux-gnu --with-build-time-tools=/usr/local/nvptx-none/bin --disable-sjlj-exceptions --enable-newlib-io-long-long
Thread model: single
gcc version 5.0.0 20150325 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-m64' '-S' '-fmath-errno' '-fsigned-zeros' '-ftrapping-math' '-fno-trapv' '-fno-strict-overflow' '-fno-openacc' '-foffload-abi=lp64' '-fopenmp' '-v' '-v' '-o' '/tmp/cccxIggp.mkoffload'
 /install/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/5.0.0/accel/nvptx-none/lto1 -quiet -dumpbase ccKOW9hi.o -m64 -auxbase-strip /tmp/cccxIggp.mkoffload -version -fmath-errno -fsigned-zeros -ftrapping-math -fno-trapv -fno-strict-overflow -fno-openacc -foffload-abi=lp64 -fopenmp -o /tmp/cccxIggp.mkoffload @/tmp/ccjRDWhp
GNU GIMPLE (GCC) version 5.0.0 20150325 (experimental) (nvptx-none)
    compiled by GNU C version 5.0.0 20150325 (experimental), GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU GIMPLE (GCC) version 5.0.0 20150325 (experimental) (nvptx-none)
    compiled by GNU C version 5.0.0 20150325 (experimental), GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
COMPILER_PATH=/install/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/5.0.0/accel/nvptx-none/:/install/usr/local/bin/../libexec/gcc/
LIBRARY_PATH=/install/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/5.0.0/accel/nvptx-none/:/install/usr/local/bin/../lib/gcc/
COLLECT_GCC_OPTIONS='-m64' '-S' '-fmath-errno' '-fsigned-zeros' '-ftrapping-math' '-fno-trapv' '-fno-strict-overflow' '-fno-openacc' '-foffload-abi=lp64' '-fopenmp' '-v' '-v' '-o' '/tmp/cccxIggp.mkoffload'

因此看起来工具链被调用并且创建了.mkoffload个文件。

请帮忙。如果它应该工作,我怎么能诊断出错?

1 个答案:

答案 0 :(得分:14)

  

TL; DR - GCC(主干)是否已经支持OpenMP 4.0卸载到nVidia GPU?

没有

目前GCC仅支持将OpenMP 4.0卸载到Intel Xeon Phi(KNL)和OpenACC 2.0卸载到nVidia GPU。

有关于支持OpenMP 4.0卸载到nVidia GPU的想法:[1][2],但实施尚未开始。

UPD 2017: GCC 7.1现在支持将OpenMP 4.5卸载到NVidia GPU [3]