2

我有一个 C/C++ 中的 Python 扩展,我想使用 OpenMP 卸载。使用 NVIDIA 的 nvc++,编译和在 python 中使用/运行扩展一样有效。问题在于它默认不使用 GPU。设置 $OMP_OFFLOAD_TARGET=MANDATORY 会导致以下错误:

 
(venv) bash-4.2$ python test_2d_c.py
2D (dependend) :
Fatal error: Could not run target region on device 0, execution terminated.

在纯 C/C++ 版本中使用相同的 OpenMP 指令效果很好。

顺便说一句,编译期间的输出看起来很有希望:

 
nvc++ -Iinclude -I/software/rome/SciPy-bundle/2021.05-foss-2021a/lib/python3.9/site-
packages/numpy/core/include -I/home/h0/seth295c/cmi/venv/include -
I/sw/installed/Python/3.9.5-GCCcore-10.3.0/include/python3.9 -c src/gamma_c.cpp -o
build/temp.linux-x86_64-3.9/src/gamma_c.o -g -O3 -shared -std=c++17 -Minfo=mp -mp=gpu -
mp -target=gpu
cmi::gamma_c_2d_naive(_object *, _object *):
     97, #omp target teams distribute parallel for
kernel
97, Generating "nvkernel__ZN3cmi16gamma_c_2d_naiveEP7_objectS1__F1L97_1" GPU
    Generating Tesla and Multicore code
    Generating reduction(+:res,.res22168p)
    Loop parallelized across teams and threads(128), schedule(static)
cmi::gamma_c_2d(_object *, _object *):
    228, #omp parallel
    240, #omp parallel
        240, Generating reduction(+:res)
cmi::gamma_c_2d_independence(_object *, _object *):
    338, #omp parallel
    350, #omp parallel
        350, Generating reduction(+:res)
4

0 回答 0