Source code
/* Program:
* 每個 node 將自己的 id 印出,並且將所有的參與運動的 node 總數也印出
* ,顯示出自己的主機名稱。
* History:
* 2008-04-09 BETA
* 2008-06-25 增加顯示主機名稱功能
*/
#include <stdio.h>
#include <mpi.h>
main (int argc, char **argv)
{
int rank, size, len;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
int myid, numprocs;
/* 取得 node 總數 */
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
/* 取得本身 node id / rank */
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
/* 取得本身 host name */
MPI_Get_processor_name(name, &len);
printf("This is machine %d of %d name = %s\n", myid, numprocs, name);
MPI_Finalize();
}
Result
Related functions
Last modified 17 years ago
Last modified on Jun 25, 2008, 5:12:23 PM
Attachments (1)
- demo1-01.png (75.8 KB) - added by wade 17 years ago.
Download all attachments as: .zip

