以下のコードでは、プロービング中に正しい到着数が取得されません。同じ機能性も標準のMPI関数でテストされ、正解が得られます。 Boostのバージョンで正しい結果が得られないのはなぜですか?boost :: iprobeが正しい回数を返しません
ブーストバージョン:
#include <iostream>
#include <boost/mpi.hpp>
using namespace boost;
using namespace boost::mpi;
int main()
{
environment env;
communicator world;
if (world.rank() == 0)
{
int a[70];
auto req = world.isend(0, 0, a);
//req.wait(); // does not make any difference on the result.
optional<status> stat;
while (!stat)
{
stat = world.iprobe(0, 0);
if (stat)
{
optional<int> count = (*stat).count<int>();
if (count)
{
std::cout << *count << std::endl; // output: 2, expected: 70.
}
}
}
}
return 0;
}
標準バージョン:
#include <iostream>
#include <mpi.h>
int main()
{
MPI_Init(NULL, NULL);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
{
int a[70];
MPI_Request req;
MPI_Status stat;
MPI_Isend(a, 70, MPI_INT, 0, 0, MPI_COMM_WORLD, &req);
//MPI_Wait(&req, &stat);
int flag;
MPI_Iprobe(0, 0, MPI_COMM_WORLD, &flag, &stat);
if (flag)
{
int count;
MPI_Get_count(&stat, MPI_INT, &count);
std::cout << count << std::endl; // output: 70.
}
}
MPI_Finalize();
return 0;
}
編集:isend(dest, tag, values, n)
を使用代わりにisend(dest, tag, values)
はn
は内の要素の数であり、正しい答えを与えアレイ。