ricosjp / monolish

monolish: MONOlithic LInear equation Solvers for Highly-parallel architecture
Apache License 2.0
195 stars 12 forks source link

impl. C++ template MPI Library #51

Open t-hishinuma opened 3 years ago

t-hishinuma commented 3 years ago

in monolish::mpi

t-hishinuma commented 3 years ago

interface idea

test_dot(...){
  monolish::mpi::comm &comm = monolish::mpi::get_instance(); 

  ....

  return comm.Allreduce<double>(ans); 
}

int main(argc, argv){
  monolish::mpi::comm comm;  // singleton
  //or comm(external_comm);
  comm.Init(argc, argv); 

....

  ans = test_dot(x, y); //dont need comm

....

  comm.Finalize();
}

The comm class should be a singleton. In monolish, only one comm is created per process. There is not need to pass comm to functions.

t-hishinuma commented 3 years ago

class interface idea

class monolish::mpi::comm{
private: 
  MPI_COMM COMM;
  comm() = default;

  ~comm() {}; 

public:
  comm(const comm &) = delete;
  comm &operator=(const comm &) = delete;
  comm(comm &&) = delete;
  comm &operator=(comm &&) = delete;

  static comm &get_instance() {
    static comm instance;
    return comm;
  }

  void Init(.....);
  void Finalize();

  double Allreduce(double val);
  float Allreduce(float val);
  ....
t-hishinuma commented 3 years ago

MPI program need:

t-hishinuma commented 3 years ago

Remove "request" from "waitall" and wait for all communications at once.