我是MPI的新手。我不知道如何重新定义它。在c中,printf显示输出,但在mpi中,printf函数显示错误。。。
代码:
#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:%sn");
MPI_Finalize();
}
您在MPI_Get_processer_name函数中缺少参数
用此行替换您的函数调用,并初始化长度var(int(
int name_len; //12 characters
MPI_Get_processor_name(processor_name, &name_len);