0

我正在尝试创建一个消息处理程序,它可以对带有任何标签的消息进行阻塞探测:

MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &probe_status);

然后根据标签采取相应的行动:

int tag = probe_status.MPI_TAG;
if (tag == 0){
    // The message is of type a
}
else if (tag == 1){
    // The message is of type b
}

但是,probe_status.MPI_TAG始终评估为 0,即使我已经隔离了发件人并且只有一个MPI_Isend使用标签 1。

编辑:事实上,即使

MPI_Probe(0, 1, MPI_COMM_WORLD, &probe_status);

cout << rank << ": a message has been found with the probe, with tag " 
     << probe_status.MPI_TAG << ", source " << probe_status.MPI_SOURCE << " 
     and size " << probe_status.count << endl;

给出:标记 0、源 12 和大小 0。只有 2 个节点在运行,如果发送者被删除,则探测会阻塞,因此它会找到从节点 0 发送的“正确”消息。

EDIT2:发件人是这样的:

unsigned int rank = MPI::COMM_WORLD.Get_rank();
unsigned int nodes = MPI::COMM_WORLD.Get_size();

for(unsigned int i=0; i<nodes; i++){
// Send the release to all nodes except the current
    if(i != rank){
        int taskid[5];
        convert_task_to_id(task_name,taskid);

    Message* message = get_available_message();
    memcpy(message->taskobject_id,taskid, sizeof(taskid));

    message->available = false;
    MPI_Isend(&(message->taskobject_id), 3, MPI_INT, i, 1, MPI_COMM_WORLD, &(message->request));
}
}

持有和可用Message的在哪里(以便我可以在完成时重复使用 s)。在这个例子中,只有节点 0 发送,只有节点 1 会找到消息。使用 MPICH 3.0.4。structMPI_RequestboolMPI_Request

谢谢你的帮助。

4

0 回答 0