libMesh::Parallel::StandardType< TypeVector< T > > Class Template Reference

#include <parallel_algebra.h>

Inheritance diagram for libMesh::Parallel::StandardType< TypeVector< T > >:

Public Member Functions

 StandardType (const TypeVector< T > *example=NULL)
 
 operator const data_type & () const
 
 operator data_type & ()
 
void commit ()
 
void free ()
 

Protected Attributes

data_type _datatype
 

Detailed Description

template<typename T>
class libMesh::Parallel::StandardType< TypeVector< T > >

Definition at line 54 of file parallel_algebra.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::Parallel::StandardType< TypeVector< T > >::StandardType ( const TypeVector< T > *  example = NULL)
inlineexplicit

Definition at line 58 of file parallel_algebra.h.

References libMesh::Parallel::DataType::_datatype, libMesh::libMeshPrivateData::_is_initialized, libMesh::AutoPtr< Tp >::get(), and libMesh::AutoPtr< Tp >::reset().

58  {
59  // We need an example for MPI_Address to use
60  TypeVector<T> *ex;
61  AutoPtr<TypeVector<T> > temp;
62  if (example)
63  ex = const_cast<TypeVector<T> *>(example);
64  else
65  {
66  temp.reset(new TypeVector<T>());
67  ex = temp.get();
68  }
69 
70  // _static_type never gets freed, but it only gets committed once
71  // per T, so it's not a *huge* memory leak...
72  static data_type _static_type;
73  static bool _is_initialized = false;
74  if (!_is_initialized)
75  {
76 #ifdef LIBMESH_HAVE_MPI
77  StandardType<T> T_type(&((*ex)(0)));
78 
79 #if MPI_VERSION == 1
80 
81  int blocklengths[LIBMESH_DIM+2];
82  MPI_Aint displs[LIBMESH_DIM+2];
83  MPI_Datatype types[LIBMESH_DIM+2];
84  MPI_Aint start, later;
85 
86  MPI_Address(ex, &start);
87  blocklengths[0] = 1;
88  displs[0] = 0;
89  types[0] = MPI_LB;
90  for (unsigned int i=0; i != LIBMESH_DIM; ++i)
91  {
92  MPI_Address(&((*ex)(i)), &later);
93  blocklengths[i+1] = 1;
94  displs[i+1] = later - start;
95  types[i+1] = T_type;
96  }
97  MPI_Address((ex+1), &later);
98  blocklengths[LIBMESH_DIM+1] = 1;
99  displs[LIBMESH_DIM+1] = later - start;
100  types[LIBMESH_DIM+1] = MPI_UB;
101 
102  MPI_Type_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);
103 
104 #else // MPI_VERSION >= 2
105 
106  int blocklength = LIBMESH_DIM;
107  MPI_Aint displs, start;
108  MPI_Datatype tmptype, type = T_type;
109 
110  MPI_Get_address (ex, &start);
111  MPI_Get_address (&((*ex)(0)), &displs);
112 
113  // subtract off offset to first value from the beginning of the structure
114  displs -= start;
115 
116  // create a prototype structure
117  MPI_Type_create_struct (1, &blocklength, &displs, &type, &tmptype);
118 
119  // resize the structure type to account for padding, if any
120  MPI_Type_create_resized (tmptype, 0, sizeof(TypeVector<T>), &_static_type);
121 #endif
122 
123  MPI_Type_commit (&_static_type);
124 #endif // #ifdef LIBMESH_HAVE_MPI
125 
126  _is_initialized = true;
127  }
128  _datatype = _static_type;
129  }

Member Function Documentation

void libMesh::Parallel::DataType::commit ( )
inlineinherited

Definition at line 277 of file parallel.h.

References libMesh::Parallel::DataType::_datatype.

Referenced by libMesh::Parallel::DataType::DataType().

278  {
279 #ifdef LIBMESH_HAVE_MPI
280  MPI_Type_commit (&_datatype);
281 #endif
282  }
libMesh::Parallel::DataType::operator const data_type & ( ) const
inlineinherited

Definition at line 265 of file parallel.h.

References libMesh::Parallel::DataType::_datatype.

266  { return _datatype; }
libMesh::Parallel::DataType::operator data_type & ( )
inlineinherited

Definition at line 268 of file parallel.h.

References libMesh::Parallel::DataType::_datatype.

269  { return _datatype; }

Member Data Documentation


The documentation for this class was generated from the following file:

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:02 UTC

Hosted By:
SourceForge.net Logo