1. 程式人生 > >linux下intel使用intel mpi(2)

linux下intel使用intel mpi(2)

1.任務排程支援
當使用Altair* PBS Pro*, TORQUE*, and OpenPBS*時:$PBS_ENVIRONMENT 設定為值 PBS_BATCH或者 PBS_INTERACTIVE
參考程式碼如下:

#PBS –l nodes=4:ppn=4 
#PBS –q queue_name cd $PBS_O_WORKDIR mpirun –n 16 ./myprog

當使用IBM* Platform LSF*時:
先設定$LSB_MCPU_HOSTS,並在其上新增上main processes的名稱,下面是一個執行例項:

$ bsub -n 16 mpirun -n
16 ./myprog

當使用Parallelnavi NQS*時:
完成設定

$ENVIRONMENT,  $QSUB_REQID, $QSUB_NODEINF
 $QSUB_NODEINF

這個檔案被作為 mpirun的machine file
當使用SLURM*時:
設定$SLURM_JOBID,

 $SLURM_TASKS_PER_NODE
 $SLURM_NODELIST

執行如下命令:

$ srun -N2 --nodelist=host1,host2 -A 
$ mpirun -n 2 ./myprog

當使用Univa* Grid Engine*時:
設定$PE_HOSTFILE:
這兩個會被生成

/tmp/sge_hostfile_${username}_$$ 
and /tmp/sge_machifile_${username}_$$

當使用SIGINT, SIGTERM Signals Intercepting時,
當資源呼叫超過上限時,一個訊號會向所有程序傳送來結束大多數的任務安排。
例如:Torque* 向一個任務傳送三遍SIGTERM ,假如這個任務還在活躍, 就會發送SIGKILL 來結束它。
用以下命令來看檢視所有的佇列:

$ qconf -sql

使用以下命令來修改佇列設定:

$ qconf -mq <queue_name>

找到terminate_method然後把訊號改成SIGTERM
關閉佇列設定
關於Controlling Per-Host Process Placement:
預設情況下,intel mpi使用per-host process placement,這意味著-ppn命令將無用。可以使用如下命令將其關閉,以可以通過-ppn命令來控制。

$ export I_MPI_JOB_RESPECT_PROCESS_PLACEMENT=off

Cross-OS Launch Mode:
你可以跨平臺的使用intel mpi通訊:
首先確保所有節點的intel mpi版本一致。
確保hydra服務被開啟,可以使用如下命令檢視:

> hydra_service -status

假如沒有開啟,可以使用-start選項開啟。
當執行一個跨平臺的任務時,進行如下設定:

-demux select
-genv I_MPI_FABRICS=shm:tcp
-host <hostname>
-hostos <os> for nodes operating on the other OS
-env I_MPI_ROOT and -env PATH – local environment variables for the specified host
(optional) -bootstrap ssh – specifies the remote node access mechanism. If the option is not specified, the Hydra service is used. If you specify ssh, make sure the SSH connectivity is established between the Linux and Windows nodes.

以下是一個示例:

$ mpirun -demux select -genv I_MPI_FABRICS=shm:tcp -env 
I_MPI_ROOT=<windows_installdir> \ 
-env PATH=<windows_installdir>\<arch>\bin -hostos windows -host <windows_host> -n 2 IMB-MPI1 pingpong :\ 
-host <linux_host> -n 3 <linux_installdir>/<arch>/bin/IMB-MPI1 pingpong

2.設定專案啟動選項:
設定library選項:
使用正確的引數執行mpivars.[c]sh指令碼,例如:

$ . <installdir>/bin64/mpivars.sh release

下面是引數表:
release
Set this argument to use single-threaded optimized library.
debug
Set this argument to use single-threaded debug library.
release_mt
Set this argument to use multi-threaded optimized library (default).
debug_mt
Set this argument to use multi-threaded debug library.
控制節點放置:
通過使用 -host你可以明確的指定節點的執行內容,通過使用-ppn你可以
確定每個節點的程序數。例如:

$ mpirun -n 4 -ppn 2 -hosts node1,node2 ./testc 
Hello world: rank 0 of 4 running on node1 
Hello world: rank 1 of 4 running on node1
Hello world: rank 2 of 4 running on node2 
Hello world: rank 3 of 4 running on node2

你也可以使用一個包含有相關資訊的host檔案來完成相關設定,使用-f來傳遞檔案資訊給mpirun,下面是示例:

$ cat ./hosts 
#nodes 
node1 
node2 
$ mpirun -n 4 -ppn 2 -f hosts ./testc

執行結果是:

$ mpirun -n 6 -hosts node1,node2 ./testc 
Hello world: rank 0 of 6 running on node1 
Hello world: rank 1 of 6 running on node1 
Hello world: rank 2 of 6 running on node1 
Hello world: rank 3 of 6 running on node1 
Hello world: rank 4 of 6 running on node2 
Hello world: rank 5 of 6 running on node2

運用引數表:
引數表間應當用冒號隔開,全域性變數應當最先出現,下面是一個示例:

$ mpirun -genv I_MPI_DEBUG=2 -host node1 -n 2 ./testc : -host node2 -n 2 ./testc

在設定檔案中,每個引數表應當在新的一行,全域性變數應該出現在第一行,下面是一個示例:

$ cat ./config 
-genv I_MPI_DEBUG=2 
-host node1 -n 2 ./testc 
-host node2 -n 2 ./testc

使用-configfile命令指定:

$ mpirun -configfile config 
Hello world: rank 0 of 4 running on node1 
Hello world: rank 1 of 4 running on node1 
Hello world: rank 2 of 4 running on node2 
Hello world: rank 3 of 4 running on node2

3.選擇通訊結構:
下面是相應的表格:
shm
Shared memory (for intra-node communication only).
dapl
Direct Access Programming Library* (DAPL)-capable network fabrics, such as InfiniBand* and iWarp* (through DAPL).
tcp
TCP/IP-capable network fabrics, such as Ethernet and InfiniBand* (through IPoIB*).
tmi
Tag Matching Interface (TMI)-capable network fabrics, such as Intel® True Scale Fabric, Intel® Omni-Path Architecture and Myrinet* (through TMI).
ofa
OpenFabrics Alliance* (OFA)-capable network fabrics, such as InfiniBand* (through OFED* verbs).
ofi
OpenFabrics Interfaces* (OFI)-capable network fabrics, such as Intel® True Scale Fabric, Intel® Omni-Path Architecture, InfiniBand* and Ethernet (through OFI API).
使用I_MPI_FABRICS變數來指定一個通訊結構,另外還有控制變數比如I_MPI_FABRICS_LIST and I_MPI_FALLBACK,這個會在之後的部落格提到。
預設的行為:
使用共享記憶體,並從結構表中選擇最前面且可用的結構方式,結構表一般為(dapl,ofa,tcp,tmi,ofi),也可以看I_MPI_FABRICS_LIST。
我們可以通過設定I_MPI_DEBUG=2檢視使用了哪種結構。
例如:

$ mpirun –n 4 –ppn 2 –hosts <node1>,<node2> -genv I_MPI_DEBUG=2 ./myprog ... MPI startup(): shm and dapl data transfer modes

設定結構列表:
使用I_MPI_FABRICS_LIST變數,例如:

$ export I_MPI_FABRICS_LIST=ofi,tcp 
$ mpirun –n 4 –ppn 2 –hosts <node1>,<node2> ./myprog

你也可以直接指定intra-node和inter-node(節點內部和外部)通訊,語法為:

I_MPI_FABRICS=<fabric>|<intra-node fabric>:<inter-node fabric>

如果你只指定了

<fabric>

那麼指定的內容會被用於節點內外。
例如如下設定:

$ export I_MPI_FABRICS=shm:tcp 
$ mpirun –n 4 –ppn 2 –hosts <node1>,<node2> ./myprog

節點內為shared memery,節點外為tcp
如果你設定為:

$ export I_MPI_FABRICS=tcp

節點內外均為tcp