我正在使用建模工具箱Anuga,并将其设置为在parallel支持下运行。据我目前所知,其背后的机制是Numpy被C中的模块extended通过OpenMP公开
extra_args = ['-fopenmp']
我已经开发并测试了一个脚本来运行mpirun -np 4 python <myscript.py>
,它可以正常工作。由于模型越来越大,我的兴趣是通过OpenMP将一些处理转移到物理形式的nvidiagpu上。我听说这叫做卸载。我安装了一个Quadro K2000
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.56 Driver Version: 418.56 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Quadro K2000 Off | 00000000:01:00.0 On | N/A |
| 32% 48C P8 N/A / N/A | 403MiB / 1999MiB | 4% Default |
+-------------------------------+----------------------+----------------------+
所以我
在我的ubuntu19.04上安装了gcc-offload-nvptx
,它读取gcc的版本8。然后我
将编译器标志更改为
extra_args = ['-fopenmp', '-fstack-protector']
以及
python setup.py build
编译安装。这将为目标模块cg_ext.c
返回以下消息,而不会出现任何进一步的错误:x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-rzpqx3/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-rzpqx3/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/anuga/utilities/cg_ext.o -Lbuild/temp.linux-x86_64-2.7 -o build/lib.linux-x86_64-2.7/anuga/utilities/cg_ext.so -fopenmp -fstack-protector
什么时候
ldd
检查编译过的库build/lib.linux-x86_64-2.7/anuga/utilities/cg_ext.so linux-vdso.so.1 (0x00007fff7a9fa000) libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f0650502000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0650317000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0650311000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f06502f0000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0650606000)
所以我想一切都设置正确了。我现在转到
之前:
void cg_daxpy(int N, double a, double *x, double *y)
{
int i;
#pragma omp parallel for private(i)
for(i=0;i<N;i++)
{
y[i]=y[i]+a*x[i];
}
}
之后:
void cg_daxpy(int N, double a, double *x, double *y)
{
int i;
#pragma omp target device(0)
{
#pragma omp parallel for
for(i=0;i<N;i++)
{
y[i]=y[i]+a*x[i];
}
}
}
然后,我重新编译一个安装并按以下方式运行脚本,希望获得分析信息:
nvprof --print-gpu-trace --profile-child-processes --profile-from-start off -fo %p.nvprof python -m cProfile runDamBreak.py
这将返回消息
==19444== Profiling application: orted --hnp --set-sid --report-uri 14 --singleton-died-pipe 15 -mca state_novm_select 1 -mca ess hnp -mca pmix ^s1,s2,cray,isolated
==19444== Profiling result:
No kernels were profiled.
总之,我知道pragma被编译器理解了,但是没有段被发送到GPU。任何关于如何进一步调试的提示都将不胜感激。你知道吗
致以最诚挚的问候
塞巴斯蒂安
目前没有回答
相关问题 更多 >
编程相关推荐