x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
datatype.hpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\mpi\datatype.hpp
Girar
Efecto
Propiedad
Historial
// Copyright 2004 The Trustees of Indiana University. // Copyright 2005 Matthias Troyer. // Copyright 2006 Douglas Gregor
. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Authors: Douglas Gregor // Andrew Lumsdaine // Matthias Troyer /** @file datatype.hpp * * This header provides the mapping from C++ types to MPI data types. */ #ifndef BOOST_MPI_DATATYPE_HPP #define BOOST_MPI_DATATYPE_HPP #include
#include
#include
#include
#include
#include
#include
#include
#include
// for std::pair namespace boost { namespace mpi { /** * @brief Type trait that determines if there exists a built-in * integer MPI data type for a given C++ type. * * This ytpe trait determines when there is a direct mapping from a * C++ type to an MPI data type that is classified as an integer data * type. See @c is_mpi_builtin_datatype for general information about * built-in MPI data types. */ template
struct is_mpi_integer_datatype : public boost::mpl::false_ { }; /** * @brief Type trait that determines if there exists a built-in * floating point MPI data type for a given C++ type. * * This ytpe trait determines when there is a direct mapping from a * C++ type to an MPI data type that is classified as a floating * point data type. See @c is_mpi_builtin_datatype for general * information about built-in MPI data types. */ template
struct is_mpi_floating_point_datatype : public boost::mpl::false_ { }; /** * @brief Type trait that determines if there exists a built-in * logical MPI data type for a given C++ type. * * This ytpe trait determines when there is a direct mapping from a * C++ type to an MPI data type that is classified as an logical data * type. See @c is_mpi_builtin_datatype for general information about * built-in MPI data types. */ template
struct is_mpi_logical_datatype : public boost::mpl::false_ { }; /** * @brief Type trait that determines if there exists a built-in * complex MPI data type for a given C++ type. * * This ytpe trait determines when there is a direct mapping from a * C++ type to an MPI data type that is classified as an complex data * type. See @c is_mpi_builtin_datatype for general information about * built-in MPI data types. */ template
struct is_mpi_complex_datatype : public boost::mpl::false_ { }; /** * @brief Type trait that determines if there exists a built-in * byte MPI data type for a given C++ type. * * This ytpe trait determines when there is a direct mapping from a * C++ type to an MPI data type that is classified as an byte data * type. See @c is_mpi_builtin_datatype for general information about * built-in MPI data types. */ template
struct is_mpi_byte_datatype : public boost::mpl::false_ { }; /** @brief Type trait that determines if there exists a built-in MPI * data type for a given C++ type. * * This type trait determines when there is a direct mapping from a * C++ type to an MPI type. For instance, the C++ @c int type maps * directly to the MPI type @c MPI_INT. When there is a direct * mapping from the type @c T to an MPI type, @c * is_mpi_builtin_datatype will derive from @c mpl::true_ and the MPI * data type will be accessible via @c get_mpi_datatype. * * In general, users should not need to specialize this * trait. However, if you have an additional C++ type that can map * directly to only of MPI's built-in types, specialize either this * trait or one of the traits corresponding to categories of MPI data * types (@c is_mpi_integer_datatype, @c * is_mpi_floating_point_datatype, @c is_mpi_logical_datatype, @c * is_mpi_complex_datatype, or @c is_mpi_builtin_datatype). @c * is_mpi_builtin_datatype derives @c mpl::true_ if any of the traits * corresponding to MPI data type categories derived @c mpl::true_. */ template
struct is_mpi_builtin_datatype : boost::mpl::or_
, is_mpi_floating_point_datatype
, is_mpi_logical_datatype
, is_mpi_complex_datatype
, is_mpi_byte_datatype
> { }; /** @brief Type trait that determines if a C++ type can be mapped to * an MPI data type. * * This type trait determines if it is possible to build an MPI data * type that represents a C++ data type. When this is the case, @c * is_mpi_datatype derives @c mpl::true_ and the MPI data type will * be accessible via @c get_mpi_datatype. * For any C++ type that maps to a built-in MPI data type (see @c * is_mpi_builtin_datatype), @c is_mpi_data_type is trivially * true. However, any POD ("Plain Old Data") type containing types * that themselves can be represented by MPI data types can itself be * represented as an MPI data type. For instance, a @c point3d class * containing three @c double values can be represented as an MPI * data type. To do so, first make the data type Serializable (using * the Boost.Serialization library); then, specialize the @c * is_mpi_datatype trait for the point type so that it will derive @c * mpl::true_: * * @code * namespace boost { namespace mpi { * template<> struct is_mpi_datatype
* : public mpl::true_ { }; * } } * @endcode */ template
struct is_mpi_datatype : public is_mpi_builtin_datatype
{ }; /** @brief Returns an MPI data type for a C++ type. * * The function creates an MPI data type for the given object @c * x. The first time it is called for a class @c T, the MPI data type * is created and cached. Subsequent calls for objects of the same * type @c T return the cached MPI data type. The type @c T must * allow creation of an MPI data type. That is, it must be * Serializable and @c is_mpi_datatype
must derive @c mpl::true_. * * For fundamental MPI types, a copy of the MPI data type of the MPI * library is returned. * * Note that since the data types are cached, the caller should never * call @c MPI_Type_free() for the MPI data type returned by this * call. * * @param x for an optimized call, a constructed object of the type * should be passed; otherwise, an object will be * default-constructed. * * @returns The MPI data type corresponding to type @c T. */ template
MPI_Datatype get_mpi_datatype(const T& x) { BOOST_MPL_ASSERT((is_mpi_datatype
)); return detail::mpi_datatype_cache.datatype(x); } // Don't parse this part when we're generating Doxygen documentation. #ifndef BOOST_MPI_DOXYGEN /// INTERNAL ONLY #define BOOST_MPI_DATATYPE(CppType, MPIType, Kind) \ template<> \ inline MPI_Datatype \ get_mpi_datatype< CppType >(const CppType&) { return MPIType; } \ \ template<> \ struct BOOST_JOIN(is_mpi_,BOOST_JOIN(Kind,_datatype))< CppType > \ : boost::mpl::bool_
\ {} /// INTERNAL ONLY BOOST_MPI_DATATYPE(char, MPI_CHAR, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(short, MPI_SHORT, integer); /// INTERNAL ONLY BOOST_MPI_DATATYPE(int, MPI_INT, integer); /// INTERNAL ONLY BOOST_MPI_DATATYPE(long, MPI_LONG, integer); /// INTERNAL ONLY BOOST_MPI_DATATYPE(float, MPI_FLOAT, floating_point); /// INTERNAL ONLY BOOST_MPI_DATATYPE(double, MPI_DOUBLE, floating_point); /// INTERNAL ONLY BOOST_MPI_DATATYPE(long double, MPI_LONG_DOUBLE, floating_point); /// INTERNAL ONLY BOOST_MPI_DATATYPE(unsigned char, MPI_UNSIGNED_CHAR, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(unsigned short, MPI_UNSIGNED_SHORT, integer); /// INTERNAL ONLY BOOST_MPI_DATATYPE(unsigned, MPI_UNSIGNED, integer); /// INTERNAL ONLY BOOST_MPI_DATATYPE(unsigned long, MPI_UNSIGNED_LONG, integer); /// INTERNAL ONLY #define BOOST_MPI_LIST2(A, B) A, B /// INTERNAL ONLY BOOST_MPI_DATATYPE(std::pair
, MPI_FLOAT_INT, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(std::pair
, MPI_DOUBLE_INT, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(std::pair
, MPI_LONG_DOUBLE_INT, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(std::pair
), MPI_LONG_INT, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(std::pair
), MPI_SHORT_INT, builtin); /// INTERNAL ONLY BOOST_MPI_DATATYPE(std::pair
), MPI_2INT, builtin); #undef BOOST_MPI_LIST2 #if 0 #ifndef BOOST_NO_INTRINSIC_WCHAR_T BOOST_MPI_DATATYPE(wchar_t, MPI_WCHAR, builtin); #endif #ifdef BOOST_HAS_LONG_LONG BOOST_MPI_DATATYPE(long long, MPI_LONG_LONG_INT, builtin); BOOST_MPI_DATATYPE(unsigned long long, MPI_UNSIGNED_LONG_LONG, builtin); #endif #endif #endif // Doxygen namespace detail { inline MPI_Datatype build_mpi_datatype_for_bool() { MPI_Datatype type; MPI_Type_contiguous(sizeof(bool), MPI_BYTE, &type); MPI_Type_commit(&type); return type; } } /// Support for bool. There is no corresponding MPI_BOOL. /// INTERNAL ONLY template<> inline MPI_Datatype get_mpi_datatype
(const bool&) { static MPI_Datatype type = detail::build_mpi_datatype_for_bool(); return type; } /// INTERNAL ONLY template<> struct is_mpi_datatype
: boost::mpl::bool_
{}; /// INTERNAL ONLY template
struct is_mpi_datatype
> : mpl::and_
, is_mpi_datatype
> { }; } } // end namespace boost::mpi #endif // BOOST_MPI_MPI_DATATYPE_HPP
datatype.hpp
Dirección de la página
Dirección del archivo
Anterior
6/22
Siguiente
Descargar
( 10 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.