我正在尝试在debian 7上使用openmpi和mpirun运行此示例hello world程序。#include <stdio.h>#include <mpi/mpi.h>int main (int argc, char **argv) { int nProcId, nProcNo; int nNameLen; char szMachineName[MPI_MAX_PROCESSOR_NAME]; MPI_Init (&argc, &argv); // Start up MPI MPI_Comm_size (MPI_COMM_WORLD,&nProcNo); // Find out number of processes MPI_Comm_rank (MPI_COMM_WORLD, &nProcId); // Find out process rank MPI_Get_processor_name (szMachineName, &nNameLen); // Get machine name printf ("Hello World from process %d on %s\r\n", nProcId, szMachineName); if (nProcId == 0) printf ("Number of Processes: %d\r\n", nProcNo); MPI_Finalize (); // Shut down MPI return 0;}我的问题是MPI_Comm_Rank该过程的所有副本都返回0。当我在外壳上运行此命令时:mpirun -np 4 helloWorld它产生以下输出:Hello World from process 0 on debianNumber of Processes: 1Hello World from process 0 on debianNumber of Processes: 1Hello World from process 0 on debianNumber of Processes: 1Hello World from process 0 on debianNumber of Processes: 1为什么进程数仍为1?
2 回答
侃侃尔雅
TA贡献1801条经验 获得超15个赞
我在Mint 17上同时安装了openmpi和mpich,并使用进行了切换update-alternatives --configure mpi
。但是,这不会关闭mpiexec实现,您还必须为此执行update-alternatives --configure mpirun
。
- 2 回答
- 0 关注
- 1056 浏览
添加回答
举报
0/150
提交
取消