1 /*! 2 * \file mfront/include/MFront/BehaviourProfiler.hxx 3 * \brief 4 * \author Thomas Helfer 5 * \brief 15 mai 2014 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #ifndef LIB_MFRONT_MFRONTBEHAVIOURPROFILER_HXX 15 #define LIB_MFRONT_MFRONTBEHAVIOURPROFILER_HXX 16 17 #include"TFEL/Config/TFELConfig.hxx" 18 #if defined _MSC_VER 19 #define MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER const 20 #else 21 #define MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER constexpr const 22 #include<time.h> 23 #endif 24 25 #include"MFront/MFrontConfig.hxx" 26 27 #include<array> 28 #include<atomic> 29 #include<string> 30 31 namespace mfront{ 32 33 /*! 34 * structure in charge of performance measurements in mechanical 35 * behaviour 36 */ 37 struct MFRONTPROFILING_VISIBILITY_EXPORT BehaviourProfiler 38 { 39 //! a simple alias 40 using index_type = unsigned short; 41 /*! 42 * a timer for a specicied code block. 43 * This descructor will increase the time count for the code block. 44 */ 45 struct MFRONTPROFILING_VISIBILITY_EXPORT Timer { 46 /*! 47 * \param[in,out] t : global timer 48 * \param[in] cn : code block 49 */ 50 Timer(BehaviourProfiler&, 51 const index_type); 52 //! destructor 53 ~Timer(); 54 protected: 55 Timer(const Timer&) = default; 56 Timer(Timer&&) = default; 57 Timer& operator=(const Timer&) = delete; 58 Timer& operator=(Timer&&) = delete; 59 //! timer to which the results are reported 60 BehaviourProfiler& gtimer; 61 //! code block associated with the timer 62 const index_type c; 63 #if !(defined _WIN32 || defined _WIN64 || defined __APPLE__) 64 //! start 65 timespec start; 66 //! end 67 timespec end; 68 #endif 69 }; // end of struct Timer 70 /*! 71 * constructor 72 * \param[in] n : behaviour name 73 */ 74 explicit BehaviourProfiler(const std::string&); 75 /* 76 * \see MechanialBehaviourData for a description 77 */ 78 //! code block index in the measures array 79 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 80 index_type FLOWRULE = 0; 81 //! code block index in the measures array 82 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 83 index_type BEFOREINITIALIZELOCALVARIABLES = 1; 84 //! code block index in the measures array 85 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 86 index_type INITIALIZELOCALVARIABLES = 2; 87 //! code block index in the measures array 88 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 89 index_type AFTERINITIALIZELOCALVARIABLES = 3; 90 //! code block index in the measures array 91 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 92 index_type COMPUTEPREDICTOR = 4; 93 //! code block index in the measures array 94 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 95 index_type COMPUTEPREDICTIONOPERATOR = 5; 96 //! code block index in the measures array 97 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 98 index_type INTEGRATOR = 6; 99 //! code block index in the measures array 100 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 101 index_type COMPUTESTRESS = 7; 102 //! code block index in the measures array 103 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 104 index_type COMPUTEDERIVATIVE = 8; 105 //! code block index in the measures array 106 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 107 index_type INITIALIZEJACOBIAN = 9; 108 //! code block index in the measures array 109 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 110 index_type COMPUTEFDF = 10; 111 //! code block index in the measures array 112 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 113 index_type TINYMATRIXSOLVE = 11; 114 //! code block index in the measures array 115 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 116 index_type COMPUTEFINALSTRESS = 12; 117 //! code block index in the measures array 118 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 119 index_type COMPUTETANGENTOPERATOR = 13; 120 //! code block index in the measures array 121 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 122 index_type UPDATEAUXILIARYSTATEVARIABLES = 14; 123 //! code block index in the measures array 124 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 125 index_type FINITESTRAINPREPROCESSING = 15; 126 //! code block index in the measures array 127 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 128 index_type FINITESTRAINPOSTPROCESSING = 16; 129 //! code block index in the measures array 130 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 131 index_type USERDEFINEDCODE1 = 17; 132 //! code block index in the measures array 133 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 134 index_type USERDEFINEDCODE2 = 18; 135 //! code block index in the measures array 136 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 137 index_type ADDITIONALCONVERGENCECHECKS = 19; 138 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 139 index_type APRIORITIMESTEPSCALINGFACTOR = 20; 140 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 141 index_type APOSTERIORITIMESTEPSCALINGFACTOR = 21; 142 //! code block index in the measures array 143 static MFRONTBEHAVIOURPROFILER_CONST_QUALIFIER 144 index_type TOTALTIME = 22; 145 //! destructor 146 ~BehaviourProfiler(); 147 protected: 148 //! name of the behaviour 149 const std::string name; 150 //! time spend in each code block (nanoseconds) 151 std::array<std::atomic<intmax_t>, 23> measures; 152 }; // end of BehaviourProfiler 153 154 } // end of namespace mfront 155 156 #endif /* LIB_MFRONT_MFRONTBEHAVIOURPROFILER_HXX */ 157 158