00001 #ifndef _PLOGP_P2P_MODEL_HPP
00002 #define _PLOGP_P2P_MODEL_HPP
00003
00004 #include <boost/serialization/access.hpp>
00005 #include <gsl/gsl_fit.h>
00006
00007 extern "C" {
00008 #include "../../logp_mpi-1.4/logp_mpi.h"
00009 }
00010
00012 class plogp_p2p_model {
00013 private:
00014 friend class boost::serialization::access;
00015 logp_params * logp;
00016
00017 public:
00018 plogp_p2p_model() {logp = NULL;}
00019 ~plogp_p2p_model() { logp_free(logp);}
00020
00022 template <class Archive> void serialize(Archive & ar, const unsigned int version) {
00023 if (logp == NULL) {
00024 logp = (logp_params*)malloc(sizeof(logp_params));
00025 logp->descr = (char*)malloc(sizeof(char) * 4);
00026 strcpy(logp->descr, "CPM");
00027 logp->params = NULL;
00028 }
00029 ar & logp->nsizes;
00030 ar & logp->nsizes_max;
00031 ar & logp->L;
00032 if (logp->params == NULL)
00033 logp->params = (logp_size_params*)malloc(sizeof(logp_size_params) * logp->nsizes);
00034 int i ;
00035 logp_size_params *params;
00036 for (i=0,params = logp->params; i < logp->nsizes; i++,params++) {
00037 ar & params->size;
00038 ar & params->time;
00039 ar & params->RTT;
00040 ar & params->RTT_min;
00041 ar & params->os;
00042 ar & params->os_cnfint;
00043 ar & params->os_min;
00044 ar & params->_or;
00045 ar & params->or_cnfint;
00046 ar & params->or_min;
00047 ar & params->g;
00048 }
00049 }
00050
00051 void estimate(MPI_Comm comm, MPIB_msgset msgset, MPIB_precision precision, int i, int j) {
00052 int rank;
00053 MPI_Comm_rank(comm, &rank);
00054 logp_params *tmp;
00055 logp_measure(&tmp, (char*)"CPM", comm, i, j, 0,
00056 precision.min_reps, precision.max_reps, precision.cl, precision.eps,
00057 msgset.max_diff, (msgset.min_size > 0) ? msgset.min_size : 1, msgset.max_size, msgset.max_num,
00058 LOGP_MPI_SEND, LOGP_MPI_RECV, LOGP_BUF_STATIC, LOGP_OPT_GM_DIRECT, LOGP_DIAG_SILENT);
00059 if (rank == i)
00060 logp = tmp;
00061 }
00062
00063 void write_header(ostream &os) {}
00064 void write_elem(int i, int j, ostream &os) {
00065 os << "\n\n";
00066 os << "#" << i <<"-" << j <<"\n" ;
00067 os << "# LogP network performance data: " << logp->descr << endl;
00068 os << "# Latency = ";
00069 os.setf(ios::fixed,ios::floatfield);
00070 os.precision(7);
00071 os << logp->L << endl;
00072 os << "# time bytes os os_min os_cnfint or or_min or_cnfint g\n" ;
00073 for (i = 0; i < logp->nsizes; i++) {
00074 logp_size_params *lsp = &logp->params[i];
00075 os.width(9);
00076 os << lsp->time << " " ;
00077 os.width(7);
00078 os << lsp->size << " ";
00079 os.width(0);
00080 os << lsp->os << " ";
00081 os << lsp-> os_min << " ";
00082 os << lsp->os_cnfint << " " << lsp->_or << " " << lsp->or_min << " " << lsp->or_cnfint << " " << lsp->g << "\n" ;
00083 }
00084 }
00085 void write_footer(ostream &os) {
00086 os << "\n\n";
00087 }
00088 };
00089
00090 #endif