首页 > 解决方案 > 在 C++ 中发送类而不是 MPI_Type_create_struct 是否有不同的 MPI 命令?

问题描述

我正在尝试使用 MPI 创建一个并行程序,它的串行版本包含这样的类。

class car {

public:
    //constructor
    car(int x, int y, int value){
        xPosition = x;
        yPosition = y;      
    }

    //deconstructor
    ~car() {
        cout << "Car deconstructor!" << endl;
    }

private:
    int xPosition;
    int yPosition;
    int ageInSteps;
    int last50Stepsx[stepHistory];
    int last50Stepsy[stepHistory];
};

我想将这个类从一个进程发送到另一个进程,所以我认为这样做的方法是创建一个包含这个结构的数据类型。

我看到人们通常使用MPI_Type_create_struct然后MPI_Type_create_resized来使用 C 语言发送结构。

这与在 C++ 中发送类的方式相同吗?

标签: c++typesmpimessage-passing

解决方案


推荐阅读