aboutsummaryrefslogtreecommitdiff
path: root/src/MPIO.hh
blob: 67bfebd8e2a3dba04ab3f12129163efb3162559b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef __MPIO_HH_
#define __MPIO_HH_

#include "IEEEIO.hh"
#include "MPIutils.hh"
#include "Timer.hh"

class MPIO {
typedef float *floatP;
typedef MPI_Request *MPI_RequestP;

  MPIcomm &comm;
  int *alldims,*allorigins;
  int globaldims[3]; // for all procs
  int localorigin[3],localdims[3]; // local dims are full extent + bound & ghost
  int root, myid;
  IEEEIO *file; // only on master
  MPI_Request *sendreq; // is it proper to have a pointer here?
  MPI_RequestP recvreq[2]; // double-buffered
  floatP slicebuffer[3]; // double-buffered + a scratch space
  
  
protected:
  void sendSlice(int z, float *data, MPI_Request *req);
  int requestSlice(int z, float *slicebuffer, MPI_Request *req);
  void waitForSlice(int z, float *slicebuffer, float *destbuffer, MPI_Request *req);
  void asyncWrite(float *data);
public:
  MPIO(IEEEIO *io,MPIcomm &c);
  ~MPIO();
  inline int isRoot() { return ((myid==root)?1:0);}
  void setLocalDims(int rank,int *origin,int *dims);
  virtual int write(float *data){
    asyncWrite(data);
    return 1;
  }
};

#endif