[Dune] [Dune-Commit] dune-geometry r57 - trunk/dune/geometry/genericgeometry

Carsten Gräser graeser at math.fu-berlin.de
Mon Apr 2 13:54:58 CEST 2012


Hi Martin,

Am 02.04.2012 11:45, schrieb mnolte at dune-project.org:
> Author: mnolte
> Date: 2012-04-02 11:45:06 +0200 (Mon, 02 Apr 2012)
> New Revision: 57
> 
> Modified:
>    trunk/dune/geometry/genericgeometry/cachedmapping.hh
> Log:
> use a bitfield (slightly reduces memory consumption)
are you sure that this really reduces memory consumption?
If you have more members than just the bitfield you might
get padding due to alignment rules. In the attached example
struct A containing only a bitfield has the expected size
of one byte while all the others have 12 byte (x86, gcc-4.6.1).

Best,
Carsten

struct A
{
    bool a_:1;
    bool b_:1;
    bool c_:1;
};

struct B
{
    double x_;
    bool a_:1;
    bool b_:1;
    bool c_:1;
};

struct C
{
    double x_;
    bool a_;
};

struct D
{
    double x_;
    bool a_;
    bool b_;
    bool c_;
    bool d_;
};


> 
> 
> Modified: trunk/dune/geometry/genericgeometry/cachedmapping.hh
> ===================================================================
> --- trunk/dune/geometry/genericgeometry/cachedmapping.hh	2012-04-01 08:52:17 UTC (rev 56)
> +++ trunk/dune/geometry/genericgeometry/cachedmapping.hh	2012-04-02 09:45:06 UTC (rev 57)
> @@ -41,10 +41,6 @@
>  
>        typedef typename GeometryTraits::Caching Caching;
>  
> -      typename Traits::JacobianTransposedType jacobianTransposed;
> -      typename Traits::JacobianType jacobianInverseTransposed;
> -      typename Traits::FieldType integrationElement;
> -
>        CachedStorage ()
>        : affine( false ),
>          jacobianTransposedComputed( false ),
> @@ -52,11 +48,15 @@
>          integrationElementComputed( false )
>        {}
>  
> -      bool affine;
> +      typename Traits::JacobianTransposedType jacobianTransposed;
> +      typename Traits::JacobianType jacobianInverseTransposed;
> +      typename Traits::FieldType integrationElement;
>  
> -      bool jacobianTransposedComputed;        // = affine, if jacobian transposed was computed
> -      bool jacobianInverseTransposedComputed; // = affine, if jacobian inverse transposed was computed
> -      bool integrationElementComputed;        // = affine, if integration element was computed
> +      bool affine : 1;
> +
> +      bool jacobianTransposedComputed : 1;        // = affine, if jacobian transposed was computed
> +      bool jacobianInverseTransposedComputed : 1; // = affine, if jacobian inverse transposed was computed
> +      bool integrationElementComputed : 1;        // = affine, if integration element was computed
>      };
>  
>  
> 
> 
> _______________________________________________
> Dune-Commit mailing list
> Dune-Commit at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-commit


-- 
----------------------------------------------------------------------
Dr. Carsten Gräser       | phone: +49-30 / 838-75349
Freie Universität Berlin | fax  : +49-30 / 838-54977
Institut für Mathematik  | email: graeser at math.fu-berlin.de
Arnimallee 6             |
14195 Berlin, Germany    | URL  : http://page.mi.fu-berlin.de/graeser
----------------------------------------------------------------------




More information about the Dune mailing list