[英]mpi (message passing model)in c printf error
我是 MPI 的新手。 我不知道如何重新爱它。 In c printf shows the output but in mpi the printf function shows error...
代码:
#include <mpi.h>
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
int main(int argc, char* argv[]) {
// Initialize the MPI environment
MPI_Init(&argc, &argv);
// Get the number of processes
int P; //total number of processes
MPI_Comm_size(MPI_COMM_WORLD, &P);
// Get the rank of the process
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME]; //256
MPI_Get_processor_name(processor_name);
printf("\nHello world from process:%d out of %d, mapped on processor:%s\n");
MPI_Finalize();
}
您缺少MPI_Get_processor_name function 中的参数
用此行替换您的 function 调用并初始化长度 var (int)
int name_len; //12 characters
MPI_Get_processor_name(processor_name, &name_len);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.