This source file includes following definitions.
- ompi_datatype_create_struct
   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 #include "ompi_config.h"
  26 
  27 #include <stddef.h>
  28 
  29 #include "ompi/datatype/ompi_datatype.h"
  30 
  31 int32_t ompi_datatype_create_struct( int count, const int* pBlockLength, const ptrdiff_t* pDisp,
  32                                      ompi_datatype_t* const * pTypes, ompi_datatype_t** newType )
  33 {
  34     ptrdiff_t disp = 0, endto, lastExtent, lastDisp;
  35     ompi_datatype_t *pdt, *lastType;
  36     int lastBlock;
  37     int i, start_from;
  38 
  39     
  40     for( i = 0; (i < count) && (0 == pBlockLength[i]); i++ );
  41     if( i == count ) {  
  42         return ompi_datatype_duplicate( &ompi_mpi_datatype_null.dt, newType);
  43     }
  44     
  45 
  46 
  47     start_from = i;
  48     lastType = (ompi_datatype_t*)pTypes[start_from];
  49     lastBlock = pBlockLength[start_from];
  50     lastExtent = lastType->super.ub - lastType->super.lb;
  51     lastDisp = pDisp[start_from];
  52     endto = pDisp[start_from] + lastExtent * lastBlock;
  53 
  54     for( i = (start_from + 1); i < count; i++ ) {
  55         if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
  56             lastBlock += pBlockLength[i];
  57             endto = lastDisp + lastBlock * lastExtent;
  58         } else {
  59             disp += lastType->super.desc.used;
  60             if( lastBlock > 1 ) disp += 2;
  61             lastType = (ompi_datatype_t*)pTypes[i];
  62             lastExtent = lastType->super.ub - lastType->super.lb;
  63             lastBlock = pBlockLength[i];
  64             lastDisp = pDisp[i];
  65             endto = lastDisp + lastExtent * lastBlock;
  66         }
  67     }
  68     disp += lastType->super.desc.used;
  69     if( lastBlock != 1 ) disp += 2;
  70 
  71     lastType = (ompi_datatype_t*)pTypes[start_from];
  72     lastBlock = pBlockLength[start_from];
  73     lastExtent = lastType->super.ub - lastType->super.lb;
  74     lastDisp = pDisp[start_from];
  75     endto = pDisp[start_from] + lastExtent * lastBlock;
  76 
  77     pdt = ompi_datatype_create( (int32_t)disp );
  78 
  79     
  80     for( i = (start_from + 1); i < count; i++ ) {
  81         if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
  82             lastBlock += pBlockLength[i];
  83             endto = lastDisp + lastBlock * lastExtent;
  84         } else {
  85             ompi_datatype_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
  86             lastType = (ompi_datatype_t*)pTypes[i];
  87             lastExtent = lastType->super.ub - lastType->super.lb;
  88             lastBlock = pBlockLength[i];
  89             lastDisp = pDisp[i];
  90             endto = lastDisp + lastExtent * lastBlock;
  91         }
  92     }
  93     ompi_datatype_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
  94 
  95      *newType = pdt;
  96     return OMPI_SUCCESS;
  97 }