1
マシン間でmatrcesを送信するためにMPIを使用したいと思います。以下は私のテストコードですMPIを使ってEigen :: MatrixXdでデータを送信する方法
#include <iostream>
#include <Eigen/Dense>
#include <mpi.h>
using std::cin;
using std::cout;
using std::endl;
using namespace Eigen;
int main(int argc, char ** argv)
{
MatrixXd a = MatrixXd::Ones(3, 4);
int myrank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
MPI_Status status;
if (0 == myrank)
{
MPI_Send(&a, 96, MPI_BYTE, 1, 99, MPI_COMM_WORLD);
}
else if (1 == myrank)
{
MPI_Recv(&a, 96, MPI_BYTE, 0, 99, MPI_COMM_WORLD, &status);
cout << "RANK " << myrank << endl;
cout << a << endl;
}
MPI_Finalize();
return 0;
}
エラーなしで正常にコンパイルされましたが、起動したときに次のエラーが返されました。
$ MPI mpiexec -n 2 ./sendMatrixTest
RANK 1
[HPNotebook:11633] *** Process received signal ***
[HPNotebook:11633] Signal: Segmentation fault (11)
[HPNotebook:11633] Signal code: Address not mapped (1)
[HPNotebook:11633] Failing at address: 0xf4ba40
--------------------------------------------------------------------------
mpiexec noticed that process rank 1 with PID 11633 on node HPNotebook exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
どうすればよいですか?ありがとうございました!
はあなたの行列をシリアル化し、それを送信しますか? –
'eigen'行列を送るのではなく、' int'のような単純なもので始まり、処理します。 'eigen'行列は' std :: vector'のようなコンテナです。そこには多くの情報が入っています。 http://stackoverflow.com/questions/36021305/mpi-send-struct-with-a-vector-property-in-cの例を示します – Matt