00001 #ifndef __CkDDT_H_
00002 #define __CkDDT_H_
00003
00004 #include <string>
00005 #include <vector>
00006 #include "charm++.h"
00007 #include "ampi.h"
00008
00009
00010 #define DDTDEBUG(...) //CkPrintf(__VA_ARGS__)
00011
00012 using std::array;
00013 using std::vector;
00014 using std::string;
00015
00016
00017
00018
00019
00020
00021
00022
00023 #define AMPI_MAX_BASIC_TYPE 29
00024
00025
00026
00027
00028
00029
00030
00031 #define AMPI_MAX_PREDEFINED_TYPE 41
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #define CkDDT_CONTIGUOUS 42
00042 #define CkDDT_VECTOR 43
00043 #define CkDDT_HVECTOR 44
00044 #define CkDDT_INDEXED_BLOCK 45
00045 #define CkDDT_HINDEXED_BLOCK 46
00046 #define CkDDT_INDEXED 47
00047 #define CkDDT_HINDEXED 48
00048 #define CkDDT_STRUCT 49
00049
00050 enum CkDDT_Dir : bool {
00051 PACK = true,
00052 UNPACK = false
00053 };
00054
00055
00056 inline void serializeContig(char* userdata, char* buffer, size_t size, CkDDT_Dir dir) noexcept
00057 {
00058 if (dir == PACK) {
00059 memcpy(buffer, userdata, size);
00060 }
00061 else {
00062 memcpy(userdata, buffer, size);
00063 }
00064 }
00065
00066
00067
00068 inline void CkDDT_SetName(string &dst, const char *src) noexcept
00069 {
00070 int end = strlen(src)-1;
00071 while ((end>0) && (src[end]==' ')) {
00072 end--;
00073 }
00074 int len = (end==0) ? 0 : end+1;
00075 if (len > MPI_MAX_OBJECT_NAME) {
00076 len = MPI_MAX_OBJECT_NAME;
00077 }
00078 dst.assign(src, len);
00079 }
00080
00081 class CkDDT;
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 class CkDDT_DataType
00114 {
00115 protected:
00116 bool iscontig;
00117 bool isAbsolute;
00118 int size;
00119 int count;
00120 int datatype;
00121 int refCount;
00122 int baseSize;
00123 int baseIndex;
00124 int numElements;
00125 MPI_Aint extent;
00126 MPI_Aint ub;
00127 MPI_Aint lb;
00128 MPI_Aint trueExtent;
00129 MPI_Aint trueLB;
00130 MPI_Aint baseExtent;
00131 CkDDT_DataType *baseType;
00132 vector<int> keyvals;
00133 string name;
00134
00135 public:
00136 CkDDT_DataType() = default;
00137 virtual ~CkDDT_DataType() = default;
00138 CkDDT_DataType(int type) noexcept;
00139 CkDDT_DataType(int datatype, int size, MPI_Aint extent, int count, MPI_Aint lb, MPI_Aint ub,
00140 bool iscontig, int baseSize, MPI_Aint baseExtent, CkDDT_DataType* baseType,
00141 int numElements, int baseIndex, MPI_Aint trueExtent, MPI_Aint trueLB) noexcept;
00142 CkDDT_DataType(const CkDDT_DataType &obj, MPI_Aint _lb=0, MPI_Aint _extent=0) noexcept;
00143 CkDDT_DataType& operator=(const CkDDT_DataType& obj) noexcept;
00144
00145 virtual void pupType(PUP::er &p, CkDDT* ddt) noexcept;
00146 virtual int getEnvelope(int *num_integers, int *num_addresses, int *num_datatypes, int *combiner) const noexcept;
00147 virtual int getContents(int max_integers, int max_addresses, int max_datatypes,
00148 int array_of_integers[], MPI_Aint array_of_addresses[],
00149 int array_of_datatypes[]) const noexcept;
00150
00151 virtual size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept
00152 {
00153 DDTDEBUG("CkDDT_Datatype::serialize %s %d objects of type %d (%d bytes)\n",
00154 (dir==PACK)?"packing":"unpacking", num, datatype, bufSize);
00155 size_t bufSize = std::min((size_t)num * (size_t)size, (size_t)msgLength);
00156 if (iscontig) {
00157 serializeContig(userdata, buffer, bufSize, dir);
00158 return bufSize;
00159 }
00160 else {
00161 for (int i=0; i<num; i++) {
00162 if (bufSize < size) {
00163 break;
00164 }
00165 serializeContig(userdata + i*extent, buffer + i*size, size, dir);
00166 bufSize -= size;
00167 }
00168 return msgLength - bufSize;
00169 }
00170 }
00171 virtual int getNumBasicElements(int bytes) const noexcept;
00172
00173 void setSize(MPI_Aint lb, MPI_Aint extent) noexcept;
00174 bool isContig() const noexcept { return iscontig; }
00175 int getSize(int count=1) const noexcept { return count * size; }
00176 MPI_Aint getExtent() const noexcept { return extent; }
00177 int getBaseSize() const noexcept { return baseSize; }
00178 MPI_Aint getLB() const noexcept { return lb; }
00179 MPI_Aint getUB() const noexcept { return ub; }
00180 MPI_Aint getTrueExtent() const noexcept { return trueExtent; }
00181 MPI_Aint getTrueLB() const noexcept { return trueLB; }
00182 int getBaseIndex() const noexcept { return baseIndex; }
00183 CkDDT_DataType* getBaseType() const noexcept { return baseType; }
00184 MPI_Aint getBaseExtent() const noexcept { return baseExtent; }
00185 int getCount() const noexcept { return count; }
00186 int getType() const noexcept { return datatype; }
00187 int getNumElements() const noexcept { return numElements; }
00188 void incRefCount() noexcept {
00189 CkAssert(refCount > 0);
00190 if (datatype > AMPI_MAX_PREDEFINED_TYPE) {
00191 refCount++;
00192 }
00193 }
00194 int decRefCount() noexcept {
00195
00196
00197 CkAssert(refCount > 0);
00198 if (datatype > AMPI_MAX_PREDEFINED_TYPE) {
00199 return --refCount;
00200 }
00201 return -1;
00202 }
00203 vector<int>& getKeyvals() noexcept { return keyvals; }
00204 void setName(const char *src) noexcept { CkDDT_SetName(name, src); }
00205 void getName(char *dest, int *len) const noexcept {
00206 int length = *len = name.size();
00207 memcpy(dest, &name[0], length);
00208 dest[length] = '\0';
00209 }
00210 void setAbsolute(bool arg) noexcept { isAbsolute = arg; }
00211 };
00212
00213
00214
00215
00216
00217 class CkDDT_Contiguous final : public CkDDT_DataType
00218 {
00219 public:
00220 CkDDT_Contiguous() = default;
00221 ~CkDDT_Contiguous() override = default;
00222 CkDDT_Contiguous& operator=(const CkDDT_Contiguous& obj) noexcept;
00223 CkDDT_Contiguous(int count, int index, CkDDT_DataType* oldType) noexcept;
00224 CkDDT_Contiguous(const CkDDT_Contiguous& obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00225
00226 size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00227 void pupType(PUP::er &p, CkDDT* ddt) noexcept override;
00228 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00229 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00230 int getNumBasicElements(int bytes) const noexcept override;
00231 };
00232
00233
00234
00235
00236
00237
00238
00239 class CkDDT_Vector : public CkDDT_DataType
00240 {
00241 protected:
00242 int blockLength;
00243 int strideLength;
00244
00245 public:
00246 CkDDT_Vector() = default;
00247 ~CkDDT_Vector() override = default;
00248 CkDDT_Vector& operator=(const CkDDT_Vector& obj) noexcept;
00249 CkDDT_Vector(int count, int blklen, int stride, int index, CkDDT_DataType* type) noexcept;
00250 CkDDT_Vector(const CkDDT_Vector &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00251
00252 size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00253 void pupType(PUP::er &p, CkDDT* ddt) noexcept override;
00254 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00255 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00256 int getNumBasicElements(int bytes) const noexcept override;
00257 };
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 class CkDDT_HVector final : public CkDDT_Vector
00268 {
00269 public:
00270 CkDDT_HVector() = default;
00271 ~CkDDT_HVector() override = default;
00272 CkDDT_HVector& operator=(const CkDDT_HVector& obj) noexcept;
00273 CkDDT_HVector(int nCount, int blength, int strideLen, int index, CkDDT_DataType* type) noexcept;
00274 CkDDT_HVector(const CkDDT_HVector &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00275
00276 size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00277 void pupType(PUP::er &p, CkDDT* ddt) noexcept override;
00278 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00279 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00280 int getNumBasicElements(int bytes) const noexcept override;
00281 };
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 class CkDDT_HIndexed_Block : public CkDDT_DataType
00294 {
00295 protected:
00296 int blockLength;
00297
00298
00299
00300 vector<MPI_Aint> arrayDisplacements;
00301
00302 public:
00303 CkDDT_HIndexed_Block() = default;
00304 ~CkDDT_HIndexed_Block() override = default;
00305 CkDDT_HIndexed_Block& operator=(const CkDDT_HIndexed_Block &obj) noexcept;
00306 CkDDT_HIndexed_Block(int count, int Blength, const MPI_Aint *arrBytesDisp, int index,
00307 CkDDT_DataType *type) noexcept;
00308 CkDDT_HIndexed_Block(const CkDDT_HIndexed_Block &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00309
00310 size_t serialize(char *userdata, char *buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00311 void pupType(PUP::er &p, CkDDT *ddt) noexcept override;
00312 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00313 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00314 int getNumBasicElements(int bytes) const noexcept override;
00315 };
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 class CkDDT_Indexed_Block final : public CkDDT_HIndexed_Block
00327 {
00328 public:
00329 CkDDT_Indexed_Block() = default;
00330 ~CkDDT_Indexed_Block() override = default;
00331 CkDDT_Indexed_Block& operator=(const CkDDT_Indexed_Block &obj) noexcept;
00332 CkDDT_Indexed_Block(int count, int Blength, const MPI_Aint *arrBytesDisp, const int *ArrDisp,
00333 int index, CkDDT_DataType *type) noexcept;
00334 CkDDT_Indexed_Block(const CkDDT_Indexed_Block &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00335
00336 size_t serialize(char *userdata, char *buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00337 void pupType(PUP::er &p, CkDDT *ddt) noexcept override;
00338 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00339 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00340 int getNumBasicElements(int bytes) const noexcept override;
00341 };
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 class CkDDT_HIndexed : public CkDDT_DataType
00353 {
00354 protected:
00355 vector<int> arrayBlockLength;
00356 vector<MPI_Aint> arrayDisplacements;
00357
00358 public:
00359 CkDDT_HIndexed() = default;
00360 ~CkDDT_HIndexed() override = default;
00361 CkDDT_HIndexed& operator=(const CkDDT_HIndexed& obj) noexcept;
00362 CkDDT_HIndexed(int count, const int* arrBlock, const MPI_Aint* arrBytesDisp, int index,
00363 CkDDT_DataType* type) noexcept;
00364 CkDDT_HIndexed(const CkDDT_HIndexed &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00365
00366 size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00367 void pupType(PUP::er &p, CkDDT* ddt) noexcept override;
00368 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00369 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00370 int getNumBasicElements(int bytes) const noexcept override;
00371 };
00372
00373
00374
00375
00376
00377
00378
00379
00380 class CkDDT_Indexed final : public CkDDT_HIndexed
00381 {
00382 public:
00383 CkDDT_Indexed() = default;
00384 ~CkDDT_Indexed() override = default;
00385 CkDDT_Indexed& operator=(const CkDDT_Indexed& obj) noexcept;
00386 CkDDT_Indexed(int count, const int* arrBlock, const MPI_Aint* arrBytesDisp,
00387 const MPI_Aint* arrDisp, int index, CkDDT_DataType* type) noexcept;
00388 CkDDT_Indexed(const CkDDT_Indexed &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00389
00390 size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00391 void pupType(PUP::er &p, CkDDT* ddt) noexcept override;
00392 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00393 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00394 int getNumBasicElements(int bytes) const noexcept override;
00395 };
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 class CkDDT_Struct final : public CkDDT_DataType
00408 {
00409 protected:
00410 vector<int> arrayBlockLength;
00411 vector<MPI_Aint> arrayDisplacements;
00412 vector<int> index;
00413 vector<CkDDT_DataType *> arrayDataType;
00414
00415 public:
00416 CkDDT_Struct() = default;
00417 ~CkDDT_Struct() override = default;
00418 CkDDT_Struct& operator=(const CkDDT_Struct& obj) noexcept;
00419 CkDDT_Struct(int count, const int* arrBlock, const MPI_Aint* arrDisp, const int *index,
00420 CkDDT_DataType **type, const char* name=nullptr) noexcept;
00421 CkDDT_Struct(const CkDDT_Struct &obj, MPI_Aint _lb, MPI_Aint _extent) noexcept;
00422
00423 vector<int>& getBaseIndices() noexcept { return index; }
00424 const vector<int>& getBaseIndices() const noexcept { return index; }
00425 vector<CkDDT_DataType *>& getBaseTypes() noexcept { return arrayDataType; }
00426 const vector<CkDDT_DataType *>& getBaseTypes() const noexcept { return arrayDataType; }
00427
00428 size_t serialize(char* userdata, char* buffer, int num, int msgLength, CkDDT_Dir dir) const noexcept override;
00429 void pupType(PUP::er &p, CkDDT* ddt) noexcept override;
00430 int getEnvelope(int *ni, int *na, int *nd, int *combiner) const noexcept override;
00431 int getContents(int ni, int na, int nd, int i[], MPI_Aint a[], int d[]) const noexcept override;
00432 int getNumBasicElements(int bytes) const noexcept override;
00433 };
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 class CkDDT
00446 {
00447 private:
00448 const array<const CkDDT_DataType *, AMPI_MAX_PREDEFINED_TYPE+1>& predefinedTypeTable;
00449 vector<CkDDT_DataType *> userTypeTable;
00450 vector<int> types;
00451
00452 public:
00453
00454 static
00455 void addBasic(array<const CkDDT_DataType *, AMPI_MAX_PREDEFINED_TYPE+1>& predefinedTypeTable_,
00456 int type) noexcept
00457 {
00458 CkAssert(type >= 0);
00459 CkAssert(type <= AMPI_MAX_BASIC_TYPE);
00460 CkAssert(type <= AMPI_MAX_PREDEFINED_TYPE);
00461 predefinedTypeTable_[type] = new CkDDT_DataType(type);
00462 }
00463
00464 static
00465 void addStruct(array<const CkDDT_DataType *, AMPI_MAX_PREDEFINED_TYPE+1>& predefinedTypeTable_,
00466 const char* name, int type, int val, int idx, int offset) noexcept
00467 {
00468 CkAssert(type > AMPI_MAX_BASIC_TYPE);
00469 CkAssert(type <= AMPI_MAX_PREDEFINED_TYPE);
00470 const int bLengths[2] = {1, 1};
00471 MPI_Datatype bTypes[2] = {val, idx};
00472 CkDDT_DataType* nTypes[2] = {const_cast<CkDDT_DataType *>(predefinedTypeTable_[val]), const_cast<CkDDT_DataType *>(predefinedTypeTable_[idx])};
00473 MPI_Aint offsets[2] = {0, offset};
00474 predefinedTypeTable_[type] = new CkDDT_Struct(2, bLengths, offsets, bTypes, nTypes, name);
00475 }
00476
00477 static
00478 const array<const CkDDT_DataType *, AMPI_MAX_PREDEFINED_TYPE+1> createPredefinedTypes() noexcept
00479 {
00480 array<const CkDDT_DataType *, AMPI_MAX_PREDEFINED_TYPE+1> predefinedTypeTable_;
00481
00482 addBasic(predefinedTypeTable_, MPI_DOUBLE);
00483 addBasic(predefinedTypeTable_, MPI_INT);
00484 addBasic(predefinedTypeTable_, MPI_FLOAT);
00485 addBasic(predefinedTypeTable_, MPI_LOGICAL);
00486 addBasic(predefinedTypeTable_, MPI_C_BOOL);
00487 addBasic(predefinedTypeTable_, MPI_CHAR);
00488 addBasic(predefinedTypeTable_, MPI_BYTE);
00489 addBasic(predefinedTypeTable_, MPI_PACKED);
00490 addBasic(predefinedTypeTable_, MPI_SHORT);
00491 addBasic(predefinedTypeTable_, MPI_LONG);
00492 addBasic(predefinedTypeTable_, MPI_UNSIGNED_CHAR);
00493 addBasic(predefinedTypeTable_, MPI_UNSIGNED_SHORT);
00494 addBasic(predefinedTypeTable_, MPI_UNSIGNED);
00495 addBasic(predefinedTypeTable_, MPI_UNSIGNED_LONG);
00496 addBasic(predefinedTypeTable_, MPI_LONG_DOUBLE);
00497 addBasic(predefinedTypeTable_, MPI_LONG_LONG_INT);
00498 addBasic(predefinedTypeTable_, MPI_SIGNED_CHAR);
00499 addBasic(predefinedTypeTable_, MPI_UNSIGNED_LONG_LONG);
00500 addBasic(predefinedTypeTable_, MPI_WCHAR);
00501 addBasic(predefinedTypeTable_, MPI_INT8_T);
00502 addBasic(predefinedTypeTable_, MPI_INT16_T);
00503 addBasic(predefinedTypeTable_, MPI_INT32_T);
00504 addBasic(predefinedTypeTable_, MPI_INT64_T);
00505 addBasic(predefinedTypeTable_, MPI_UINT8_T);
00506 addBasic(predefinedTypeTable_, MPI_UINT16_T);
00507 addBasic(predefinedTypeTable_, MPI_UINT32_T);
00508 addBasic(predefinedTypeTable_, MPI_UINT64_T);
00509 addBasic(predefinedTypeTable_, MPI_AINT);
00510 addBasic(predefinedTypeTable_, MPI_LB);
00511 addBasic(predefinedTypeTable_, MPI_UB);
00512
00513
00514
00515
00516
00517
00518
00519 typedef struct { int val; int idx; } IntInt;
00520 addStruct(predefinedTypeTable_, "MPI_2INT", MPI_2INT, MPI_INT, MPI_INT, offsetof(IntInt, idx));
00521
00522 typedef struct { float val; float idx; } FloatFloat;
00523 addStruct(predefinedTypeTable_, "MPI_2FLOAT", MPI_2FLOAT, MPI_FLOAT, MPI_FLOAT, offsetof(FloatFloat, idx));
00524
00525 typedef struct { double val; double idx; } DoubleDouble;
00526 addStruct(predefinedTypeTable_, "MPI_2DOUBLE", MPI_2DOUBLE, MPI_DOUBLE, MPI_DOUBLE, offsetof(DoubleDouble, idx));
00527
00528 typedef struct { float val; int idx; } FloatInt;
00529 addStruct(predefinedTypeTable_, "MPI_FLOAT_INT", MPI_FLOAT_INT, MPI_FLOAT, MPI_INT, offsetof(FloatInt, idx));
00530
00531
00532 typedef struct { double val; int idx; } DoubleInt;
00533 addStruct(predefinedTypeTable_, "MPI_DOUBLE_INT", MPI_DOUBLE_INT, MPI_DOUBLE, MPI_INT, offsetof(DoubleInt, idx));
00534
00535 typedef struct { long val; int idx; } LongInt;
00536 addStruct(predefinedTypeTable_, "MPI_LONG_INT", MPI_LONG_INT, MPI_LONG, MPI_INT, offsetof(LongInt, idx));
00537
00538 typedef struct { short val; int idx; } ShortInt;
00539 addStruct(predefinedTypeTable_, "MPI_SHORT_INT", MPI_SHORT_INT, MPI_SHORT, MPI_INT, offsetof(ShortInt, idx));
00540
00541 typedef struct { long double val; int idx; } LongdoubleInt;
00542 addStruct(predefinedTypeTable_, "MPI_LONG_DOUBLE_INT", MPI_LONG_DOUBLE_INT, MPI_LONG_DOUBLE, MPI_INT,
00543 offsetof(LongdoubleInt, idx));
00544
00545
00546 typedef struct { float val; float idx; } FloatComplex;
00547 addStruct(predefinedTypeTable_, "MPI_FLOAT_COMPLEX", MPI_FLOAT_COMPLEX, MPI_FLOAT, MPI_FLOAT,
00548 offsetof(FloatComplex, idx));
00549 addStruct(predefinedTypeTable_, "MPI_COMPLEX", MPI_COMPLEX, MPI_FLOAT, MPI_FLOAT, offsetof(FloatComplex, idx));
00550
00551 typedef struct { double val; double idx; } DoubleComplex;
00552 addStruct(predefinedTypeTable_, "MPI_DOUBLE_COMPLEX", MPI_DOUBLE_COMPLEX, MPI_DOUBLE, MPI_DOUBLE,
00553 offsetof(DoubleComplex, idx));
00554
00555 typedef struct { long double val; long double idx; } LongDoubleComplex;
00556 addStruct(predefinedTypeTable_, "MPI_LONG_DOUBLE_COMPLEX", MPI_LONG_DOUBLE_COMPLEX, MPI_LONG_DOUBLE, MPI_LONG_DOUBLE,
00557 offsetof(LongDoubleComplex, idx));
00558 return predefinedTypeTable_;
00559 }
00560
00561 CkDDT(const array<const CkDDT_DataType *, AMPI_MAX_PREDEFINED_TYPE+1>& predefinedTypeTable_) noexcept : predefinedTypeTable(predefinedTypeTable_) {}
00562 CkDDT& operator=(const CkDDT &obj) = default;
00563 CkDDT(const CkDDT &obj) = default;
00564 ~CkDDT() noexcept;
00565
00566 void newContiguous(int count, MPI_Datatype oldType, MPI_Datatype* newType) noexcept;
00567 void newVector(int count, int blocklength, int stride, MPI_Datatype oldtype,
00568 MPI_Datatype* newtype) noexcept;
00569 void newHVector(int count, int blocklength, int stride, MPI_Datatype oldtype,
00570 MPI_Datatype* newtype) noexcept;
00571 void newIndexedBlock(int count, int Blocklength, const int *arrDisp, MPI_Datatype oldtype,
00572 MPI_Datatype *newtype) noexcept;
00573 void newHIndexedBlock(int count, int Blocklength, const MPI_Aint *arrDisp, MPI_Datatype oldtype,
00574 MPI_Datatype *newtype) noexcept;
00575 void newIndexed(int count, const int* arrbLength, MPI_Aint* arrDisp, MPI_Datatype oldtype,
00576 MPI_Datatype* newtype) noexcept;
00577 void newHIndexed(int count, const int* arrbLength, const MPI_Aint* arrDisp, MPI_Datatype oldtype,
00578 MPI_Datatype* newtype) noexcept;
00579 void newStruct(int count, const int* arrbLength, const MPI_Aint* arrDisp,
00580 const MPI_Datatype *oldtype, MPI_Datatype* newtype) noexcept;
00581
00582 int insertType(CkDDT_DataType* ptr, int type) noexcept;
00583 void freeType(int index) noexcept;
00584 void pup(PUP::er &p) noexcept;
00585 void createDup(int nIndexOld, int *nIndexNew) noexcept;
00586 void createResized(MPI_Datatype oldtype, MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype) noexcept;
00587 int getEnvelope(int nIndex, int *num_integers, int *num_addresses, int *num_datatypes,
00588 int *combiner) const noexcept;
00589 int getContents(int nIndex, int max_integers, int max_addresses, int max_datatypes,
00590 int array_of_integers[], MPI_Aint array_of_addresses[], int array_of_datatypes[]) noexcept;
00591
00592 CkDDT_DataType* getType(int nIndex) const noexcept {
00593 if (nIndex <= AMPI_MAX_PREDEFINED_TYPE) {
00594 CkAssert(nIndex >= 0);
00595 return const_cast<CkDDT_DataType *>(predefinedTypeTable[nIndex]);
00596 }
00597 else {
00598 CkAssert((nIndex - AMPI_MAX_PREDEFINED_TYPE - 1) < userTypeTable.size());
00599 return userTypeTable[nIndex - AMPI_MAX_PREDEFINED_TYPE - 1];
00600 }
00601 }
00602
00603 bool isContig(int nIndex) const noexcept { return getType(nIndex)->isContig(); }
00604 int getSize(int nIndex, int count=1) const noexcept { return count * getType(nIndex)->getSize(); }
00605 MPI_Aint getExtent(int nIndex) const noexcept { return getType(nIndex)->getExtent(); }
00606 MPI_Aint getLB(int nIndex) const noexcept { return getType(nIndex)->getLB(); }
00607 MPI_Aint getUB(int nIndex) const noexcept { return getType(nIndex)->getUB(); }
00608 MPI_Aint getTrueExtent(int nIndex) const noexcept { return getType(nIndex)->getTrueExtent(); }
00609 MPI_Aint getTrueLB(int nIndex) const noexcept { return getType(nIndex)->getTrueLB(); }
00610 void setName(int nIndex, const char *name) noexcept { getType(nIndex)->setName(name); }
00611 void getName(int nIndex, char *name, int *len) const noexcept { getType(nIndex)->getName(name, len); }
00612 };
00613
00614 #endif