MPI를 배우려고합니다. 한 프로세서에서 다른 프로세서로 데이터를 전송할 때 데이터를 전송하고 다른 데이터를 변수로 수신 할 수있었습니다. 하지만 두 프로세서에서 보내고받을 때 잘못된 순위 오류가 발생합니다.전달자 MPI_COMM_WORLD의 MPI_Send에서 오류가 발생했습니다. MPI_ERR_RANK : 잘못된 순위
#!/bin/bash
#PBS -l nodes=1:ppn=8,walltime=1:00
#PBS -N MPIsample
#PBS -q edu_shared
#PBS -m abe
#PBS -M [email protected]
#PBS -e mpitest.err
#PBS -o mpitest.out
#PBS -d /export/home/blah/MPIsample
mpirun -machinefile $PBS_NODEFILE -np $PBS_NP ./mpitest
출력 파일은 다음과 같이 나온다 :
World size is 1
World size is 1
World size is 1
World size is 1
World size is 1
World size is 1
World size is 1
World size is 1
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 6
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
Job complete
세계 크기가 만약 여기
내 PBS 파일이있는 프로그램 여기#include <mpi.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
int world_size;
int rank;
char hostname[256];
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
int tag = 4;
int value = 4;
int master = 0;
int rec;
MPI_Status status;
// Initialize the MPI environment
MPI_Init(&argc,&argv);
// get the total number of processes
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
// get the rank of current process
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// get the name of the processor
MPI_Get_processor_name(processor_name, &name_len);
// get the hostname
gethostname(hostname,255);
printf("World size is %d\n",world_size);
if(rank == master){
MPI_Send(&value,1,MPI_INT,1,tag,MPI_COMM_WORLD);
MPI_Recv(&rec,1,MPI_INT,1,tag,MPI_COMM_WORLD,&status);
printf("In master with value %d\n",rec);
}
if(rank == 1){
MPI_Send(&tag,1,MPI_INT,0,tag,MPI_COMM_WORLD);
MPI_Recv(&rec,1,MPI_INT,0,tag,MPI_COMM_WORLD,&status);
printf("in slave with rank %d and value %d\n",rank, rec);
}
printf("Hello world! I am process number: %d from processor %s on host %s out of %d processors\n", rank, processor_name, hostname, world_size);
MPI_Finalize();
return 0;
}
내 코드입니다 1이면 세계 크기는 8 회가 아니라 1 회 인쇄해야합니다.
ERR 파일은 다음과 같습니다
[compute-0-34.local:13110] *** An error occurred in MPI_Send
[compute-0-34.local:13110] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13110] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13110] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13107] *** An error occurred in MPI_Send
[compute-0-34.local:13107] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13107] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13107] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13112] *** An error occurred in MPI_Send
[compute-0-34.local:13112] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13112] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13112] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13108] *** An error occurred in MPI_Send
[compute-0-34.local:13108] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13108] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13108] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13109] *** An error occurred in MPI_Send
[compute-0-34.local:13109] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13109] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13109] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13113] *** An error occurred in MPI_Send
[compute-0-34.local:13113] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13113] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13113] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13106] *** An error occurred in MPI_Send
[compute-0-34.local:13106] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13106] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13106] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
[compute-0-34.local:13111] *** An error occurred in MPI_Send
[compute-0-34.local:13111] *** on communicator MPI_COMM_WORLD
[compute-0-34.local:13111] *** MPI_ERR_RANK: invalid rank
[compute-0-34.local:13111] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
1 일 전 내가 보내고 동시에 그러나 작업 코드는 나에게이 오류가 표시되고 그 후받을 수 있었다. 내 코드 또는 작업중인 고성능 컴퓨터에 문제가 있습니까?
글을 편집하고 PBS 스크립트에서'mpirun' 명령 줄을 추가 할 수 있습니까? 충돌이 발생할 수 있습니다. 단 하나의 MPI 작업 만 있습니다.'gethostname()'다음에'printf' 줄을 옮기면 그 점이 분명해질 것입니다. –
mpirun 명령을 추가했습니다. 또한 gethostname() 바로 뒤에 printf 줄을 이동했습니다. 그것은 여전히 나에게 같은 오류가 생기고있다. –
mpirun 앞에'set -x'를 추가하고 작업 stdout과 stderr를 게시하십시오. 너 어떤 MPI를 달리고 있니? 제대로 구축했다면, -machinefile ... -np ... '도 필요하지 않습니다. –