#include<stdio.h>
#include<mpi.h>
#include<stdlib.h>
#include<time.h>
 
int main(int argc, char* argv[])
 {
    int myid, numprocs, namelen;
   char processor_name[MPI_MAX_PROCESSOR_NAME];
 
    MPI_Init(&argc, &argv);        // starts MPI
   MPI_Comm_rank(MPI_COMM_WORLD, &myid);  // get current process id
   MPI_Comm_size(MPI_COMM_WORLD, &numprocs);      // get number of processes
    MPI_Get_processor_name(processor_name, &namelen);

   if (myid == 0) printf("number of processes: %d\n...", numprocs);
   printf("%s: Hello world from process %d \n", processor_name, myid);

    MPI_Finalize();
 
     return 0;
 }

关于配置mpi参考https://blog.csdn.net/Candy_GL/article/details/80015209?tdsourcetag=s_pcqq_aiomsg

Logo

汇聚原天河团队并行计算工程师、中科院计算所专家以及头部AI名企HPC专家,助力解决“卡脖子”问题

更多推荐