如何使用mpirun将不同的CPU内核用于不同的程序? [英] How to use mpirun to use different CPU cores for different programs?

查看:1127
本文介绍了如何使用mpirun将不同的CPU内核用于不同的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个32核的虚拟机. 我正在运行一些仿真,我需要一次使用16个内核.

I have a virtual machine with 32 cores. I am running some simulations for which I need to utilize 16 cores at one time.

我使用以下命令在16个内核上运行作业:

I use the below command to run a job on 16 cores :

mpirun -n 16 程序名称 args > log.out 2>& 1

mpirun -n 16 program_name args > log.out 2>&1

该程序在16个内核上运行.

This program runs on 16 cores.

现在,如果我想在其余内核上使用不同的参数运行相同的程序,则可以使用相同的命令,例如

Now if I want to run the same programs on the rest of the cores, with different arguments, I use the same command like

mpirun -n 8 程序名称 diff_args > log_1.out 2>& 1

mpirun -n 8 program_name diff_args > log_1.out 2>&1

第二个过程使用与之前相同的16个内核. 如何使用mpirun在8个不同的内核上运行此过程,而不是在第一个作业使用的16个内核上运行.

The second process utilizes the same 16 cores that were utilized earlier. How can use mpirun to run this process on 8 different cores, not the previous 16 that first job was using.

我正在使用无头Ubuntu 16.04.

I am using headless Ubuntu 16.04.

推荐答案

Open MPI的启动器支持通过--cpu-set选项限制CPU集.它接受一组表示为形式为s0,s1,s2,...的列表的逻辑CPU,其中每个列表条目都是某个CPU n-m范围内的单个逻辑CPU编号.

Open MPI's launcher supports restricting the CPU set via the --cpu-set option. It accepts a set of logical CPUs expressed as a list of the form s0,s1,s2,..., where each list entry is either a single logical CPU number of a range of CPUs n-m.

提供了VM中逻辑CPU的连续编号,您要做的是:

Provided that the logical CPUs in your VM are numbered consecutively, what you have to do is:

mpirun --cpu-set  0-15 --bind-to core -n 16 program_name args > log.out 2>&1
mpirun --cpu-set 16-23 --bind-to core -n  8 program_name diff_args > log_1.out 2>&1

--bind-to core告诉Open MPI在遵守--cpu-set参数中提供的CPU集的同时,将进程绑定到每个单独的内核.

--bind-to core tells Open MPI to bind the processes to separate cores each while respecting the CPU set provided in the --cpu-set argument.

使用诸如lstopo(Open MPI的hwloc库的一部分)之类的工具来获取系统的拓扑可能会有所帮助,这有助于选择正确的CPU编号,例如,防止绑定到超线程,尽管这在虚拟化环境中意义不大.

It might be helpful to use a tool such as lstopo (part of the hwloc library of Open MPI) to obtain the topology of the system, which helps in choosing the right CPU numbers and, e.g., prevents binding to hyperthreads, although this is less meaningful in a virtualised environment.

(请注意,lstopo使用一种混乱的命名约定,并将OS逻辑CPU称为 physical ,因此请在(P#n)条目中查找数字.lstopo -p隐藏hwloc逻辑并避免混淆.)

(Note that lstopo uses a confusing naming convention and calls the OS logical CPUs physical, so look for the numbers in the (P#n) entries. lstopo -p hides the hwloc logical numbers and prevents confusion.)

这篇关于如何使用mpirun将不同的CPU内核用于不同的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆