branch: upgrade_to_cpp14_consolidated commit fd7dc6e95054fef8908e2c06f97ab2022ee023ba Author: aa <a...@plaxis.com> Date: Thu Apr 4 15:58:23 2019 +0200
1) no more thread static pointer from boost, using thread_static qualifier instead 2) removing "register" keyword, as it's considered deprecated --- src/bgeot_geometric_trans.cc | 10 +-- src/getfem/bgeot_tensor.h | 8 +- src/getfem/dal_basic.h | 28 +++---- src/getfem/getfem_omp.h | 30 +------ src/getfem_fem.cc | 98 +++++++++++----------- ...fem_generic_assembly_functions_and_operators.cc | 15 +--- src/getfem_integration.cc | 24 +++--- src/getfem_linearized_plates.cc | 4 +- src/getfem_mat_elem.cc | 8 +- src/gmm/gmm_domain_decomp.h | 6 +- 10 files changed, 96 insertions(+), 135 deletions(-) diff --git a/src/bgeot_geometric_trans.cc b/src/bgeot_geometric_trans.cc index 0b1cc6a..97a127b 100644 --- a/src/bgeot_geometric_trans.cc +++ b/src/bgeot_geometric_trans.cc @@ -29,22 +29,22 @@ namespace bgeot { std::vector<scalar_type>& __aux1(){ - DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, v); + THREAD_SAFE_STATIC std::vector<scalar_type> v; return v; } std::vector<scalar_type>& __aux2(){ - DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, v); + THREAD_SAFE_STATIC std::vector<scalar_type> v; return v; } std::vector<scalar_type>& __aux3(){ - DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>, v); + THREAD_SAFE_STATIC std::vector<scalar_type> v; return v; } std::vector<long>& __ipvt_aux(){ - DEFINE_STATIC_THREAD_LOCAL(std::vector<long>, vi); + THREAD_SAFE_STATIC std::vector<long> vi; return vi; } @@ -279,7 +279,7 @@ namespace bgeot { auto itpc_j = pc.begin() + j*P, itG_b = G.begin(); for (size_type i = 0; i < N; ++i, ++itG_b) { auto itG = itG_b, itpc = itpc_j; - register scalar_type a = *(itG) * (*itpc); + scalar_type a = *(itG) * (*itpc); for (size_type k = 1; k < P; ++k) { itG += N; a += *(itG) * (*++itpc); } *itK++ = a; diff --git a/src/getfem/bgeot_tensor.h b/src/getfem/bgeot_tensor.h index 7979157..ebf2671 100644 --- a/src/getfem/bgeot_tensor.h +++ b/src/getfem/bgeot_tensor.h @@ -336,8 +336,8 @@ namespace bgeot { /* reduction du tenseur t par son indice ni et la matrice */ /* transposee de m. */ - DEFINE_STATIC_THREAD_LOCAL(std::vector<T>, tmp); - DEFINE_STATIC_THREAD_LOCAL(multi_index, mi); + THREAD_SAFE_STATIC std::vector<T> tmp; + THREAD_SAFE_STATIC multi_index mi; mi = t.sizes(); size_type dimt = mi[ni], dim = m.nrows(); @@ -403,8 +403,8 @@ namespace bgeot { template<class T> void tensor<T>::mat_reduction (const tensor &t, const gmm::dense_matrix<T> &m, int ni) { /* reduction du tenseur t par son indice ni et la matrice m. */ - DEFINE_STATIC_THREAD_LOCAL(std::vector<T>, tmp); - DEFINE_STATIC_THREAD_LOCAL(multi_index, mi); + THREAD_SAFE_STATIC std::vector<T> tmp; + THREAD_SAFE_STATIC multi_index mi; mi = t.sizes(); size_type dimt = mi[ni], dim = m.ncols(); diff --git a/src/getfem/dal_basic.h b/src/getfem/dal_basic.h index 878b996..f3acbd5 100644 --- a/src/getfem/dal_basic.h +++ b/src/getfem/dal_basic.h @@ -282,7 +282,7 @@ namespace dal /* ********************************************************************* */ - /* Menbers functions */ + /* Member functions */ /* ********************************************************************* */ @@ -313,9 +313,9 @@ namespace dal typename pointer_array::iterator ite = it+ ((last_ind + DNAMPKS__) >> pks); while (it != ite) { *it = std::unique_ptr<T[]>(new T[DNAMPKS__+1]);// std::make_unique<T[]>(DNAMPKS__+1); - register pointer p = it->get(); ++it; - register pointer pe = p + (DNAMPKS__+1); - register const_pointer pa = (ita++)->get(); + pointer p = it->get(); ++it; + pointer pe = p + (DNAMPKS__+1); + const_pointer pa = (ita++)->get(); while (p != pe) *p++ = *pa++; } return *this; @@ -324,9 +324,8 @@ namespace dal template<class T, unsigned char pks> typename dynamic_array<T,pks>::const_reference dynamic_array<T,pks>::operator [](size_type ii) const { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(std::shared_ptr<T>,pf,NULL); - if (pf.get() == NULL) { pf = std::make_shared<T>(); } - return (ii<last_ind) ? (array[ii>>pks])[ii&DNAMPKS__] : *pf; + THREAD_SAFE_STATIC T f; + return (ii<last_ind) ? (array[ii>>pks])[ii&DNAMPKS__] : f; } template<class T, unsigned char pks> typename dynamic_array<T,pks>::reference @@ -336,13 +335,14 @@ namespace dal last_accessed = ii + 1; if (ii >= last_ind) { - if ((ii >> (pks+ppks)) > 0) { - while ((ii >> (pks+ppks)) > 0) ppks++; - array.resize(m_ppks = (size_type(1) << ppks)); m_ppks--; - } - for (size_type jj = (last_ind >> pks); ii >= last_ind; - jj++, last_ind += (DNAMPKS__ + 1)) - { array[jj] = std::unique_ptr<T[]>(new T[DNAMPKS__+1]); } // std::make_unique<T[]>(DNAMPKS__ + 1); } + if ((ii >> (pks+ppks)) > 0) { + while ((ii >> (pks+ppks)) > 0) ppks++; + array.resize(m_ppks = (size_type(1) << ppks)); m_ppks--; + } + for (size_type jj = (last_ind >> pks); ii >= last_ind; + jj++, last_ind += (DNAMPKS__ + 1)){ + array[jj] = std::unique_ptr<T[]>(new T[DNAMPKS__+1]); + } // std::make_unique<T[]>(DNAMPKS__ + 1); } } } return (array[ii >> pks])[ii & DNAMPKS__]; diff --git a/src/getfem/getfem_omp.h b/src/getfem/getfem_omp.h index 17e8a7e..13d0691 100644 --- a/src/getfem/getfem_omp.h +++ b/src/getfem/getfem_omp.h @@ -47,8 +47,6 @@ This is the kernel of getfem. #ifdef GETFEM_HAS_OPENMP #include <mutex> - #include <boost/thread.hpp> /**TODO: get rid of this dependency as soon - as thread_local is widely supported*/ #endif namespace getfem @@ -341,33 +339,9 @@ namespace getfem and their initialization (it's more general and portable then using __declspec(thread))*/ #ifdef GETFEM_HAS_OPENMP - - #define DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(Type,Var,initial) \ - static boost::thread_specific_ptr<Type> ptr_##Var; \ - if(!ptr_##Var.get()) {ptr_##Var.reset(new Type(initial));} \ - Type& Var=*ptr_##Var; - - #define DEFINE_STATIC_THREAD_LOCAL(Type,Var) \ - static boost::thread_specific_ptr<Type> ptr_##Var; \ - if(!ptr_##Var.get()) {ptr_##Var.reset(new Type());} \ - Type& Var=*ptr_##Var; - - #define DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(Type, Var, ...) \ - static boost::thread_specific_ptr<Type> ptr_##Var; \ - if(!ptr_##Var.get()) {ptr_##Var.reset(new Type(__VA_ARGS__));} \ - Type& Var=*ptr_##Var; - + #define THREAD_SAFE_STATIC thread_local #else - - #define DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(Type,Var,initial) \ - static Type Var(initial); - - #define DEFINE_STATIC_THREAD_LOCAL(Type,Var) \ - static Type Var; - - #define DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(Type, Var, ...) \ - static Type Var(__VA_ARGS__); - + #define THREAD_SAFE_STATIC static #endif class partition_master; diff --git a/src/getfem_fem.cc b/src/getfem_fem.cc index 263da5c..f0c0e9e 100644 --- a/src/getfem_fem.cc +++ b/src/getfem_fem.cc @@ -383,8 +383,8 @@ namespace getfem { typedef dal::dynamic_tree_sorted<dof_description, dof_description_comp__> dof_d_tab; pdof_description lagrange_dof(dim_type n) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(dim_type, n_old, dim_type(-2)); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pdof_description, p_old, 0); + THREAD_SAFE_STATIC dim_type n_old = dim_type(-2); + THREAD_SAFE_STATIC pdof_description p_old = nullptr; if (n != n_old) { dof_d_tab& tab = dal::singleton<dof_d_tab>::instance(); dof_description l; @@ -397,8 +397,8 @@ namespace getfem { } pdof_description lagrange_0_dof(dim_type n) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(dim_type, n_old, dim_type(-2)); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pdof_description, p_old, 0); + THREAD_SAFE_STATIC dim_type n_old = dim_type(-2); + THREAD_SAFE_STATIC pdof_description p_old = nullptr; if (n != n_old) { dof_d_tab& tab = dal::singleton<dof_d_tab>::instance(); dof_description l; @@ -3174,10 +3174,10 @@ namespace getfem { void hermite_segment__::mat_trans(base_matrix &M, const base_matrix &G, bgeot::pgeometric_trans pgt) const { - DEFINE_STATIC_THREAD_LOCAL(bgeot::pgeotrans_precomp, pgp); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_stored, 0); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, K, 1, 1); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_vector,r, 1); + THREAD_SAFE_STATIC bgeot::pgeotrans_precomp pgp; + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_stored = nullptr; + THREAD_SAFE_STATIC base_matrix K(1, 1); + THREAD_SAFE_STATIC base_vector r(1); dim_type N = dim_type(G.nrows()); if (pgt != pgt_stored) { @@ -3240,9 +3240,9 @@ namespace getfem { const base_matrix &G, bgeot::pgeometric_trans pgt) const { - DEFINE_STATIC_THREAD_LOCAL(bgeot::pgeotrans_precomp, pgp); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_stored, 0); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, K, 2, 2); + THREAD_SAFE_STATIC bgeot::pgeotrans_precomp pgp; + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_stored = nullptr; + THREAD_SAFE_STATIC base_matrix K(2, 2); dim_type N = dim_type(G.nrows()); GMM_ASSERT1(N == 2, "Sorry, this version of hermite " @@ -3312,9 +3312,9 @@ namespace getfem { void hermite_tetrahedron__::mat_trans(base_matrix &M, const base_matrix &G, bgeot::pgeometric_trans pgt) const { - DEFINE_STATIC_THREAD_LOCAL(bgeot::pgeotrans_precomp, pgp); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_stored, 0); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, K, 3, 3); + THREAD_SAFE_STATIC bgeot::pgeotrans_precomp pgp; + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_stored = nullptr; + THREAD_SAFE_STATIC base_matrix K(3, 3); dim_type N = dim_type(G.nrows()); GMM_ASSERT1(N == 3, "Sorry, this version of hermite " "element works only on dimension three.") @@ -3416,10 +3416,10 @@ namespace getfem { const base_matrix &G, bgeot::pgeometric_trans pgt) const { - DEFINE_STATIC_THREAD_LOCAL(bgeot::pgeotrans_precomp, pgp); - DEFINE_STATIC_THREAD_LOCAL(pfem_precomp, pfp); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_stored, 0); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, K, 2, 2); + THREAD_SAFE_STATIC bgeot::pgeotrans_precomp pgp; + THREAD_SAFE_STATIC pfem_precomp pfp; + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_stored = nullptr; + THREAD_SAFE_STATIC base_matrix K(2, 2); dim_type N = dim_type(G.nrows()); GMM_ASSERT1(N == 2, "Sorry, this version of argyris " "element works only on dimension two.") @@ -3458,7 +3458,7 @@ namespace getfem { M(5+6*k, 3+6*k) = c*c; M(5+6*k, 4+6*k) = c*d; M(5+6*k, 5+6*k) = d*d; } - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, W, 3, 21); + THREAD_SAFE_STATIC base_matrix W(3, 21); base_small_vector norient(M_PI, M_PI * M_PI); if (pgt->is_linear()) gmm::lu_inverse(K); for (unsigned i = 18; i < 21; ++i) { @@ -3477,11 +3477,11 @@ namespace getfem { for (unsigned j = 0; j < 21; ++j) W(i-18, j) = t(j, 0, 0) * v[0] + t(j, 0, 1) * v[1]; } - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix,A,3,3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(bgeot::base_vector, w, 3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(bgeot::base_vector, coeff, 3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(gmm::sub_interval, SUBI, 18,3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(gmm::sub_interval, SUBJ, 0,3); + THREAD_SAFE_STATIC base_matrix A(3,3); + THREAD_SAFE_STATIC bgeot::base_vector w(3); + THREAD_SAFE_STATIC bgeot::base_vector coeff(3); + THREAD_SAFE_STATIC gmm::sub_interval SUBI(18, 3); + THREAD_SAFE_STATIC gmm::sub_interval SUBJ(0, 3); gmm::copy(gmm::sub_matrix(W, SUBJ, SUBI), A); gmm::lu_inverse(A); gmm::copy(gmm::transposed(A), gmm::sub_matrix(M, SUBI)); @@ -3587,10 +3587,10 @@ namespace getfem { const base_matrix &G, bgeot::pgeometric_trans pgt) const { - DEFINE_STATIC_THREAD_LOCAL(bgeot::pgeotrans_precomp, pgp); - DEFINE_STATIC_THREAD_LOCAL(pfem_precomp, pfp); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_stored, 0); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, K, 2, 2); + THREAD_SAFE_STATIC bgeot::pgeotrans_precomp pgp; + THREAD_SAFE_STATIC pfem_precomp pfp; + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_stored = nullptr; + THREAD_SAFE_STATIC base_matrix K(2, 2); dim_type N = dim_type(G.nrows()); GMM_ASSERT1(N == 2, "Sorry, this version of morley " "element works only on dimension two.") @@ -3601,7 +3601,7 @@ namespace getfem { pfp = fem_precomp(std::make_shared<morley_triangle__>(), node_tab(0), 0); } gmm::copy(gmm::identity_matrix(), M); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, W, 3, 6); + THREAD_SAFE_STATIC base_matrix W(3, 6); base_small_vector norient(M_PI, M_PI * M_PI); if (pgt->is_linear()) { gmm::mult(G, pgp->grad(0), K); gmm::lu_inverse(K); } @@ -3623,11 +3623,11 @@ namespace getfem { } // cout << "W = " << W << endl; getchar(); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_matrix, A, 3, 3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_vector, w, 3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(base_vector, coeff, 3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(gmm::sub_interval, SUBI, 3, 3); - DEFINE_STATIC_THREAD_LOCAL_CONSTRUCTED(gmm::sub_interval, SUBJ, 0, 3); + THREAD_SAFE_STATIC base_matrix A(3, 3); + THREAD_SAFE_STATIC base_vector w(3); + THREAD_SAFE_STATIC base_vector coeff(3); + THREAD_SAFE_STATIC gmm::sub_interval SUBI(3, 3); + THREAD_SAFE_STATIC gmm::sub_interval SUBJ(0, 3); gmm::copy(gmm::sub_matrix(W, SUBJ, SUBI), A); gmm::lu_inverse(A); gmm::copy(gmm::transposed(A), gmm::sub_matrix(M, SUBI)); @@ -3777,12 +3777,12 @@ namespace getfem { static pfem classical_fem_(bgeot::pgeometric_trans pgt, short_type k, bool complete=false, bool discont=false, scalar_type alpha=0) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_last,0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(short_type, k_last, short_type(-1)); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pfem, fem_last, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(char, complete_last, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(char, discont_last, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(scalar_type, alpha_last, 0); + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_last = nullptr; + THREAD_SAFE_STATIC short_type k_last = short_type(-1); + THREAD_SAFE_STATIC pfem fem_last = nullptr; + THREAD_SAFE_STATIC char complete_last = 0; + THREAD_SAFE_STATIC char discont_last = 0; + THREAD_SAFE_STATIC scalar_type alpha_last = 0; bool found = false; if (pgt_last == pgt && k_last == k && complete_last == complete && @@ -3978,9 +3978,9 @@ namespace getfem { /* ******************************************************************** */ pfem PK_fem(size_type n, short_type k) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pfem, pf, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(size_type, d, size_type(-2)); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(short_type, r, short_type(-2)); + THREAD_SAFE_STATIC pfem pf = nullptr; + THREAD_SAFE_STATIC size_type d = size_type(-2); + THREAD_SAFE_STATIC short_type r = short_type(-2); if (d != n || r != k) { std::stringstream name; name << "FEM_PK(" << n << "," << k << ")"; @@ -3991,9 +3991,9 @@ namespace getfem { } pfem QK_fem(size_type n, short_type k) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pfem, pf, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(size_type, d, size_type(-2)); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(short_type, r, short_type(-2)); + THREAD_SAFE_STATIC pfem pf = nullptr; + THREAD_SAFE_STATIC size_type d = size_type(-2); + THREAD_SAFE_STATIC short_type r = short_type(-2); if (d != n || r != k) { std::stringstream name; name << "FEM_QK(" << n << "," << k << ")"; @@ -4004,9 +4004,9 @@ namespace getfem { } pfem prism_PK_fem(size_type n, short_type k) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pfem, pf, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(size_type, d, size_type(-2)); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(short_type, r, short_type(-2)); + THREAD_SAFE_STATIC pfem pf = nullptr; + THREAD_SAFE_STATIC size_type d = size_type(-2); + THREAD_SAFE_STATIC short_type r = short_type(-2); if (d != n || r != k) { std::stringstream name; name << "FEM_PRISM_PK(" << n << "," << k << ")"; diff --git a/src/getfem_generic_assembly_functions_and_operators.cc b/src/getfem_generic_assembly_functions_and_operators.cc index 3193528..14bb626 100644 --- a/src/getfem_generic_assembly_functions_and_operators.cc +++ b/src/getfem_generic_assembly_functions_and_operators.cc @@ -28,24 +28,11 @@ compilers */ -#if defined(_MSC_VER) && _MSC_VER < 1800 -#include <boost/math/special_functions/acosh.hpp> -#include <boost/math/special_functions/asinh.hpp> -#include <boost/math/special_functions/atanh.hpp> -#include <boost/math/special_functions/erf.hpp> -typedef double (*BoostMathFunction)(double); -BoostMathFunction const acosh = boost::math::acosh<double>; -BoostMathFunction const asinh = boost::math::asinh<double>; -BoostMathFunction const atanh = boost::math::atanh<double>; -BoostMathFunction const erf = boost::math::erf<double>; -BoostMathFunction const erfc = boost::math::erfc<double>; -#endif - namespace getfem { base_matrix& __mat_aux1() { - DEFINE_STATIC_THREAD_LOCAL(base_matrix, m); + THREAD_SAFE_STATIC base_matrix m; return m; } diff --git a/src/getfem_integration.cc b/src/getfem_integration.cc index 911a2b0..ce14aa5 100644 --- a/src/getfem_integration.cc +++ b/src/getfem_integration.cc @@ -1149,8 +1149,8 @@ namespace getfem { /* Fonctions pour la ref. directe. */ pintegration_method exact_simplex_im(size_type n) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pintegration_method, pim, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(size_type, d, -2); + THREAD_SAFE_STATIC pintegration_method pim = nullptr; + THREAD_SAFE_STATIC size_type d = -2; if (d != n) { std::stringstream name; name << "IM_EXACT_SIMPLEX(" << n << ")"; @@ -1161,8 +1161,8 @@ namespace getfem { } pintegration_method exact_parallelepiped_im(size_type n) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pintegration_method, pim, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(size_type, d, -2); + THREAD_SAFE_STATIC pintegration_method pim = nullptr; + THREAD_SAFE_STATIC size_type d = -2; if (d != n) { std::stringstream name; name << "IM_EXACT_PARALLELEPIPED(" << n << ")"; @@ -1173,8 +1173,8 @@ namespace getfem { } pintegration_method exact_prism_im(size_type n) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pintegration_method, pim, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(size_type, d, -2); + THREAD_SAFE_STATIC pintegration_method pim = nullptr; + THREAD_SAFE_STATIC size_type d = -2; if (d != n) { std::stringstream name; name << "IM_EXACT_PRISM(" << n << ")"; @@ -1190,8 +1190,8 @@ namespace getfem { static pintegration_method classical_exact_im(bgeot::pconvex_structure cvs) { cvs = bgeot::basic_structure(cvs); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pconvex_structure,cvs_last, 0); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pintegration_method, im_last, 0); + THREAD_SAFE_STATIC bgeot::pconvex_structure cvs_last = nullptr; + THREAD_SAFE_STATIC pintegration_method im_last = nullptr; bool found = false; if (cvs_last == cvs) @@ -1279,9 +1279,9 @@ namespace getfem { pintegration_method classical_approx_im(bgeot::pgeometric_trans pgt, dim_type degree) { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bgeot::pgeometric_trans, pgt_last, 0); - DEFINE_STATIC_THREAD_LOCAL(dim_type, degree_last); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pintegration_method, im_last, 0); + THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_last = nullptr; + THREAD_SAFE_STATIC dim_type degree_last; + THREAD_SAFE_STATIC pintegration_method im_last = nullptr; if (pgt_last == pgt && degree == degree_last) return im_last; im_last = classical_approx_im_(pgt->structure(),degree); @@ -1291,7 +1291,7 @@ namespace getfem { } pintegration_method im_none() { - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pintegration_method,im_last,0); + THREAD_SAFE_STATIC pintegration_method im_last = nullptr; if (!im_last) im_last = int_method_descriptor("IM_NONE"); return im_last; } diff --git a/src/getfem_linearized_plates.cc b/src/getfem_linearized_plates.cc index 55cba5e..d7fb4c3 100644 --- a/src/getfem_linearized_plates.cc +++ b/src/getfem_linearized_plates.cc @@ -105,8 +105,8 @@ namespace getfem { virtual void give_transformation(const mesh_fem &mf, size_type cv, base_matrix &M) const{ - DEFINE_STATIC_THREAD_LOCAL(base_matrix, M_old); - DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(pfem, pf_old, 0); + THREAD_SAFE_STATIC base_matrix M_old; + THREAD_SAFE_STATIC pfem pf_old = nullptr; // Obtaining the fem descriptors pfem pf1 = mf.fem_of_element(cv); diff --git a/src/getfem_mat_elem.cc b/src/getfem_mat_elem.cc index 9c5ea77..463552c 100644 --- a/src/getfem_mat_elem.cc +++ b/src/getfem_mat_elem.cc @@ -376,10 +376,10 @@ namespace getfem { void expand_product_daxpy(base_tensor &t, scalar_type J, bool first)const { size_type k; base_tensor::iterator pt = t.begin(); - DEFINE_STATIC_THREAD_LOCAL(std::vector<base_tensor::const_iterator>, pts); - DEFINE_STATIC_THREAD_LOCAL(std::vector<base_tensor::const_iterator>,es_beg); - DEFINE_STATIC_THREAD_LOCAL(std::vector<base_tensor::const_iterator>,es_end); - DEFINE_STATIC_THREAD_LOCAL(std::vector<scalar_type>,Vtab); + THREAD_SAFE_STATIC std::vector<base_tensor::const_iterator> pts; + THREAD_SAFE_STATIC std::vector<base_tensor::const_iterator> es_beg; + THREAD_SAFE_STATIC std::vector<base_tensor::const_iterator> es_end; + THREAD_SAFE_STATIC std::vector<scalar_type> Vtab; pts.resize(0); pts.resize(pme->size()); // resize(0) necessary, do not remove es_beg.resize(0); es_beg.resize(pme->size()); diff --git a/src/gmm/gmm_domain_decomp.h b/src/gmm/gmm_domain_decomp.h index 2821f3a..f2a4f69 100644 --- a/src/gmm/gmm_domain_decomp.h +++ b/src/gmm/gmm_domain_decomp.h @@ -81,9 +81,9 @@ namespace gmm { std::vector<size_type> ns(dim), na(dim), nu(dim); for (size_type i = 0; i < nbpts; ++i) { for (int k = 0; k < dim; ++k) { - register double a = (pts[i][k] - pmin[k]) / msize; - ns[k] = size_type(a) - 1; na[k] = 0; - pts1[k] = int(a + overlap); pts2[k] = int(ceil(a-1.0-overlap)); + double a = (pts[i][k] - pmin[k]) / msize; + ns[k] = size_type(a) - 1; na[k] = 0; + pts1[k] = int(a + overlap); pts2[k] = int(ceil(a-1.0-overlap)); } size_type sum = 0; do {