#ifndef IbTestDefines_H #define IbTestDefines_H #include #include // maximum command buffer required to provide QPs connection over cluster // for 1000 QPs with 16 Lids and 12 byte per QP one require at least 192000 bytes #define IBTEST_MAXLID 16 #define IBTEST_QP_QUEUE_SIZE 128 #define IBTEST_CMD_MAGIC 0x1ff1 #define IBTEST_CMD_NONE 0 #define IBTEST_CMD_EXIT 76543201 #define IBTEST_CMD_TIMESYNC 76543202 #define IBTEST_CMD_SLEEP 76543203 #define IBTEST_CMD_CHAOTIC 76543204 #define IBTEST_CMD_COLLECT 76543205 #define IBTEST_CMD_TEST 76543206 #define IBTEST_CMD_CREATEQP 76543207 #define IBTEST_CMD_CONNECTQP 76543208 #define IBTEST_CMD_CLOSEQP 76543209 #define IBTEST_CMD_POOL 76543210 #define IBTEST_CMD_ALLTOALL 76543211 #define IBTEST_CMD_CLEANUP 76543212 #define IBTEST_CMD_ASKQUEUE 76543213 #define IBTEST_CMD_INITMCAST 76543214 #define IBTEST_CMD_MCAST 76543215 #define IBTEST_CMD_RDMA 76543216 #define IBTEST_CMD_TIMING 76543217 #define IBTEST_CMD_COLLRATE 76543218 #define IBTEST_CMD_ACTIVENODES 76543219 #define IBTEST_CMD_TESTGPU 76543220 #define IBTEST_WORKERNAME "IbTest" #define CMDCH_RECV_ARG 123456 #define CMDCH_SEND_ARG 654321 #pragma pack(1) // this is command sent via common channel for different kind of action // command specific settings should be sent after all or selected nodes // responded struct IbTestCommandMessage { int32_t magic; // just IBTEST_CMD_MAGIC value to ensure that this is command int32_t cmdid; // command id int32_t node; // node, for which command is submitted double delay; // how long should node waits before exit from command wait int32_t getresults; // how many double values return from results array int32_t cmddatasize; void* cmddata() const { return (int8_t*) this + sizeof(IbTestCommandMessage); } }; struct IbTestTymeSyncMessage { int32_t msgid; double master_time; double slave_shift; double slave_time; double slave_scale; }; #pragma pack() extern double rand_0_1(); extern double GaussRand(double mean, double sigma); extern int IbTestMatrixMean; extern int IbTestMatrixSigma; template class IbTestMatrix { public: IbTestMatrix() : fNRow(0), fNCol(0), fMatrix(nullptr) {} IbTestMatrix(int _nrow, int _ncol) : fNRow(_nrow), fNCol(_ncol), fMatrix(nullptr) { Allocate(); } virtual ~IbTestMatrix() { Clean(); } void SetSize(int _nrow, int _ncol) { if ((nrow()!=_nrow) || (ncol()!=_ncol)) { Clean(); fNRow = _nrow; fNCol = _ncol; Allocate(); } } int nrow() const { return fNRow; } int ncol() const { return fNCol; } T** getmatrix() const { return fMatrix; } T* getrow(int row) const { return fMatrix[row]; } T operator()(int row, int col) const { return fMatrix[row][col]; } T& operator()(int row, int col) { return fMatrix[row][col]; } void Fill(T value) { for (int row=0;row0) && (value>max)) value = max; fMatrix[row][col] = T(value); } } int CountEqual(T value) { int cnt = 0; for (int row=0;row class IbTestColumn { public: IbTestColumn() : fSize(0), fVector(nullptr) {} IbTestColumn(int _size) : fSize(_size), fVector(nullptr) { Allocate(); } virtual ~IbTestColumn() { Clean(); } void SetSize(int _size) { if (_size == size()) return; if (_size < size()) { fSize = _size; } else { Clean(); fSize = _size; Allocate(); } } int size() const { return fSize; } T* getvector() const { return fVector; } T at(int n) const { return fVector[n]; } T& at(int n) { return fVector[n]; } T operator()(int n) const { return fVector[n]; } T& operator()(int n) { return fVector[n]; } bool Remove(int indx) { if ((indx<0) || (indx>=size())) return false; for (int n=indx;n= 0; } void Sort() { for (int n=0;n IbTestIntMatrix; typedef IbTestMatrix IbTestBoolMatrix; typedef IbTestColumn IbTestIntColumn; typedef IbTestColumn IbTestBoolColumn; #endif