From 8c725f8d5e7ca809c52ba9d13e31a727f53f1525 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Fri, 2 May 2014 16:00:12 +0200 Subject: [PATCH] Work on compilation speed. - h5/make_h5.... only used in parameters. - old boost includes before C++11 - remove boost serialization, make macro TRIQS_MAKE_NVP temporarely - remove boost::is_complex (can be written in 2 lines...) - move some lib in cpp --- test/triqs/gfs/mpi_red.cpp | 1 + triqs/arrays/blas_lapack/dot.hpp | 4 +- triqs/arrays/functional/fold.hpp | 3 - triqs/arrays/h5/array_stack.hpp | 4 +- triqs/arrays/h5/simple_read_write.hpp | 6 +- triqs/arrays/impl/assignment.hpp | 10 ++-- triqs/arrays/impl/common.hpp | 7 ++- triqs/arrays/impl/indexmap_storage_pair.hpp | 6 +- triqs/arrays/impl/make_const.hpp | 5 +- triqs/arrays/impl/traits.hpp | 6 +- triqs/arrays/indexmaps/common.hpp | 1 - triqs/arrays/indexmaps/cuboid/domain.hpp | 2 +- triqs/arrays/indexmaps/cuboid/map.hpp | 6 +- triqs/arrays/storages/mem_block.hpp | 4 +- triqs/arrays/storages/memcopy.hpp | 2 +- triqs/arrays/storages/shared_block.hpp | 4 +- triqs/arrays/vector.hpp | 16 +++--- triqs/det_manip/det_manip.hpp | 15 +++-- triqs/gfs/domains/discrete.hpp | 6 +- triqs/gfs/domains/legendre.hpp | 6 +- triqs/gfs/domains/matsubara.hpp | 4 +- triqs/gfs/gf.hpp | 8 +-- triqs/gfs/local/tail.hpp | 6 +- triqs/gfs/meshes/discrete.hpp | 2 +- triqs/gfs/meshes/linear.hpp | 16 +++--- triqs/gfs/meshes/matsubara_freq.hpp | 6 +- triqs/gfs/meshes/product.c11.hpp | 2 +- triqs/gfs/meshes/product.c14.hpp | 2 +- triqs/h5.hpp | 2 +- triqs/h5/base.hpp | 6 +- triqs/h5/vector.hpp | 6 +- triqs/lattice/bravais_lattice.hpp | 6 +- triqs/lattice/brillouin_zone.hpp | 2 +- triqs/lattice/bz_mesh.hpp | 4 +- triqs/parameters/defaults.hpp | 2 +- triqs/parameters/opaque_object_h5.hpp | 9 +-- triqs/parameters/parameters.hpp | 2 +- triqs/utility/concept_tools.hpp | 6 +- triqs/utility/draft/value_view.hpp | 4 +- .../is_complex.hpp} | 30 +++------- triqs/utility/mini_vector.hpp | 6 +- triqs/utility/mpi.hpp | 2 +- triqs/utility/typeid_name.cpp | 57 +++++++++++++++++++ triqs/utility/typeid_name.hpp | 44 +++----------- 44 files changed, 180 insertions(+), 168 deletions(-) rename triqs/{h5/h5_boost_python_exceptions.hpp => utility/is_complex.hpp} (58%) create mode 100644 triqs/utility/typeid_name.cpp diff --git a/test/triqs/gfs/mpi_red.cpp b/test/triqs/gfs/mpi_red.cpp index 240dbd76..4ee2e629 100644 --- a/test/triqs/gfs/mpi_red.cpp +++ b/test/triqs/gfs/mpi_red.cpp @@ -1,5 +1,6 @@ #define TRIQS_ARRAYS_ENFORCE_BOUNDCHECK #include +#include using namespace triqs::gfs; using namespace triqs::arrays; #define TEST(X) std::cout << BOOST_PP_STRINGIZE((X)) << " ---> "<< (X) < - typename std::enable_if::value && Star,T>::type + typename std::enable_if::value && Star,T>::type _conj(T && x) { return conj(std::forward(x));} template< bool Star, typename T> - typename std::enable_if::value && Star),T>::type + typename std::enable_if::value && Star),T>::type _conj(T && x) { return std::forward(x);} /** diff --git a/triqs/arrays/functional/fold.hpp b/triqs/arrays/functional/fold.hpp index d10c27af..3ab26c25 100644 --- a/triqs/arrays/functional/fold.hpp +++ b/triqs/arrays/functional/fold.hpp @@ -20,9 +20,6 @@ ******************************************************************************/ #ifndef TRIQS_ARRAYS_EXPRESSION_FOLD_H #define TRIQS_ARRAYS_EXPRESSION_FOLD_H -#include -#include -#include #include "../array.hpp" namespace triqs { diff --git a/triqs/arrays/h5/array_stack.hpp b/triqs/arrays/h5/array_stack.hpp index 71b4cfb6..df49af21 100644 --- a/triqs/arrays/h5/array_stack.hpp +++ b/triqs/arrays/h5/array_stack.hpp @@ -32,7 +32,7 @@ namespace arrays { static const size_t dim = R; static const bool base_is_array = dim > 0; size_t bufsize_, step, _size; - static const bool T_is_complex = boost::is_complex::value; + static const bool T_is_complex = triqs::is_complex::value; static const unsigned int RANK = dim + 1 + (T_is_complex ? 1 : 0); utility::mini_vector dims, offset, maxdims, dim_chunk, buffer_dim, zero; H5::DataSet dataset; @@ -67,7 +67,7 @@ namespace arrays { cparms.setChunk(RANK, dim_chunk.ptr()); // Modify dataset creation properties, i.e. enable chunking. try { dataset = g.create_dataset(name, h5::native_type_from_C(typename h5::remove_complex::type()), mspace1, cparms); - if (boost::is_complex::value) h5::write_string_attribute(&dataset, "__complex__", "1"); + if (triqs::is_complex::value) h5::write_string_attribute(&dataset, "__complex__", "1"); } TRIQS_ARRAYS_H5_CATCH_EXCEPTION; } diff --git a/triqs/arrays/h5/simple_read_write.hpp b/triqs/arrays/h5/simple_read_write.hpp index d897c85c..7dbc74d0 100644 --- a/triqs/arrays/h5/simple_read_write.hpp +++ b/triqs/arrays/h5/simple_read_write.hpp @@ -42,7 +42,7 @@ namespace arrays { if (S1[u] <= 0) TRIQS_RUNTIME_ERROR << " negative strides not permitted in h5"; S[u] = 1; } - static const bool is_complex = boost::is_complex::value; + static const bool is_complex = triqs::is_complex::value; return h5::dataspace_from_LS(A.indexmap().domain().lengths(), A.indexmap().domain().lengths(), S); } @@ -82,7 +82,7 @@ namespace arrays { H5::DataSet ds = g.create_dataset(name, h5::data_type_file(), data_space(A)); ds.write(__get_array_data_cptr(A), h5::data_type_memory(), data_space(A)); // if complex, to be python compatible, we add the __complex__ attribute - if (boost::is_complex::value) h5::write_string_attribute(&ds, "__complex__", "1"); + if (triqs::is_complex::value) h5::write_string_attribute(&ds, "__complex__", "1"); } TRIQS_ARRAYS_H5_CATCH_EXCEPTION; } @@ -108,7 +108,7 @@ namespace arrays { try { H5::DataSet ds = g.open_dataset(name); H5::DataSpace dataspace = ds.getSpace(); - static const unsigned int Rank = ArrayType::rank + (boost::is_complex::value ? 1 : 0); + static const unsigned int Rank = ArrayType::rank + (triqs::is_complex::value ? 1 : 0); int rank = dataspace.getSimpleExtentNdims(); if (rank != Rank) TRIQS_RUNTIME_ERROR << "triqs::array::h5::read. Rank mismatch : the array has rank = " << Rank diff --git a/triqs/arrays/impl/assignment.hpp b/triqs/arrays/impl/assignment.hpp index 6303ea22..ac86292c 100644 --- a/triqs/arrays/impl/assignment.hpp +++ b/triqs/arrays/impl/assignment.hpp @@ -39,16 +39,16 @@ namespace triqs { namespace arrays { } template - void triqs_arrays_compound_assign_delegation (LHS & lhs, const RHS & rhs, mpl::char_ ) { + void triqs_arrays_compound_assign_delegation (LHS & lhs, const RHS & rhs, char_ ) { static_assert( !LHS::is_const, "Can not apply a compound operator to a const view !"); assignment::impl(lhs, rhs).invoke(); } #define TRIQS_DEFINE_COMPOUND_OPERATORS(MYTYPE)\ - template MYTYPE & operator +=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'A'>()); return *this;}\ - template MYTYPE & operator -=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'S'>()); return *this;}\ - template MYTYPE & operator *=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'M'>()); return *this;}\ - template MYTYPE & operator /=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, mpl::char_<'D'>()); return *this;} + template MYTYPE & operator +=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'A'>()); return *this;}\ + template MYTYPE & operator -=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'S'>()); return *this;}\ + template MYTYPE & operator *=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'M'>()); return *this;}\ + template MYTYPE & operator /=(RHS const & rhs) { triqs_arrays_compound_assign_delegation (*this,rhs, char_<'D'>()); return *this;} #define TRIQS_DELETE_COMPOUND_OPERATORS(MYTYPE)\ template MYTYPE & operator +=(RHS const & rhs) = delete;\ diff --git a/triqs/arrays/impl/common.hpp b/triqs/arrays/impl/common.hpp index 9009411d..7a750db4 100644 --- a/triqs/arrays/impl/common.hpp +++ b/triqs/arrays/impl/common.hpp @@ -31,10 +31,11 @@ #include #include #include +#include -#include -#include -#include +template using char_ = std::integral_constant; + +#include #include #include // LEADS to an error on OS X??? diff --git a/triqs/arrays/impl/indexmap_storage_pair.hpp b/triqs/arrays/impl/indexmap_storage_pair.hpp index 968806c3..b30982d9 100644 --- a/triqs/arrays/impl/indexmap_storage_pair.hpp +++ b/triqs/arrays/impl/indexmap_storage_pair.hpp @@ -28,8 +28,6 @@ #include "triqs/utility/exceptions.hpp" #include "triqs/utility/typeid_name.hpp" #include "triqs/utility/view_tools.hpp" -#include -#include #include #ifdef TRIQS_WITH_PYTHON_SUPPORT #include "../python/numpy_extractor.hpp" @@ -328,8 +326,8 @@ namespace triqs { namespace arrays { friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::make_nvp("storage",this->storage_); - ar & boost::serialization::make_nvp("indexmap",this->indexmap_); + ar & TRIQS_MAKE_NVP("storage",this->storage_); + ar & TRIQS_MAKE_NVP("indexmap",this->indexmap_); } // pretty print of the array diff --git a/triqs/arrays/impl/make_const.hpp b/triqs/arrays/impl/make_const.hpp index 3529dedd..29472692 100644 --- a/triqs/arrays/impl/make_const.hpp +++ b/triqs/arrays/impl/make_const.hpp @@ -19,11 +19,8 @@ * TRIQS. If not, see . * ******************************************************************************/ - #ifndef TRIQS_ARRAYS_MAKE_CONST_H #define TRIQS_ARRAYS_MAKE_CONST_H -#include -#include namespace triqs { namespace arrays { @@ -32,7 +29,7 @@ namespace triqs { namespace arrays { * make_const_type : make the type constant. * For a storage, it transforms it into a storage */ - template struct make_const_type : boost::mpl::if_c::type, T> {}; + template struct make_const_type : std::conditional::type, T> {}; } }}//namespace triqs::arrays #endif diff --git a/triqs/arrays/impl/traits.hpp b/triqs/arrays/impl/traits.hpp index 76740a10..afea8f3d 100644 --- a/triqs/arrays/impl/traits.hpp +++ b/triqs/arrays/impl/traits.hpp @@ -22,6 +22,8 @@ #define TRIQS_ARRAYS_IMPL_TRAITS_H #include #include +#include +#include namespace triqs { namespace arrays { @@ -67,11 +69,11 @@ namespace arrays { template struct is_amv_view_class : _or, is_matrix_view, is_vector_view> {}; template struct is_amv_value_or_view_class : _or, is_amv_view_class> {}; - template struct is_scalar : _or, boost::is_complex> {}; + template struct is_scalar : _or, triqs::is_complex> {}; template struct is_scalar_for - : std::conditional::value, is_scalar, boost::is_same>::type { + : std::conditional::value, is_scalar, std::is_same>::type { }; } } // namespace triqs::arrays diff --git a/triqs/arrays/indexmaps/common.hpp b/triqs/arrays/indexmaps/common.hpp index f31621f8..031d02fb 100644 --- a/triqs/arrays/indexmaps/common.hpp +++ b/triqs/arrays/indexmaps/common.hpp @@ -23,7 +23,6 @@ #include "../impl/common.hpp" #include //#include "../impl/tuple_tools.hpp" -#include #include namespace boost { namespace serialization { class access;}} diff --git a/triqs/arrays/indexmaps/cuboid/domain.hpp b/triqs/arrays/indexmaps/cuboid/domain.hpp index a87a6199..1b571e55 100644 --- a/triqs/arrays/indexmaps/cuboid/domain.hpp +++ b/triqs/arrays/indexmaps/cuboid/domain.hpp @@ -41,7 +41,7 @@ namespace triqs { namespace arrays { namespace indexmaps { namespace cuboid { typedef mini_vector n_uple; n_uple lengths_; friend class boost::serialization::access; - template void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("dimensions",lengths_);} + template void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("dimensions",lengths_);} public : static constexpr unsigned int rank = Rank; typedef n_uple index_value_type; diff --git a/triqs/arrays/indexmaps/cuboid/map.hpp b/triqs/arrays/indexmaps/cuboid/map.hpp index 62f63cca..585477aa 100644 --- a/triqs/arrays/indexmaps/cuboid/map.hpp +++ b/triqs/arrays/indexmaps/cuboid/map.hpp @@ -133,9 +133,9 @@ namespace triqs { namespace arrays { namespace indexmaps { namespace cuboid { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::make_nvp("domain",mydomain); - ar & boost::serialization::make_nvp("strides",strides_); - ar & boost::serialization::make_nvp("start_shift",start_shift_); + ar & TRIQS_MAKE_NVP("domain",mydomain); + ar & TRIQS_MAKE_NVP("strides",strides_); + ar & TRIQS_MAKE_NVP("start_shift",start_shift_); } // for construction void compute_stride_compact() { diff --git a/triqs/arrays/storages/mem_block.hpp b/triqs/arrays/storages/mem_block.hpp index 039194c9..10f6b4ff 100644 --- a/triqs/arrays/storages/mem_block.hpp +++ b/triqs/arrays/storages/mem_block.hpp @@ -265,8 +265,8 @@ namespace triqs { namespace arrays { namespace storages { //namespace details { template void save(Archive & ar, const unsigned int version) const { - ar << boost::serialization::make_nvp("size",size_); - for (size_t i=0; i diff --git a/triqs/arrays/storages/memcopy.hpp b/triqs/arrays/storages/memcopy.hpp index aa629fcc..dbd52d11 100644 --- a/triqs/arrays/storages/memcopy.hpp +++ b/triqs/arrays/storages/memcopy.hpp @@ -25,7 +25,7 @@ namespace triqs { namespace arrays { namespace storages { // beware : complex is not a pod - template struct is_scalar_or_pod : std::integral_constant::value || boost::is_complex::value || std::is_pod::value > {}; + template struct is_scalar_or_pod : std::integral_constant::value || triqs::is_complex::value || std::is_pod::value > {}; // copy such that it is a fast memcpy for scalar / pod objects // when not a scalar object, loop on elements diff --git a/triqs/arrays/storages/shared_block.hpp b/triqs/arrays/storages/shared_block.hpp index 0fcbb4a4..9d899ec1 100644 --- a/triqs/arrays/storages/shared_block.hpp +++ b/triqs/arrays/storages/shared_block.hpp @@ -103,11 +103,11 @@ namespace triqs { namespace arrays { namespace storages { friend class shared_block; friend class boost::serialization::access; template - void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("ptr",sptr); } + void save(Archive & ar, const unsigned int version) const { ar << TRIQS_MAKE_NVP("ptr",sptr); } template void load(Archive & ar, const unsigned int version) { if (sptr) dec_ref(sptr); - ar >> boost::serialization::make_nvp("ptr",sptr); data_ = (sptr ? sptr->p : nullptr); s = (sptr ? sptr->size() : 0); + ar >> TRIQS_MAKE_NVP("ptr",sptr); data_ = (sptr ? sptr->p : nullptr); s = (sptr ? sptr->size() : 0); if (sptr) inc_ref(sptr); } BOOST_SERIALIZATION_SPLIT_MEMBER(); diff --git a/triqs/arrays/vector.hpp b/triqs/arrays/vector.hpp index bfa6a23f..13a010c2 100644 --- a/triqs/arrays/vector.hpp +++ b/triqs/arrays/vector.hpp @@ -247,25 +247,25 @@ namespace triqs { namespace arrays { template typename boost::enable_if< is_vector_or_view >::type - triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, mpl::char_<'A'>) { + triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, char_<'A'>) { T a = 1.0; blas::axpy(a,rhs,lhs); } template typename boost::enable_if< is_vector_or_view >::type - triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, mpl::char_<'S'>) { + triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, char_<'S'>) { T a = -1.0; blas::axpy(a,rhs,lhs); } template typename boost::enable_if< is_scalar_for > >::type - triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, mpl::char_<'M'>) { + triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, char_<'M'>) { T a = rhs; blas::scal(a,lhs); } template typename boost::enable_if< is_scalar_for > >::type - triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, mpl::char_<'D'>) { + triqs_arrays_compound_assign_delegation (vector & lhs, RHS const & rhs, char_<'D'>) { T a = 1/rhs; blas::scal(a,lhs); } @@ -275,25 +275,25 @@ namespace triqs { namespace arrays { template typename boost::enable_if< is_vector_or_view >::type - triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, mpl::char_<'A'>) { + triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, char_<'A'>) { T a = 1.0; blas::axpy(a,rhs,lhs); } template typename boost::enable_if< is_vector_or_view >::type - triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, mpl::char_<'S'>) { + triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, char_<'S'>) { T a = -1.0; blas::axpy(a,rhs,lhs); } template typename boost::enable_if< is_scalar_for > >::type - triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, mpl::char_<'M'>) { + triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, char_<'M'>) { T a = rhs; blas::scal(a,lhs); } template typename boost::enable_if< is_scalar_for > >::type - triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, mpl::char_<'D'>) { + triqs_arrays_compound_assign_delegation (vector_view & lhs, RHS const & rhs, char_<'D'>) { T a = 1/rhs; blas::scal(a,lhs); } diff --git a/triqs/det_manip/det_manip.hpp b/triqs/det_manip/det_manip.hpp index 9b8230d6..602b8dc3 100644 --- a/triqs/det_manip/det_manip.hpp +++ b/triqs/det_manip/det_manip.hpp @@ -51,7 +51,7 @@ namespace triqs { namespace det_manip { typedef typename f_tr::template decay_arg<0>::type xy_type; typedef typename f_tr::result_type value_type; - static_assert( std::is_floating_point::value || boost::is_complex::value, "det_manip : the function must return a floating number or a complex number"); + static_assert( std::is_floating_point::value || triqs::is_complex::value, "det_manip : the function must return a floating number or a complex number"); typedef arrays::vector vector_type; typedef arrays::matrix matrix_type; @@ -78,13 +78,12 @@ namespace triqs { namespace det_manip { friend class boost::serialization::access; template void serialize(Archive & ar) { - using boost::serialization::make_nvp; - ar & make_nvp("Nmax",Nmax) & make_nvp("N",N) - & make_nvp("n_opts",n_opts) & make_nvp("n_opts_max_before_check",n_opts_max_before_check) - & make_nvp("det",det) & make_nvp("sign",sign) - & make_nvp("Minv",mat_inv) - & make_nvp("row_num",row_num) & make_nvp("col_num",col_num) - & make_nvp("x_values",x_values) & make_nvp("y_values",y_values); + ar & TRIQS_MAKE_NVP("Nmax",Nmax) & TRIQS_MAKE_NVP("N",N) + & TRIQS_MAKE_NVP("n_opts",n_opts) & TRIQS_MAKE_NVP("n_opts_max_before_check",n_opts_max_before_check) + & TRIQS_MAKE_NVP("det",det) & TRIQS_MAKE_NVP("sign",sign) + & TRIQS_MAKE_NVP("Minv",mat_inv) + & TRIQS_MAKE_NVP("row_num",row_num) & TRIQS_MAKE_NVP("col_num",col_num) + & TRIQS_MAKE_NVP("x_values",x_values) & TRIQS_MAKE_NVP("y_values",y_values); } /// Write into HDF5 diff --git a/triqs/gfs/domains/discrete.hpp b/triqs/gfs/domains/discrete.hpp index 40059fd1..0ad0f66f 100644 --- a/triqs/gfs/domains/discrete.hpp +++ b/triqs/gfs/domains/discrete.hpp @@ -75,9 +75,9 @@ namespace gfs { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { - ar& boost::serialization::make_nvp("n_max", Nmax); - ar& boost::serialization::make_nvp("names", _names); - ar& boost::serialization::make_nvp("names_inv", _inv_names); + ar& TRIQS_MAKE_NVP("n_max", Nmax); + ar& TRIQS_MAKE_NVP("names", _names); + ar& TRIQS_MAKE_NVP("names_inv", _inv_names); } }; } diff --git a/triqs/gfs/domains/legendre.hpp b/triqs/gfs/domains/legendre.hpp index dd606ef1..a615a1e8 100644 --- a/triqs/gfs/domains/legendre.hpp +++ b/triqs/gfs/domains/legendre.hpp @@ -66,9 +66,9 @@ namespace gfs { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { - ar& boost::serialization::make_nvp("n_max", Nmax); - ar& boost::serialization::make_nvp("beta", beta); - ar& boost::serialization::make_nvp("statistic", statistic); + ar& TRIQS_MAKE_NVP("n_max", Nmax); + ar& TRIQS_MAKE_NVP("beta", beta); + ar& TRIQS_MAKE_NVP("statistic", statistic); } }; } diff --git a/triqs/gfs/domains/matsubara.hpp b/triqs/gfs/domains/matsubara.hpp index cc8fcb81..65f288c0 100644 --- a/triqs/gfs/domains/matsubara.hpp +++ b/triqs/gfs/domains/matsubara.hpp @@ -97,8 +97,8 @@ namespace gfs { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int version) { - ar &boost::serialization::make_nvp("beta", beta); - ar &boost::serialization::make_nvp("statistic", statistic); + ar &TRIQS_MAKE_NVP("beta", beta); + ar &TRIQS_MAKE_NVP("statistic", statistic); } }; diff --git a/triqs/gfs/gf.hpp b/triqs/gfs/gf.hpp index ae9fa22f..554b5a9c 100644 --- a/triqs/gfs/gf.hpp +++ b/triqs/gfs/gf.hpp @@ -316,10 +316,10 @@ namespace gfs { //----------------------------- BOOST Serialization ----------------------------- friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int version) { - ar &boost::serialization::make_nvp("data", _data); - ar &boost::serialization::make_nvp("singularity", _singularity); - ar &boost::serialization::make_nvp("mesh", _mesh); - ar &boost::serialization::make_nvp("symmetry", _symmetry); + ar &TRIQS_MAKE_NVP("data", _data); + ar &TRIQS_MAKE_NVP("singularity", _singularity); + ar &TRIQS_MAKE_NVP("mesh", _mesh); + ar &TRIQS_MAKE_NVP("symmetry", _symmetry); } /// print diff --git a/triqs/gfs/local/tail.hpp b/triqs/gfs/local/tail.hpp index a2d78805..6a62af0a 100644 --- a/triqs/gfs/local/tail.hpp +++ b/triqs/gfs/local/tail.hpp @@ -167,9 +167,9 @@ namespace triqs { namespace gfs { namespace local { friend class boost::serialization::access; template void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::make_nvp("omin",omin); - ar & boost::serialization::make_nvp("mask",mask); - ar & boost::serialization::make_nvp("data",_data); + ar & TRIQS_MAKE_NVP("omin",omin); + ar & TRIQS_MAKE_NVP("mask",mask); + ar & TRIQS_MAKE_NVP("data",_data); } friend std::ostream & operator << (std::ostream & out, tail_impl const & x) { diff --git a/triqs/gfs/meshes/discrete.hpp b/triqs/gfs/meshes/discrete.hpp index 6e15738f..6279512f 100644 --- a/triqs/gfs/meshes/discrete.hpp +++ b/triqs/gfs/meshes/discrete.hpp @@ -89,7 +89,7 @@ namespace gfs { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int version) { - ar &boost::serialization::make_nvp("domain", _dom); + ar &TRIQS_MAKE_NVP("domain", _dom); } friend std::ostream &operator<<(std::ostream &sout, discrete_mesh const &m) { return sout << "Discrete Mesh"; } diff --git a/triqs/gfs/meshes/linear.hpp b/triqs/gfs/meshes/linear.hpp index 0e624e66..444526b9 100644 --- a/triqs/gfs/meshes/linear.hpp +++ b/triqs/gfs/meshes/linear.hpp @@ -165,14 +165,14 @@ namespace gfs { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int version) { - ar &boost::serialization::make_nvp("domain", _dom); - ar &boost::serialization::make_nvp("a_pt", a_pt); - ar &boost::serialization::make_nvp("b_pt", b_pt); - ar &boost::serialization::make_nvp("xmin", xmin); - ar &boost::serialization::make_nvp("xmax", xmax); - ar &boost::serialization::make_nvp("del", del); - ar &boost::serialization::make_nvp("size", L); - ar &boost::serialization::make_nvp("kind", meshk); + ar &TRIQS_MAKE_NVP("domain", _dom); + ar &TRIQS_MAKE_NVP("a_pt", a_pt); + ar &TRIQS_MAKE_NVP("b_pt", b_pt); + ar &TRIQS_MAKE_NVP("xmin", xmin); + ar &TRIQS_MAKE_NVP("xmax", xmax); + ar &TRIQS_MAKE_NVP("del", del); + ar &TRIQS_MAKE_NVP("size", L); + ar &TRIQS_MAKE_NVP("kind", meshk); } friend std::ostream &operator<<(std::ostream &sout, linear_mesh const &m) { return sout << "Linear Mesh of size " << m.L; } diff --git a/triqs/gfs/meshes/matsubara_freq.hpp b/triqs/gfs/meshes/matsubara_freq.hpp index a983827c..f189260f 100644 --- a/triqs/gfs/meshes/matsubara_freq.hpp +++ b/triqs/gfs/meshes/matsubara_freq.hpp @@ -147,9 +147,9 @@ namespace gfs { friend class boost::serialization::access; /// BOOST Serialization template void serialize(Archive &ar, const unsigned int version) { - ar &boost::serialization::make_nvp("domain", _dom); - ar &boost::serialization::make_nvp("size", _n_pts); - ar &boost::serialization::make_nvp("kind", _positive_only); + ar &TRIQS_MAKE_NVP("domain", _dom); + ar &TRIQS_MAKE_NVP("size", _n_pts); + ar &TRIQS_MAKE_NVP("kind", _positive_only); } /// Simple print (just blabla and the size) diff --git a/triqs/gfs/meshes/product.c11.hpp b/triqs/gfs/meshes/product.c11.hpp index 894b5968..8b888e93 100644 --- a/triqs/gfs/meshes/product.c11.hpp +++ b/triqs/gfs/meshes/product.c11.hpp @@ -235,7 +235,7 @@ namespace gfs { template size_t operator()(M &m, size_t N) { std::stringstream fs; fs << "MeshComponent" << N; - ar &boost::serialization::make_nvp(fs.str().c_str(), m); + ar &TRIQS_MAKE_NVP(fs.str().c_str(), m); return N + 1; } }; diff --git a/triqs/gfs/meshes/product.c14.hpp b/triqs/gfs/meshes/product.c14.hpp index 22da41db..76f74968 100644 --- a/triqs/gfs/meshes/product.c14.hpp +++ b/triqs/gfs/meshes/product.c14.hpp @@ -159,7 +159,7 @@ namespace gfs { /// BOOST Serialization friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int version) { - auto l = [&ar](auto &m, int N) { ar &boost::serialization::make_nvp("MeshComponent" + std::to_string(N), m); }; + auto l = [&ar](auto &m, int N) { ar &TRIQS_MAKE_NVP("MeshComponent" + std::to_string(N), m); }; triqs::tuple::for_each_enumerate(m_tuple, l); } diff --git a/triqs/h5.hpp b/triqs/h5.hpp index e8677dc5..8fa541a0 100644 --- a/triqs/h5.hpp +++ b/triqs/h5.hpp @@ -24,6 +24,6 @@ #include "./h5/scalar.hpp" #include "./h5/vector.hpp" #include "./h5/string.hpp" -#include "./h5/make_h5_read_write.hpp" +//#include "./h5/make_h5_read_write.hpp" #endif diff --git a/triqs/h5/base.hpp b/triqs/h5/base.hpp index 9bf72973..fbceff5a 100644 --- a/triqs/h5/base.hpp +++ b/triqs/h5/base.hpp @@ -24,7 +24,7 @@ #include #include #include "hdf5_hl.h" -#include +#include namespace triqs { @@ -97,14 +97,14 @@ namespace triqs { //------------- compute void * pointer to the data ---------------------------------- template - typename std::enable_if< boost::is_complex::value, typename std::conditional::value, const void *, void *>::type >::type + typename std::enable_if< triqs::is_complex::value, typename std::conditional::value, const void *, void *>::type >::type get_data_ptr (S * p) { typedef typename std::conditional::value, const typename S::value_type, typename S::value_type>::type T; return reinterpret_cast(p); } template - typename std::enable_if< !boost::is_complex::value, typename std::conditional::value, const void *, void *>::type >::type + typename std::enable_if< !triqs::is_complex::value, typename std::conditional::value, const void *, void *>::type >::type get_data_ptr (S * p) {return p;} // dataspace from lengths and strides. Correct for the complex. strides must be >0 diff --git a/triqs/h5/vector.hpp b/triqs/h5/vector.hpp index afe8eb55..6b951714 100644 --- a/triqs/h5/vector.hpp +++ b/triqs/h5/vector.hpp @@ -54,7 +54,7 @@ namespace triqs { template H5::DataSpace data_space_for_vector (std::vector const & V) { mini_vector L,S; S[0]=1;L[0] = V.size(); - return h5::dataspace_from_LS<1, boost::is_complex::value > (L,L,S); + return h5::dataspace_from_LS<1, triqs::is_complex::value > (L,L,S); } template @@ -63,7 +63,7 @@ namespace triqs { H5::DataSet ds = g.create_dataset(name, h5::data_type_file(), data_space_for_vector(V) ); ds.write( &V[0], h5::data_type_memory(), data_space_for_vector(V) ); // if complex, to be python compatible, we add the __complex__ attribute - if (boost::is_complex::value) h5::write_string_attribute(&ds,"__complex__","1"); + if (triqs::is_complex::value) h5::write_string_attribute(&ds,"__complex__","1"); } TRIQS_ARRAYS_H5_CATCH_EXCEPTION; } @@ -73,7 +73,7 @@ namespace triqs { try { H5::DataSet ds = g.open_dataset(name); H5::DataSpace dataspace = ds.getSpace(); - static const unsigned int Rank = 1 + (boost::is_complex::value ? 1 : 0); + static const unsigned int Rank = 1 + (triqs::is_complex::value ? 1 : 0); int rank = dataspace.getSimpleExtentNdims(); if (rank != Rank) TRIQS_RUNTIME_ERROR << "triqs : h5 : read vector. Rank mismatch : the array stored in the hdf5 file has rank = "< dims_out; diff --git a/triqs/lattice/bravais_lattice.hpp b/triqs/lattice/bravais_lattice.hpp index dbed5809..7137517c 100644 --- a/triqs/lattice/bravais_lattice.hpp +++ b/triqs/lattice/bravais_lattice.hpp @@ -67,9 +67,9 @@ namespace lattice { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { - ar& boost::serialization::make_nvp("units", units_); - ar& boost::serialization::make_nvp("atom_orb_pos", atom_orb_pos); - ar& boost::serialization::make_nvp("atom_orb_name", atom_orb_name); + ar& TRIQS_MAKE_NVP("units", units_); + ar& TRIQS_MAKE_NVP("atom_orb_pos", atom_orb_pos); + ar& TRIQS_MAKE_NVP("atom_orb_name", atom_orb_name); } private: diff --git a/triqs/lattice/brillouin_zone.hpp b/triqs/lattice/brillouin_zone.hpp index b9a4887d..991330e3 100644 --- a/triqs/lattice/brillouin_zone.hpp +++ b/triqs/lattice/brillouin_zone.hpp @@ -55,7 +55,7 @@ namespace lattice { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { - ar& boost::serialization::make_nvp("bravais_lattice", lattice_); + ar& TRIQS_MAKE_NVP("bravais_lattice", lattice_); } private: diff --git a/triqs/lattice/bz_mesh.hpp b/triqs/lattice/bz_mesh.hpp index 3d870581..60ca61f3 100644 --- a/triqs/lattice/bz_mesh.hpp +++ b/triqs/lattice/bz_mesh.hpp @@ -94,8 +94,8 @@ namespace lattice { // BOOST Serialization friend class boost::serialization::access; template void serialize(Archive &ar, const unsigned int version) { - ar &boost::serialization::make_nvp("domain", bz); - ar &boost::serialization::make_nvp("k_pt_stack", k_pt_stack); + ar &TRIQS_MAKE_NVP("domain", bz); + ar &TRIQS_MAKE_NVP("k_pt_stack", k_pt_stack); } friend std::ostream &operator<<(std::ostream &sout, bz_mesh const &m) { return sout << "Mesh over BZ "; } diff --git a/triqs/parameters/defaults.hpp b/triqs/parameters/defaults.hpp index 6d5c5a25..27aedca9 100644 --- a/triqs/parameters/defaults.hpp +++ b/triqs/parameters/defaults.hpp @@ -47,7 +47,7 @@ namespace triqs { namespace utility { friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("object_map",object_map); } + void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("object_map",object_map); } template parameter_defaults & insert(std::string const & key, T && def_val, std::string const & doc, bool opt) { object_map[key] = std::forward(def_val); diff --git a/triqs/parameters/opaque_object_h5.hpp b/triqs/parameters/opaque_object_h5.hpp index 5909cd7d..b771b6db 100644 --- a/triqs/parameters/opaque_object_h5.hpp +++ b/triqs/parameters/opaque_object_h5.hpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace triqs { namespace utility { @@ -171,14 +172,14 @@ namespace triqs { namespace utility { template void save(Archive & ar, const unsigned int version) const { std::string s = serialize_(); - ar << boost::serialization::make_nvp("type_name", type_code_to_type_name[type_code_]); - ar << boost::serialization::make_nvp("seria_str", s); + ar << TRIQS_MAKE_NVP("type_name", type_code_to_type_name[type_code_]); + ar << TRIQS_MAKE_NVP("seria_str", s); } template void load(Archive & ar, const unsigned int version) { std::string s, tnn; - ar >> boost::serialization::make_nvp("type_name", tnn); - ar >> boost::serialization::make_nvp("seria_str", s); + ar >> TRIQS_MAKE_NVP("type_name", tnn); + ar >> TRIQS_MAKE_NVP("seria_str", s); auto it = type_name_to_type_code.find(tnn); if (it== type_name_to_type_code.end()) TRIQS_RUNTIME_ERROR << " Can not deserialize the type "<< tnn<< "\n Did you forget to register it ?"; diff --git a/triqs/parameters/parameters.hpp b/triqs/parameters/parameters.hpp index 663ab990..1ffc211f 100644 --- a/triqs/parameters/parameters.hpp +++ b/triqs/parameters/parameters.hpp @@ -49,7 +49,7 @@ namespace triqs { namespace utility { friend class boost::serialization::access; template - void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("object_map",object_map); } + void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("object_map",object_map); } public: diff --git a/triqs/utility/concept_tools.hpp b/triqs/utility/concept_tools.hpp index 2b7ce339..37a3ade9 100644 --- a/triqs/utility/concept_tools.hpp +++ b/triqs/utility/concept_tools.hpp @@ -22,8 +22,6 @@ #define TRIQS_UTILITY_CONCEPT_TOOLS_H #include #include -#include -#include #define TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) MyBeautifulConcept##__concept_tag @@ -31,7 +29,7 @@ #define TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT(MyBeautifulConcept) \ struct TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) {};\ - template struct MyBeautifulConcept : boost::is_base_of {};\ + template struct MyBeautifulConcept : std::is_base_of {};\ template struct MyBeautifulConcept : MyBeautifulConcept{};\ template struct MyBeautifulConcept : MyBeautifulConcept{};\ template struct MyBeautifulConcept : MyBeautifulConcept{}; @@ -41,7 +39,7 @@ #define TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R(MyBeautifulConcept,Rs) \ struct TRIQS_CONCEPT_TAG_NAME(MyBeautifulConcept) : BOOST_PP_SEQ_FOR_EACH_I (TRIQS_DEFINE_CONCEPT_AND_ASSOCIATED_TRAIT_R_AUX,nil,Rs) {};\ - template struct MyBeautifulConcept : boost::is_base_of {};\ + template struct MyBeautifulConcept : std::is_base_of {};\ template struct MyBeautifulConcept : MyBeautifulConcept{};\ template struct MyBeautifulConcept : MyBeautifulConcept{};\ template struct MyBeautifulConcept : MyBeautifulConcept{}; diff --git a/triqs/utility/draft/value_view.hpp b/triqs/utility/draft/value_view.hpp index 218e1f32..36386c52 100644 --- a/triqs/utility/draft/value_view.hpp +++ b/triqs/utility/draft/value_view.hpp @@ -55,7 +55,7 @@ namespace triqs { // Boost serialization. Can I use std::shared_ptr directly ? Or use boost::shared_ptr friend class boost::serialization::access; template - void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("data",*p); } + void save(Archive & ar, const unsigned int version) const { ar << TRIQS_MAKE_NVP("data",*p); } template void load(Archive & ar, const unsigned int version) { T x; ar >> x; p = std::make_shared(x); } BOOST_SERIALIZATION_SPLIT_MEMBER(); @@ -85,7 +85,7 @@ namespace triqs { // Boost serialization. Can I use std::shared_ptr directly ? Or use boost::shared_ptr friend class boost::serialization::access; template - void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("data",*p); } + void save(Archive & ar, const unsigned int version) const { ar << TRIQS_MAKE_NVP("data",*p); } template void load(Archive & ar, const unsigned int version) { T x; ar >> x; p = std::make_shared(x); } BOOST_SERIALIZATION_SPLIT_MEMBER(); diff --git a/triqs/h5/h5_boost_python_exceptions.hpp b/triqs/utility/is_complex.hpp similarity index 58% rename from triqs/h5/h5_boost_python_exceptions.hpp rename to triqs/utility/is_complex.hpp index 494439c4..fb736801 100644 --- a/triqs/h5/h5_boost_python_exceptions.hpp +++ b/triqs/utility/is_complex.hpp @@ -1,9 +1,8 @@ - /******************************************************************************* * * TRIQS: a Toolbox for Research in Interacting Quantum Systems * - * Copyright (C) 2011 by M. Ferrero, O. Parcollet + * Copyright (C) 2014 by O. Parcollet * * TRIQS is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software @@ -19,26 +18,13 @@ * TRIQS. If not, see . * ******************************************************************************/ +#pragma once +#include +#include -#ifndef TRIQS_H5_EXCEPTIONS_H -#define TRIQS_H5_EXCEPTIONS_H +namespace triqs { + template struct is_complex : std::false_type{}; + template struct is_complex> : std::true_type{}; +} -#include -#include -#include -#include - -namespace triqs { namespace utility { - - // transcription of H5 error - inline void translatorH5Error(H5::Exception const& x) { - std::stringstream f; f<< " H5 exception\n"<(translatorH5Error);} - -}} - -#endif diff --git a/triqs/utility/mini_vector.hpp b/triqs/utility/mini_vector.hpp index de735c95..ebe72e8d 100644 --- a/triqs/utility/mini_vector.hpp +++ b/triqs/utility/mini_vector.hpp @@ -25,18 +25,22 @@ #include "./compiler_details.hpp" #include "./exceptions.hpp" #include +#include +#include #include #include #define TRIQS_MINI_VECTOR_NRANK_MAX 10 +#define TRIQS_MAKE_NVP(NAME,X) X +//#define TRIQS_MAKE_NVP(NAME,X) boost::serialization::make_nvp(NAME,X) namespace triqs { namespace utility { template class mini_vector { T _data[Rank]; friend class boost::serialization::access; - template void serialize(Archive & ar, const unsigned int version) { ar & boost::serialization::make_nvp("_data",_data); } + template void serialize(Archive & ar, const unsigned int version) { ar & TRIQS_MAKE_NVP("_data",_data); } void init() { for (int i=0;i struct mpi_impl::value || boost::is_complex::value)> { + template struct mpi_impl::value || triqs::is_complex::value)> { static void reduce_in_place (communicator _c, A & a, int root) { MPI_Reduce ((_c.rank()==root ? MPI_IN_PLACE:&a),&a,1, mpi_datatype::invoke(), MPI_SUM, root, _c); diff --git a/triqs/utility/typeid_name.cpp b/triqs/utility/typeid_name.cpp new file mode 100644 index 00000000..507e12b4 --- /dev/null +++ b/triqs/utility/typeid_name.cpp @@ -0,0 +1,57 @@ +/******************************************************************************* + * + * TRIQS: a Toolbox for Research in Interacting Quantum Systems + * + * Copyright (C) 2011 by M. Ferrero, O. Parcollet + * + * TRIQS is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * TRIQS. If not, see . + * + ******************************************************************************/ +#include +#include "./typeid_name.hpp" +#include + +#ifdef __GNUC__ +#include +#endif + +#include + +namespace triqs { namespace utility { + + std::string demangle(const char * name) { + std::stringstream fs; +#ifdef __GNUC__ + int status; + char * demangled = abi::__cxa_demangle(name, NULL, NULL, &status); + if (!status) { + std::string res(demangled); + boost::erase_all(res,", boost::tuples::null_type"); + boost::erase_all(res,", -1"); + boost::erase_all(res,", void"); + fs<< res; + free(demangled); + } else fs<< name; + //fs<. * ******************************************************************************/ -#ifndef TRIQS_TYPE_ID_NAME_H -#define TRIQS_TYPE_ID_NAME_H - +#pragma once #include -#include - -#ifdef __GNUC__ -#include -#endif - -#include namespace triqs { namespace utility { - inline std::string demangle(const char * name) { - std::stringstream fs; -#ifdef __GNUC__ - int status; - char * demangled = abi::__cxa_demangle(name, NULL, NULL, &status); - if (!status) { - std::string res(demangled); - boost::erase_all(res,", boost::tuples::null_type"); - boost::erase_all(res,", -1"); - boost::erase_all(res,", void"); - fs<< res; - free(demangled); - } else fs<< name; - //fs< - std::string typeid_name(T const & A) { return demangle(typeid(A).name());} +std::string demangle(const char * name); +std::string demangle(std::string const & name); +std::string get_name(std::type_info const &info); template - std::string typeid_name() { return demangle(typeid(std::declval()).name());} + std::string typeid_name(T const & A) { return get_name(typeid(A));} + + template + std::string typeid_name() { return get_name(typeid(std::declval()));} }} -#endif