코드가 MPI_COMM_WORLD에서 인스턴스화되었지만 send_code 함수에서 사용되고 있음을 알 수 있습니다!어떻게 MPI_COMM_WORLD를 선언하여 어디서나 사용할 수 있습니까?
내 코드는 다음과 같습니다
int send_code(char *code)
{
//produce the codes for adding the code into the table
printf("%s\n",code);
MPI_Send(code, 8, MPI_CHAR,0, 0,MPI_COMM_WORLD);
}
int main(int argc, char *argv[])
{
MPI_Status status;
int outbuf, inbuf;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank==0)
{
MPI_Recv(code, 8, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
printf("%s by master\n",code);
}
else
{
........
}
MPI_Finalize();
}
유형은 무엇입니까? – tchap