I am new to MPI. I am not figure out how to reslove it. In c printf shows the output but in mpi the printf function shows error...
Code:
#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();
}
You missing the argument in MPI_Get_processor_name function
replace your function call with this line and initialise the length var (int)
int name_len; //12 characters
MPI_Get_processor_name(processor_name, &name_len);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.