tp_memory_interface.hpp 1.58 KB
Newer Older
1 2 3 4 5 6
#ifndef TP_MEMORY_INTERFACE_H
#define TP_MEMORY_INTERFACE_H

#include <stdio.h>
#include <stdlib.h>

7
typedef enum { DDR, HBM, SSD, HDD, NVR } mem_t;
8 9 10 11 12 13

class iMemory {
public:
  /************************/
  /*  |-- Allocation      */
  /************************/
14 15
  virtual void memAlloc ( int64_t buffSize, mem_t mem, bool masterRank, char* fileName, MPI_Comm comm ) = 0;
  virtual void memFree  ( ) = 0;
16 17 18 19 20 21

  /************************/
  /*  |-- I/O             */
  /************************/
  //virtual int memWrite  ( iMemory srcMem, int64_t srcSize, int64_t offset );
  //virtual int memRead   ( iMemory srcMem, int64_t srcSize, int64_t offset );
22 23 24
  virtual int memWrite ( void* srcBuffer, int64_t srcSize, int64_t offset, int destRank ) = 0;
  virtual int memRead  ( void* srcBuffer, int64_t srcSize, int64_t offset, int destRank ) = 0;
  virtual int memFlush ( ) = 0;
25
  virtual int memUncache ( ) = 0;
26 27 28 29

  /************************/
  /*  |-- Utils           */
  /************************/
30 31
  virtual char* memName  ( ) = 0;
  virtual mem_t memType  ( char* name ) = 0;
32 33 34 35

  /************************/
  /*  |-- Characteristics */
  /************************/
36 37 38 39
  virtual int64_t memBandwidth    ( ) = 0;
  virtual int64_t memLatency      ( ) = 0;
  virtual int64_t memCapacity     ( ) = 0;
  virtual bool    memPersistency  ( ) = 0;
40 41 42

  /* Temporary */
  void *buffer_;
43 44 45

protected:
  mem_t mem_;
46
  bool masterRank_;
47 48 49 50 51
  MPI_Comm comm_;

  int64_t buffSize_;
  MPI_Win RMAWin_;
  
52 53 54
  int fd_;
  int mmapAllocatorRank_;

55
  MPI_File fileHandle_;
56
  MPI_Request request_;
57 58 59 60
  char fileName_[4096];
};

#endif // TP_MEMORY_INTERFACE_H