linux 下使用intel mpi 进阶

来源:互联网 发布:淘宝微淘在哪 编辑:程序博客网 时间:2024/06/05 19:20

1.统计与分析
设置I_MPI_DEBUG变量,变量的默认值为0,你可以设置0-1000间的值,值越高,获得的debug信息越多,下面是一个示例:

$ mpirun -genv I_MPI_DEBUG=2 -n 2 ./testc [0] MPI startup(): Multi-threaded optimized library [0] MPI startup(): shm data transfer mode [1] MPI startup(): shm data transfer mode [1] MPI startup(): Internal info: pinning initialization was done [0] MPI startup(): Internal info: pinning initialization was done

注意输出debug会显著的降低性能,比较推荐的是I_MPI_DEBUG=5,可以获得常用的信息。
设置输出信息:
默认情况下,每一行(也是每一个输出信息)包含MPI rank和message,你也可以输出额外的信息,比如process ID, time, host name等,或者剔除某些信息,你可以使用以下两种方法:

Add the '+' sign in front of the debug level number. In this case, each line is prefixed by the string <rank>#<pid>@<hostname>.For example: $ mpirun -genv I_MPI_DEBUG=+2 -n 2 ./testc [0#3520@clusternode1] MPI startup(): Multi-threaded optimized libraryTo exclude any information printed in front of the message, add the '-' sign in a similar manner
Add the appropriate flag after the debug level number to include or exclude some information. For example, to include time but exclude the rank number: $ mpirun -genv I_MPI_DEBUG=2,time,norank -n 2 ./testc 11:59:59 MPI startup(): Multi-threaded optimized library

如果想改变debug信息的输出模式(默认是stdout),可以修改I_MPI_DEBUG_OUTPUT的值,例如:

$ mpirun -genv I_MPI_DEBUG=2 -genv I_MPI_DEBUG_OUTPUT=/tmp/debug_output.txt -n 2 ./testc

获得统计数据:
mpi支持收集以下两种统计数据:Native statistics和IPM statistics
你可以同时收集两种数据,也可以只收集其中的一种(通过设置I_MPI_STATS的值),另外还有一些其他的环境变量,将在以后的博客中介绍。
如果需要统计native statistics,需要把I_MPI_STATS的值设置为数字类型,以确定收集的等级,可选择的值为1, 2, 3, 4, 10 或者 20,例如:

$ export I_MPI_STATS=10

也可以指定一个范围,例如:

$ export I_MPI_STATS=4-10

你也可以修改输出文件,默认为stats.txt

$ export I_MPI_STATS_FILE=stats_initial.txt

你也可以设定为为某个特定的mpi操作收集统计数据,通过设置I_MPI_STATS_SCOPE来完成这个目的,例如:

$ export I_MPI_STATS=20 $ export I_MPI_STATS_SCOPE="p2p;coll:bcast,reduce"

使用I_MPI_STATS_BUCKETS设定特定的大小,单位bytes,例如:

$ export I_MPI_STATS_BUCKETS=0-1000,50000-100000

一般认为0-1000bytes属于短信息,50k-100kbytes属于长信息
假如要收集长度为16bytes的信息,并且满足信息存在于四个通信中,可以设置为:

$ export I_MPI_STATS_BUCKETS="16@4"

假如要统计IPM 统计数据:
设置I_MPI_STATS,当值为ipm:terse只统计简短的,当值为ipm统计完整的。
例如:

$ export I_MPI_STATS=ipm

默认输出文件为stats.ipm,你也可以通过修改I_MPI_STATS_FILE的值来修改它。
你可以使用I_MPI_STATS_ACCURACY来减少输出。例如跳过占用时间少于3%的操作,如下:

$ export I_MPI_STATS=ipm $ export I_MPI_STATS_ACCURACY=3

假如你要同时收集native和IPM统计数据,如下:

$ export I_MPI_STATS=all

此时相当于命令

I_MPI_STATS=native:20,ipm

你也可以修改它来记录不同的统计数据,例如:

$ export I_MPI_STATS=native:2-10,ipm:terse

2.范围控制:
你可以控制特定收集的统计数据:
例如:

/* open "reduce" region for all processes */ MPI_Pcontrol(1, "reduce"); for (i = 0; i < 1000; i++)     MPI_Reduce(&nsend, &nrecv, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);/* close "reduce" region */ MPI_Pcontrol(-1, "reduce");

1表示打开,-1表示关闭
收集到的信息,假如是native,则放在独立的文件:

stats_<name>.txt

如果是IPM,则在标记后:

########################################################## # region : reduce [ntasks] = 4 #

范围包括:
1.不连续
2.分割
3.涉及进程子集
但不包括:
Main region – contains statistics information about all MPI calls from MPI_Init to MPI_Finalize. The main region gets the “*” name in the IPM statistics output. The native statistics output for this region is stats.txt by default.
Complementary region – contains statistics information not included into any named region. The region gets the “ipm_noregion” name in the IPM statistics output. The default output file for this region is stats_noregion.txt for the native statistics format.

原创粉丝点击