cuda - 多 GPU 分析(多个 CPU,MPI/CUDA 混合)

标签 cuda gpu mpi profiling nvidia

我在论坛上快速浏览了一下,我认为已经没有人问过这个问题了。

我目前正在使用其他人在他博士期间制作的 MPI/CUDA 混合代码。
每个 CPU 都有自己的 GPU。
我的任务是通过运行(已经可以工作的)代码来收集数据,并实现额外的东西。
将此代码转换为单个 CPU/多 GPU 代码目前不是一种选择(以后可能)。

我想利用性能分析工具来分析整个事情。

目前的想法是让每个 CPU 为其自己的 GPU 启动 nvvp 并收集数据,而另一个分析工具将处理一般的 CPU/MPI 部分(我计划像往常一样使用 TAU)。

问题是,同时启动 nvvp 的界面 8 次(如果使用 8 个 CPU/GPU 运行)非常烦人。我想避免通过界面,并获得一个直接将数据写入文件的命令行,我可以稍后将其提供给 nvvc 的界面并进行分析。

我想获得一个命令行,该命令行将由每个 CPU 执行,并为每个 CPU 生成一个文件,提供有关他们自己的 GPU 的数据。 8(GPU/CPU)= 8 个文件。
然后我打算用nvcc逐个feed和分析这些文件,手动比较数据。

任何的想法 ?

谢谢 !

最佳答案

看看nvprof ,部分 CUDA 5.0 Toolkit (目前可作为候选版本)。有一些限制 - 它只能在给定的传递中收集有限数量的计数器,并且不能收集指标(因此,现在如果您想要多个事件,则必须编写多次启动的脚本)。您可以从 nvvp 内置帮助中获取更多信息,包括示例 MPI 启动脚本(复制到此处,但如果您有比 5.0 RC 更新的版本,我建议您查看 nvvp 帮助以获取最新版本)。

#!/bin/sh
#
# Script to launch nvprof on an MPI process.  This script will
# create unique output file names based on the rank of the 
# process.  Examples:
#   mpirun -np 4 nvprof-script a.out 
#   mpirun -np 4 nvprof-script -o outfile a.out
#   mpirun -np 4 nvprof-script test/a.out -g -j
# In the case you want to pass a -o or -h flag to the a.out, you
# can do this.
#   mpirun -np 4 nvprof-script -c a.out -h -o
# You can also pass in arguments to nvprof
#   mpirun -np 4 nvprof-script --print-api-trace a.out
#

usage () {
 echo "nvprof-script [nvprof options] [-h] [-o outfile] a.out [a.out options]";
 echo "or"
 echo "nvprof-script [nvprof options] [-h] [-o outfile] -c a.out [a.out options]";
}

nvprof_args=""
while [ $# -gt 0 ];
do
    case "$1" in
        (-o) shift; outfile="$1";;
        (-c) shift; break;;
        (-h) usage; exit 1;;
        (*) nvprof_args="$nvprof_args $1";;
    esac
    shift
done

# If user did not provide output filename then create one
if [ -z $outfile ] ; then
    outfile=`basename $1`.nvprof-out
fi

# Find the rank of the process from the MPI rank environment variable
# to ensure unique output filenames.  The script handles Open MPI
# and MVAPICH.  If your implementation is different, you will need to
# make a change here.

# Open MPI
if [ ! -z ${OMPI_COMM_WORLD_RANK} ] ; then
    rank=${OMPI_COMM_WORLD_RANK}
fi
# MVAPICH
if [ ! -z ${MV2_COMM_WORLD_RANK} ] ; then
    rank=${MV2_COMM_WORLD_RANK}
fi

# Set the nvprof command and arguments.
NVPROF="nvprof --output-profile $outfile.$rank $nvprof_args" 
exec $NVPROF $*

# If you want to limit which ranks get profiled, do something like
# this. You have to use the -c switch to get the right behavior.
# mpirun -np 2 nvprof-script --print-api-trace -c a.out -q  
# if [ $rank -le 0 ]; then
#     exec $NVPROF $*
# else
#     exec $*
# fi

关于cuda - 多 GPU 分析(多个 CPU,MPI/CUDA 混合),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12044928/

相关文章:

我可以从 CUDA __global__ 函数调用头文件中的 "function-like macro"吗?

qt - TI J6 : How to find if my application is using GPU

c - MPI_收集接收缓冲区中的垃圾 (MPI+C)

cuda - 默认固定内存与零拷贝内存

cuda - 是否可以通过编程方式确定 CUDA 分析器是否正在运行?

ios - Metal IOS 简单直通计算内核在 iphone 5s 上需要 10 毫秒

c++ - cuda内存带宽计算

c - MPI_Isend 段错误

python-3.x - 如何在 python 中使用 mpi4py 库连接收集的数据

c++ - cudaMalloc 问题和 "out of memory"错误