MPI_Get_processor_name,MPI_Get_version

来源:互联网 发布:淘宝达人发布短视频 编辑:程序博客网 时间:2024/05/17 03:54
/** *  <Parallel programming technology for high performance computing> * *               @Copyright    Du Zhihui        :edited *                             Li Sanli         :review *                             Chen Yu Liu Peng :proofreading * *    Rong Tao study note:    2017.10 * *//** * mpicc -o outfile Demo.c  * mpirun -n 10 ./outfile > out.txt * */#include "mpi.h"#include <stdio.h>#include <math.h>int main(int argc,char *argv[]){    int myid, numprocs;    int namelen;    int version, subversion, ierr;    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);    MPI_Get_version(&version, &subversion);    fprintf(stdout,"stdout Process %d of %d on %s\n",myid, numprocs, processor_name);//mpirun -n 10 ./a > out.txt    fprintf(stderr,"stderr Process %d of %d on %s\n",myid, numprocs, processor_name);//screen    fprintf(stderr,"version %d.%d \n",version, subversion);//screen    perror("rong");//screen    MPI_Finalize();}


编译与运行:

-bash-4.1$ mpicc -o a Demo_01_MPI_Get_processor_name_MPI_Get_version.c-bash-4.1$ ./astdout Process 0 of 1 on AMAXstderr Process 0 of 1 on AMAXversion 3.0 rong: Success-bash-4.1$ mpirun -n 2 ./astdout Process 0 of 2 on AMAXstdout Process 1 of 2 on AMAXstderr Process 0 of 2 on AMAXversion 3.0 rong: Successstderr Process 1 of 2 on AMAXversion 3.0 rong: Success-bash-4.1$ 


原创粉丝点击