将不同长度的多条消息发送到同一级别

时间:2018-04-14 07:22:15

标签: mpi openmpi

我们说我有3个等级。

等级0从等级1收到1 MPI_INT,从等级2收到10 MPI_INT

MPI_Recv(buf1, 1, MPI_INT,
    1, 0, MPI_COMM_WORLD, &status);
MPI_Recv(buf2, 10, MPI_INT,
    2, 0, MPI_COMM_WORLD, &status);

等级1和等级2分别将1和10 MPI_INT发送到等级0。 MPI_Recv是阻塞调用。让我们说来自等级2的10 MPI_INIT在等级1的1 MPI_INT之前到达。此时,排名0阻止等待来自等级1的数据。

在这种情况下,第一个MPI_Recv可以返回吗?排名2的数据首先到达,但数据不适合buf1,可能包含一个整数。

然后来自等级1的消息到来。 MPI是否能够选择此消息并让第一个MPI_Recv返回?

1 个答案:

答案 0 :(得分:0)

由于您在调用Timer timer = new Timer(300, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String line; for (int i = 0; i < process.length; i++) { BufferedReader buffer=new BufferedReader(new InputStreamReader(process[i].getInputStream())); try { if ((line = buffer.readLine()) != null) { logTextArea[i].append(line + "\n"); } else { ((Timer) e.getSource()).stop(); } } catch (IOException ex) { ex.printStackTrace(); } } } }); try { for ( int count = 0 ; count < destList.getModel().getSize(); count++){ String projectPath = findDir(new File(codebasePath), destList.getModel().getElementAt(count).toString()); process[count] = Runtime.getRuntime().exec(System.getenv("M2_HOME")+"//bin//mvn.bat clean install -DskipTests -f "+projectPath + "\\pom.xml"); logTextArea[count] = new JTextArea(25, 60); logFrame[count] = new JFrame("Show Log"); logFrame[count].add(new JScrollPane(logTextArea[count]), BorderLayout.CENTER); logFrame[count].setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); logFrame[count].pack(); logFrame[count].setLocationByPlatform(true); logFrame[count].setVisible(true); timer.start(); process[count].waitFor() } } catch (IOException e) { e.printStackTrace(); } 时指定了一个源,因此您没有时间担心消息的顺序。当从排名MPI_Recv()收到1 MPI_Recv()时,第一个MPI_INT将返回,而当从排名{{1}收到10 1时,第二个MPI_Recv()将返回}}

如果你有MPI_INT,那将是另一回事。

如果您仍然需要说服自己,请随意编写一个带有2的简单程序。

相关问题