在群集节点上显式分发MPI进程

时间:2016-02-19 08:48:49

标签: c mpi distributed-computing openmpi mpich

我的MPI程序由一个主进程组成,该进程向工作进程发送消息,然后进行实际计算。主进程是单线程的,而工作进程是多线程的,并使用节点的所有CPU核心。

为了使所有集群节点上的所有CPU核心都参与计算,我想指定在一个集群节点上应该有2个进程,即主进程(proc_id = 0)和另一个工作进程。在所有其他群集节点上,应该只有一个工作进程。

我怎样才能做到这一点?

感谢。

1 个答案:

答案 0 :(得分:2)

如果您在OpenMPI中使用MariaDB []> MariaDB []> CREATE TABLE `Table_1` ( -> `rand` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, -> `cpn` INT(11) DEFAULT NULL, -> PRIMARY KEY (`rand`) -> ) ENGINE=INNODB DEFAULT CHARSET=utf8; Query OK, 0 rows affected (0.16 sec) MariaDB []> MariaDB []> INSERT INTO `Table_1` (`rand`, `cpn`) -> VALUES -> (1, 4), -> (2, 7), -> (3, 2), -> (4, 1), -> (5, 7); Query OK, 5 rows affected (0.02 sec) Records: 5 Duplicates: 0 Warnings: 0 MariaDB []> MariaDB []> MariaDB []> CREATE TABLE `Table_2` ( -> `rand` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, -> `cpn` INT(11) DEFAULT NULL, -> PRIMARY KEY (`rand`) -> ) ENGINE=INNODB DEFAULT CHARSET=utf8; Query OK, 0 rows affected (0.30 sec) MariaDB []> MariaDB []> INSERT INTO `Table_2` (`rand`, `cpn`) -> VALUES -> (1, 0), -> (2, 0), -> (3, 0), -> (4, 0), -> (5, 0); Query OK, 5 rows affected (0.00 sec) Records: 5 Duplicates: 0 Warnings: 0 MariaDB []> MariaDB []> MariaDB []> SELECT * FROM Table_1; +------+------+ | rand | cpn | +------+------+ | 1 | 4 | | 2 | 7 | | 3 | 2 | | 4 | 1 | | 5 | 7 | +------+------+ 5 rows in set (0.00 sec) MariaDB []> MariaDB []> SELECT * FROM Table_2; +------+------+ | rand | cpn | +------+------+ | 1 | 0 | | 2 | 0 | | 3 | 0 | | 4 | 0 | | 5 | 0 | +------+------+ 5 rows in set (0.00 sec) MariaDB []> MariaDB []> INSERT INTO Table_2 -> (SELECT * FROM Table_1 ) -> ON DUPLICATE KEY UPDATE cpn = VALUES(cpn); Query OK, 10 rows affected (0.00 sec) Records: 5 Duplicates: 5 Warnings: 0 MariaDB []> MariaDB []> SELECT * FROM Table_2; +------+------+ | rand | cpn | +------+------+ | 1 | 4 | | 2 | 7 | | 3 | 2 | | 4 | 1 | | 5 | 7 | +------+------+ 5 rows in set (0.00 sec) MariaDB []> 运行mpiexec,它将完全按照您的描述进行操作:

https://www.open-mpi.org/doc/v1.8/man1/mpiexec.1.php

  

每个节点启动一个进程,以循环方式按节点循环。这样可以在节点之间平均分配流程,并在循环中分配MPI_COMM_WORLD等级,"按节点"方式。