2017-10-11 211 views
0

我有一個MPI程序,我想在30個節點上運行(每個節點有32個內核)。我如何將一個節點的所有內核分配給單個作業/進程?如何將單個節點的多個內核分配給MPI羣集中的單個作業/進程?

我正在使用插槽來限制特定節點的作業數量。 node001 slots = 1 max_slots = 20 node002 slots = 1 max_slots = 20

是否有任何參數可用於實現此目的?

在此先感謝。

+0

歡迎使用stackoverflow!如果您正在使用像[Slurm](https://slurm.schedmd.com/sbatch.html)這樣的工作管理器,那麼命令'sbatch'功能選項'--exclusive'可能會有所幫助,但其他用戶可能會哭泣。對於PBS's'sub',有與'node-exclusive'對應的選項'-n'。你的集羣上有工作經理嗎?如果你一個人在集羣上,並且如果你直接運行'mpirun',使用不同的主機文件,那麼指定maxslots可以做到這一點。查看[mpirun]的'--bynode'選項(https://www.open-mpi.org/faq/?category=running#mpirun-hostfile)。 – francis

+0

我沒有使用任何工作管理器,我用普通的mpirun和hostfile運行它。我想要一個節點的一個插槽,所以我在hostfile中提到了「slots = 1」。我希望這個插槽能夠使用該節點中的所有CPU。如果我們使用--bynode選項,它以循環方式分配作業。有沒有選擇明確分配CPU /資源?謝謝。 –

回答

1

使用openmpi,您可以使用選項--rankfile來顯式設置等級。

文件的語法可以在這裏找到:https://www.open-mpi.org/doc/v2.0/man1/mpirun.1.php^

這是一個非常簡單的MPI + OpenMP程序:

#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <sched.h> 
#include <mpi.h> 
#include <omp.h> 

void main(int argc, char** argv) 
{ 
    MPI_Init(&argc, &argv); 
    unsigned cpu; 
    unsigned node; 

    int rank; 
    MPI_Comm_rank(MPI_COMM_WORLD, &rank); 
    #pragma omp parallel 
    { 
     printf("[%d:%d] %d\n", rank, omp_get_thread_num(), sched_getcpu()); 
    } 
    MPI_Finalize(); 
} 

它打印[MPI_rank:OMP_rank] CPU在各個OpenMP的線程。

爲rankfiles的基本格式是:

rank <rank>=<host> slot=<slot>:<cores> 

有了這些基本rankfile(主機=馬文,2CPU上一個時隙):

>cat ./rankfile 
rank 0=Marvin slot=0:0 
rank 1=Marvin slot=0:0 
rank 2=Marvin slot=0:0 
rank 3=Marvin slot=0:1 
rank 4=Marvin slot=0:0-1 
rank 5=Marvin slot=0:0 

這是我的打印:

>mpirun -n 6 --rankfile ./rankfile ./main 
[0:0] 0 
[1:0] 0 
[2:0] 0 
[3:0] 1 
[4:0] 1 
[4:1] 0 
[5:0] 0 

我沒有設置OMP_NUM_THREADS環境變量,以便讓OpenMP檢測每個可用的核心數量秩。

希望這可以幫到你

+0

你能用一個例子來解釋你的答案嗎? –

+0

謝謝,這對我有幫助。 –

相關問題