C+MPI入门 hello World!

#include "mpi.h"
#include <stdio.h>

using namespace std;

int  main(int argc,char* argv[])
{
    int myid,numprocs;   //变量是分布存储的
    int namelen;
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
    MPI_Get_processor_name(processor_name,&namelen);
    printf("Hello World! Process %d of %d on %s\n",myid,numprocs,processor_name);
    MPI_Finalize();

    return 0;
}

 

posted on 2014-01-06 16:17  Ja °  阅读(743)  评论(0编辑  收藏  举报

导航