netgen-mesher 6.2.2506.post35.dev0__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- netgen/NgOCC.py +7 -0
- netgen/__init__.py +114 -0
- netgen/__init__.pyi +22 -0
- netgen/__main__.py +53 -0
- netgen/cmake/NetgenConfig.cmake +79 -0
- netgen/cmake/netgen-targets-release.cmake +69 -0
- netgen/cmake/netgen-targets.cmake +146 -0
- netgen/config/__init__.py +1 -0
- netgen/config/__init__.pyi +52 -0
- netgen/config/__main__.py +4 -0
- netgen/config/config.py +68 -0
- netgen/config/config.pyi +54 -0
- netgen/csg.py +25 -0
- netgen/geom2d.py +178 -0
- netgen/gui.py +82 -0
- netgen/include/core/archive.hpp +1256 -0
- netgen/include/core/array.hpp +1760 -0
- netgen/include/core/autodiff.hpp +1131 -0
- netgen/include/core/autodiffdiff.hpp +733 -0
- netgen/include/core/bitarray.hpp +240 -0
- netgen/include/core/concurrentqueue.h +3619 -0
- netgen/include/core/exception.hpp +145 -0
- netgen/include/core/flags.hpp +199 -0
- netgen/include/core/hashtable.hpp +1281 -0
- netgen/include/core/localheap.hpp +318 -0
- netgen/include/core/logging.hpp +117 -0
- netgen/include/core/memtracer.hpp +221 -0
- netgen/include/core/mpi4py_pycapi.h +245 -0
- netgen/include/core/mpi_wrapper.hpp +643 -0
- netgen/include/core/ng_mpi.hpp +94 -0
- netgen/include/core/ng_mpi_generated_declarations.hpp +155 -0
- netgen/include/core/ng_mpi_native.hpp +25 -0
- netgen/include/core/ngcore.hpp +32 -0
- netgen/include/core/ngcore_api.hpp +152 -0
- netgen/include/core/ngstream.hpp +115 -0
- netgen/include/core/paje_trace.hpp +279 -0
- netgen/include/core/profiler.hpp +382 -0
- netgen/include/core/python_ngcore.hpp +457 -0
- netgen/include/core/ranges.hpp +109 -0
- netgen/include/core/register_archive.hpp +100 -0
- netgen/include/core/signal.hpp +82 -0
- netgen/include/core/simd.hpp +160 -0
- netgen/include/core/simd_arm64.hpp +407 -0
- netgen/include/core/simd_avx.hpp +394 -0
- netgen/include/core/simd_avx512.hpp +285 -0
- netgen/include/core/simd_generic.hpp +1053 -0
- netgen/include/core/simd_math.hpp +178 -0
- netgen/include/core/simd_sse.hpp +289 -0
- netgen/include/core/statushandler.hpp +37 -0
- netgen/include/core/symboltable.hpp +153 -0
- netgen/include/core/table.hpp +810 -0
- netgen/include/core/taskmanager.hpp +1161 -0
- netgen/include/core/type_traits.hpp +65 -0
- netgen/include/core/utils.hpp +385 -0
- netgen/include/core/version.hpp +102 -0
- netgen/include/core/xbool.hpp +47 -0
- netgen/include/csg/algprim.hpp +563 -0
- netgen/include/csg/brick.hpp +150 -0
- netgen/include/csg/csg.hpp +43 -0
- netgen/include/csg/csgeom.hpp +389 -0
- netgen/include/csg/csgparser.hpp +101 -0
- netgen/include/csg/curve2d.hpp +67 -0
- netgen/include/csg/edgeflw.hpp +112 -0
- netgen/include/csg/explicitcurve2d.hpp +113 -0
- netgen/include/csg/extrusion.hpp +185 -0
- netgen/include/csg/gencyl.hpp +70 -0
- netgen/include/csg/geoml.hpp +16 -0
- netgen/include/csg/identify.hpp +213 -0
- netgen/include/csg/manifold.hpp +29 -0
- netgen/include/csg/meshsurf.hpp +46 -0
- netgen/include/csg/polyhedra.hpp +121 -0
- netgen/include/csg/revolution.hpp +180 -0
- netgen/include/csg/singularref.hpp +84 -0
- netgen/include/csg/solid.hpp +295 -0
- netgen/include/csg/specpoin.hpp +194 -0
- netgen/include/csg/spline3d.hpp +99 -0
- netgen/include/csg/splinesurface.hpp +85 -0
- netgen/include/csg/surface.hpp +394 -0
- netgen/include/csg/triapprox.hpp +63 -0
- netgen/include/csg/vscsg.hpp +34 -0
- netgen/include/general/autodiff.hpp +356 -0
- netgen/include/general/autoptr.hpp +39 -0
- netgen/include/general/gzstream.h +121 -0
- netgen/include/general/hashtabl.hpp +1692 -0
- netgen/include/general/myadt.hpp +48 -0
- netgen/include/general/mystring.hpp +226 -0
- netgen/include/general/netgenout.hpp +205 -0
- netgen/include/general/ngarray.hpp +797 -0
- netgen/include/general/ngbitarray.hpp +149 -0
- netgen/include/general/ngpython.hpp +74 -0
- netgen/include/general/optmem.hpp +44 -0
- netgen/include/general/parthreads.hpp +138 -0
- netgen/include/general/seti.hpp +50 -0
- netgen/include/general/sort.hpp +47 -0
- netgen/include/general/spbita2d.hpp +59 -0
- netgen/include/general/stack.hpp +114 -0
- netgen/include/general/table.hpp +280 -0
- netgen/include/general/template.hpp +509 -0
- netgen/include/geom2d/csg2d.hpp +750 -0
- netgen/include/geom2d/geometry2d.hpp +280 -0
- netgen/include/geom2d/spline2d.hpp +234 -0
- netgen/include/geom2d/vsgeom2d.hpp +28 -0
- netgen/include/gprim/adtree.hpp +1392 -0
- netgen/include/gprim/geom2d.hpp +858 -0
- netgen/include/gprim/geom3d.hpp +749 -0
- netgen/include/gprim/geomfuncs.hpp +212 -0
- netgen/include/gprim/geomobjects.hpp +544 -0
- netgen/include/gprim/geomops.hpp +404 -0
- netgen/include/gprim/geomtest3d.hpp +101 -0
- netgen/include/gprim/gprim.hpp +33 -0
- netgen/include/gprim/spline.hpp +778 -0
- netgen/include/gprim/splinegeometry.hpp +73 -0
- netgen/include/gprim/transform3d.hpp +216 -0
- netgen/include/include/acisgeom.hpp +3 -0
- netgen/include/include/csg.hpp +1 -0
- netgen/include/include/geometry2d.hpp +1 -0
- netgen/include/include/gprim.hpp +1 -0
- netgen/include/include/incopengl.hpp +62 -0
- netgen/include/include/inctcl.hpp +13 -0
- netgen/include/include/incvis.hpp +6 -0
- netgen/include/include/linalg.hpp +1 -0
- netgen/include/include/meshing.hpp +1 -0
- netgen/include/include/myadt.hpp +1 -0
- netgen/include/include/mydefs.hpp +70 -0
- netgen/include/include/mystdlib.h +59 -0
- netgen/include/include/netgen_config.hpp +27 -0
- netgen/include/include/netgen_version.hpp +9 -0
- netgen/include/include/nginterface_v2_impl.hpp +395 -0
- netgen/include/include/ngsimd.hpp +1 -0
- netgen/include/include/occgeom.hpp +1 -0
- netgen/include/include/opti.hpp +1 -0
- netgen/include/include/parallel.hpp +1 -0
- netgen/include/include/stlgeom.hpp +1 -0
- netgen/include/include/visual.hpp +1 -0
- netgen/include/interface/rw_medit.hpp +11 -0
- netgen/include/interface/writeuser.hpp +80 -0
- netgen/include/linalg/densemat.hpp +414 -0
- netgen/include/linalg/linalg.hpp +29 -0
- netgen/include/linalg/opti.hpp +142 -0
- netgen/include/linalg/polynomial.hpp +47 -0
- netgen/include/linalg/vector.hpp +217 -0
- netgen/include/meshing/adfront2.hpp +274 -0
- netgen/include/meshing/adfront3.hpp +332 -0
- netgen/include/meshing/basegeom.hpp +370 -0
- netgen/include/meshing/bcfunctions.hpp +53 -0
- netgen/include/meshing/bisect.hpp +72 -0
- netgen/include/meshing/boundarylayer.hpp +113 -0
- netgen/include/meshing/classifyhpel.hpp +1984 -0
- netgen/include/meshing/clusters.hpp +46 -0
- netgen/include/meshing/curvedelems.hpp +274 -0
- netgen/include/meshing/delaunay2d.hpp +73 -0
- netgen/include/meshing/fieldlines.hpp +103 -0
- netgen/include/meshing/findip.hpp +198 -0
- netgen/include/meshing/findip2.hpp +103 -0
- netgen/include/meshing/geomsearch.hpp +69 -0
- netgen/include/meshing/global.hpp +54 -0
- netgen/include/meshing/hpref_hex.hpp +330 -0
- netgen/include/meshing/hpref_prism.hpp +3405 -0
- netgen/include/meshing/hpref_pyramid.hpp +154 -0
- netgen/include/meshing/hpref_quad.hpp +2082 -0
- netgen/include/meshing/hpref_segm.hpp +122 -0
- netgen/include/meshing/hpref_tet.hpp +4230 -0
- netgen/include/meshing/hpref_trig.hpp +848 -0
- netgen/include/meshing/hprefinement.hpp +366 -0
- netgen/include/meshing/improve2.hpp +178 -0
- netgen/include/meshing/improve3.hpp +151 -0
- netgen/include/meshing/localh.hpp +223 -0
- netgen/include/meshing/meshclass.hpp +1076 -0
- netgen/include/meshing/meshfunc.hpp +47 -0
- netgen/include/meshing/meshing.hpp +63 -0
- netgen/include/meshing/meshing2.hpp +163 -0
- netgen/include/meshing/meshing3.hpp +123 -0
- netgen/include/meshing/meshtool.hpp +90 -0
- netgen/include/meshing/meshtype.hpp +1930 -0
- netgen/include/meshing/msghandler.hpp +62 -0
- netgen/include/meshing/paralleltop.hpp +172 -0
- netgen/include/meshing/python_mesh.hpp +206 -0
- netgen/include/meshing/ruler2.hpp +172 -0
- netgen/include/meshing/ruler3.hpp +211 -0
- netgen/include/meshing/soldata.hpp +141 -0
- netgen/include/meshing/specials.hpp +17 -0
- netgen/include/meshing/surfacegeom.hpp +73 -0
- netgen/include/meshing/topology.hpp +1003 -0
- netgen/include/meshing/validate.hpp +21 -0
- netgen/include/meshing/visual_interface.hpp +71 -0
- netgen/include/mydefs.hpp +70 -0
- netgen/include/nginterface.h +474 -0
- netgen/include/nginterface_v2.hpp +406 -0
- netgen/include/nglib.h +697 -0
- netgen/include/nglib_occ.h +50 -0
- netgen/include/occ/occ_edge.hpp +47 -0
- netgen/include/occ/occ_face.hpp +52 -0
- netgen/include/occ/occ_solid.hpp +23 -0
- netgen/include/occ/occ_utils.hpp +376 -0
- netgen/include/occ/occ_vertex.hpp +30 -0
- netgen/include/occ/occgeom.hpp +659 -0
- netgen/include/occ/occmeshsurf.hpp +168 -0
- netgen/include/occ/vsocc.hpp +33 -0
- netgen/include/pybind11/LICENSE +29 -0
- netgen/include/pybind11/attr.h +722 -0
- netgen/include/pybind11/buffer_info.h +208 -0
- netgen/include/pybind11/cast.h +2361 -0
- netgen/include/pybind11/chrono.h +228 -0
- netgen/include/pybind11/common.h +2 -0
- netgen/include/pybind11/complex.h +74 -0
- netgen/include/pybind11/conduit/README.txt +15 -0
- netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
- netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
- netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
- netgen/include/pybind11/critical_section.h +56 -0
- netgen/include/pybind11/detail/class.h +823 -0
- netgen/include/pybind11/detail/common.h +1348 -0
- netgen/include/pybind11/detail/cpp_conduit.h +75 -0
- netgen/include/pybind11/detail/descr.h +226 -0
- netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
- netgen/include/pybind11/detail/exception_translation.h +71 -0
- netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
- netgen/include/pybind11/detail/init.h +538 -0
- netgen/include/pybind11/detail/internals.h +799 -0
- netgen/include/pybind11/detail/native_enum_data.h +209 -0
- netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
- netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
- netgen/include/pybind11/detail/type_caster_base.h +1591 -0
- netgen/include/pybind11/detail/typeid.h +65 -0
- netgen/include/pybind11/detail/using_smart_holder.h +22 -0
- netgen/include/pybind11/detail/value_and_holder.h +90 -0
- netgen/include/pybind11/eigen/common.h +9 -0
- netgen/include/pybind11/eigen/matrix.h +723 -0
- netgen/include/pybind11/eigen/tensor.h +521 -0
- netgen/include/pybind11/eigen.h +12 -0
- netgen/include/pybind11/embed.h +320 -0
- netgen/include/pybind11/eval.h +161 -0
- netgen/include/pybind11/functional.h +147 -0
- netgen/include/pybind11/gil.h +199 -0
- netgen/include/pybind11/gil_safe_call_once.h +102 -0
- netgen/include/pybind11/gil_simple.h +37 -0
- netgen/include/pybind11/iostream.h +265 -0
- netgen/include/pybind11/native_enum.h +67 -0
- netgen/include/pybind11/numpy.h +2312 -0
- netgen/include/pybind11/operators.h +202 -0
- netgen/include/pybind11/options.h +92 -0
- netgen/include/pybind11/pybind11.h +3645 -0
- netgen/include/pybind11/pytypes.h +2680 -0
- netgen/include/pybind11/stl/filesystem.h +114 -0
- netgen/include/pybind11/stl.h +666 -0
- netgen/include/pybind11/stl_bind.h +858 -0
- netgen/include/pybind11/subinterpreter.h +299 -0
- netgen/include/pybind11/trampoline_self_life_support.h +65 -0
- netgen/include/pybind11/type_caster_pyobject_ptr.h +61 -0
- netgen/include/pybind11/typing.h +298 -0
- netgen/include/pybind11/warnings.h +75 -0
- netgen/include/stlgeom/meshstlsurface.hpp +67 -0
- netgen/include/stlgeom/stlgeom.hpp +491 -0
- netgen/include/stlgeom/stlline.hpp +193 -0
- netgen/include/stlgeom/stltool.hpp +331 -0
- netgen/include/stlgeom/stltopology.hpp +419 -0
- netgen/include/stlgeom/vsstl.hpp +58 -0
- netgen/include/visualization/meshdoc.hpp +42 -0
- netgen/include/visualization/mvdraw.hpp +325 -0
- netgen/include/visualization/vispar.hpp +128 -0
- netgen/include/visualization/visual.hpp +28 -0
- netgen/include/visualization/visual_api.hpp +10 -0
- netgen/include/visualization/vssolution.hpp +399 -0
- netgen/lib/libnggui.lib +0 -0
- netgen/lib/ngcore.lib +0 -0
- netgen/lib/nglib.lib +0 -0
- netgen/lib/togl.lib +0 -0
- netgen/libnggui.dll +0 -0
- netgen/libngguipy.lib +0 -0
- netgen/libngguipy.pyd +0 -0
- netgen/libngpy/_NgOCC.pyi +1545 -0
- netgen/libngpy/__init__.pyi +7 -0
- netgen/libngpy/_csg.pyi +259 -0
- netgen/libngpy/_geom2d.pyi +323 -0
- netgen/libngpy/_meshing.pyi +1111 -0
- netgen/libngpy/_stl.pyi +131 -0
- netgen/libngpy.lib +0 -0
- netgen/libngpy.pyd +0 -0
- netgen/meshing.py +65 -0
- netgen/ngcore.dll +0 -0
- netgen/nglib.dll +0 -0
- netgen/occ.py +52 -0
- netgen/read_gmsh.py +259 -0
- netgen/read_meshio.py +22 -0
- netgen/stl.py +2 -0
- netgen/togl.dll +0 -0
- netgen/version.py +2 -0
- netgen/webgui.py +529 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boundarycondition.geo +16 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boxcyl.geo +32 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/circle_on_cube.geo +27 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cone.geo +13 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cube.geo +16 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandring.geo +55 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandspheres.geo +21 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemcyl.geo +18 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemsphere.geo +19 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylinder.geo +12 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylsphere.geo +12 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/doc/ng4.pdf +0 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipsoid.geo +8 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipticcyl.geo +10 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/extrusion.geo +99 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/fichera.geo +24 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/frame.step +11683 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/hinge.stl +8486 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/lshape3d.geo +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes.geo +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes2.geo +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/matrix.geo +27 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ortho.geo +11 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/part1.stl +2662 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/period.geo +33 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/exportNeutral.py +26 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/mesh.py +19 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/shaft.geo +65 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/revolution.geo +18 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/screw.step +1694 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sculpture.geo +13 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shaft.geo +65 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shell.geo +10 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphere.geo +8 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphereincube.geo +17 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/square.in2d +35 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarecircle.in2d +48 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarehole.in2d +47 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/torus.geo +8 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/trafo.geo +57 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twobricks.geo +15 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocubes.geo +18 -0
- netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocyl.geo +16 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/METADATA +15 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/RECORD +340 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/WHEEL +5 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/entry_points.txt +2 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/AUTHORS +1 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/LICENSE +504 -0
- netgen_mesher-6.2.2506.post35.dev0.dist-info/top_level.txt +2 -0
- pyngcore/__init__.py +1 -0
- pyngcore/pyngcore.cp314-win_amd64.pyd +0 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#ifndef NETGEN_CORE_PAJE_TRACE_HPP
|
|
2
|
+
#define NETGEN_CORE_PAJE_TRACE_HPP
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
#include <limits>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
#include "logging.hpp" // for logger
|
|
9
|
+
#include "ngcore_api.hpp" // for NGCORE_API
|
|
10
|
+
#include "utils.hpp"
|
|
11
|
+
|
|
12
|
+
namespace ngcore
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
extern NGCORE_API class PajeTrace *trace;
|
|
16
|
+
class PajeTrace
|
|
17
|
+
{
|
|
18
|
+
public:
|
|
19
|
+
using TClock = std::chrono::system_clock;
|
|
20
|
+
|
|
21
|
+
protected:
|
|
22
|
+
std::shared_ptr<Logger> logger = GetLogger("PajeTrace");
|
|
23
|
+
private:
|
|
24
|
+
NGCORE_API static size_t max_tracefile_size;
|
|
25
|
+
NGCORE_API static bool trace_thread_counter;
|
|
26
|
+
NGCORE_API static bool trace_threads;
|
|
27
|
+
NGCORE_API static bool mem_tracing_enabled;
|
|
28
|
+
NGCORE_API static bool write_paje_file;
|
|
29
|
+
|
|
30
|
+
bool tracing_enabled;
|
|
31
|
+
TTimePoint start_time;
|
|
32
|
+
int nthreads;
|
|
33
|
+
size_t n_memory_events_at_start;
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
NGCORE_API void Write();
|
|
37
|
+
NGCORE_API void WritePajeFile( const std::string & filename );
|
|
38
|
+
NGCORE_API void WriteTimingChart();
|
|
39
|
+
#ifdef NETGEN_TRACE_MEMORY
|
|
40
|
+
NGCORE_API void WriteMemoryChart( std::string fname );
|
|
41
|
+
#endif // NETGEN_TRACE_MEMORY
|
|
42
|
+
|
|
43
|
+
// Approximate number of events to trace. Tracing will
|
|
44
|
+
// be stopped if any thread reaches this number of events
|
|
45
|
+
unsigned int max_num_events_per_thread;
|
|
46
|
+
|
|
47
|
+
static void SetTraceMemory( bool trace_memory )
|
|
48
|
+
{
|
|
49
|
+
mem_tracing_enabled = trace_memory;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static void SetTraceThreads( bool atrace_threads )
|
|
53
|
+
{
|
|
54
|
+
trace_threads = atrace_threads;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void SetTraceThreadCounter( bool trace_threads )
|
|
58
|
+
{
|
|
59
|
+
trace_thread_counter = trace_threads;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static void SetMaxTracefileSize( size_t max_size )
|
|
63
|
+
{
|
|
64
|
+
max_tracefile_size = max_size;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static void SetWritePajeFile( bool write )
|
|
68
|
+
{
|
|
69
|
+
write_paje_file = write;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
std::string tracefile_name;
|
|
73
|
+
|
|
74
|
+
struct Job
|
|
75
|
+
{
|
|
76
|
+
int job_id;
|
|
77
|
+
const std::type_info *type;
|
|
78
|
+
TTimePoint start_time;
|
|
79
|
+
TTimePoint stop_time;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
struct Task
|
|
83
|
+
{
|
|
84
|
+
int thread_id;
|
|
85
|
+
|
|
86
|
+
int id;
|
|
87
|
+
int id_type;
|
|
88
|
+
|
|
89
|
+
int additional_value;
|
|
90
|
+
|
|
91
|
+
TTimePoint time;
|
|
92
|
+
bool is_start;
|
|
93
|
+
|
|
94
|
+
static constexpr int ID_NONE = -1;
|
|
95
|
+
static constexpr int ID_JOB = 1;
|
|
96
|
+
static constexpr int ID_TIMER = 2;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
struct TimerEvent
|
|
100
|
+
{
|
|
101
|
+
TTimePoint time;
|
|
102
|
+
int timer_id;
|
|
103
|
+
int thread_id;
|
|
104
|
+
int custom_value = -1;
|
|
105
|
+
bool is_start;
|
|
106
|
+
|
|
107
|
+
bool operator < (const TimerEvent & other) const { return time < other.time; }
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
struct UserEvent
|
|
111
|
+
{
|
|
112
|
+
TTimePoint t_start = 0, t_end = 0;
|
|
113
|
+
std::string data = "";
|
|
114
|
+
int container = 0;
|
|
115
|
+
int id = 0;
|
|
116
|
+
|
|
117
|
+
bool operator < (const UserEvent & other) const { return t_start < other.t_start; }
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
struct ThreadLink
|
|
121
|
+
{
|
|
122
|
+
int thread_id;
|
|
123
|
+
int key;
|
|
124
|
+
TTimePoint time;
|
|
125
|
+
bool is_start;
|
|
126
|
+
bool operator < (const ThreadLink & other) const { return time < other.time; }
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
struct MemoryEvent
|
|
130
|
+
{
|
|
131
|
+
TTimePoint time;
|
|
132
|
+
size_t size;
|
|
133
|
+
int id;
|
|
134
|
+
bool is_alloc;
|
|
135
|
+
|
|
136
|
+
bool operator < (const MemoryEvent & other) const { return time < other.time; }
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
std::vector<std::vector<Task> > tasks;
|
|
140
|
+
std::vector<Job> jobs;
|
|
141
|
+
std::vector<TimerEvent> timer_events;
|
|
142
|
+
std::vector<UserEvent> user_events;
|
|
143
|
+
std::vector<std::tuple<std::string, int>> user_containers;
|
|
144
|
+
std::vector<TimerEvent> gpu_events;
|
|
145
|
+
std::vector<std::vector<ThreadLink> > links;
|
|
146
|
+
NGCORE_API static std::vector<MemoryEvent> memory_events;
|
|
147
|
+
|
|
148
|
+
public:
|
|
149
|
+
NGCORE_API void StopTracing();
|
|
150
|
+
|
|
151
|
+
PajeTrace() = delete;
|
|
152
|
+
PajeTrace(const PajeTrace &) = delete;
|
|
153
|
+
PajeTrace(PajeTrace &&) = delete;
|
|
154
|
+
NGCORE_API PajeTrace(int anthreads, std::string aname = "");
|
|
155
|
+
NGCORE_API ~PajeTrace();
|
|
156
|
+
|
|
157
|
+
void operator=(const PajeTrace &) = delete;
|
|
158
|
+
void operator=(PajeTrace &&) = delete;
|
|
159
|
+
|
|
160
|
+
int AddUserContainer(std::string name, int parent=-1)
|
|
161
|
+
{
|
|
162
|
+
if(auto pos = std::find(user_containers.begin(), user_containers.end(), std::tuple{name,parent}); pos != user_containers.end())
|
|
163
|
+
return pos - user_containers.begin();
|
|
164
|
+
int id = user_containers.size();
|
|
165
|
+
user_containers.push_back({name, parent});
|
|
166
|
+
return id;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void AddUserEvent(UserEvent ue)
|
|
170
|
+
{
|
|
171
|
+
if(!tracing_enabled) return;
|
|
172
|
+
user_events.push_back(ue);
|
|
173
|
+
}
|
|
174
|
+
void StartGPU(int timer_id = 0, int user_value = -1)
|
|
175
|
+
{
|
|
176
|
+
if(!tracing_enabled) return;
|
|
177
|
+
if(unlikely(gpu_events.size() == max_num_events_per_thread))
|
|
178
|
+
StopTracing();
|
|
179
|
+
gpu_events.push_back(TimerEvent{GetTimeCounter(), timer_id, 0, user_value, true});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void StopGPU(int timer_id)
|
|
183
|
+
{
|
|
184
|
+
if(!tracing_enabled) return;
|
|
185
|
+
if(unlikely(gpu_events.size() == max_num_events_per_thread))
|
|
186
|
+
StopTracing();
|
|
187
|
+
gpu_events.push_back(TimerEvent{GetTimeCounter(), timer_id, 0, -1, false});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
void StartTimer(int timer_id, int user_value = -1)
|
|
191
|
+
{
|
|
192
|
+
if(!tracing_enabled) return;
|
|
193
|
+
if(unlikely(timer_events.size() == max_num_events_per_thread))
|
|
194
|
+
StopTracing();
|
|
195
|
+
timer_events.push_back(TimerEvent{GetTimeCounter(), timer_id, 0, user_value, true});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
void StopTimer(int timer_id)
|
|
199
|
+
{
|
|
200
|
+
if(!tracing_enabled) return;
|
|
201
|
+
if(unlikely(timer_events.size() == max_num_events_per_thread))
|
|
202
|
+
StopTracing();
|
|
203
|
+
timer_events.push_back(TimerEvent{GetTimeCounter(), timer_id, 0, -1, false});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
void AllocMemory(int id, size_t size)
|
|
207
|
+
{
|
|
208
|
+
if(!mem_tracing_enabled) return;
|
|
209
|
+
memory_events.push_back(MemoryEvent{GetTimeCounter(), size, id, true});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
void FreeMemory(int id, size_t size)
|
|
213
|
+
{
|
|
214
|
+
if(!mem_tracing_enabled) return;
|
|
215
|
+
memory_events.push_back(MemoryEvent{GetTimeCounter(), size, id, false});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
void ChangeMemory(int id, long long size)
|
|
219
|
+
{
|
|
220
|
+
if(size>0)
|
|
221
|
+
AllocMemory(id, size);
|
|
222
|
+
if(size<0)
|
|
223
|
+
FreeMemory(id, -size);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
int StartTask(int thread_id, int id, int id_type = Task::ID_NONE, int additional_value = -1)
|
|
228
|
+
{
|
|
229
|
+
if(!tracing_enabled) return -1;
|
|
230
|
+
if(!trace_threads && !trace_thread_counter) return -1;
|
|
231
|
+
if(unlikely(tasks[thread_id].size() == max_num_events_per_thread))
|
|
232
|
+
StopTracing();
|
|
233
|
+
int task_num = tasks[thread_id].size();
|
|
234
|
+
tasks[thread_id].push_back( Task{thread_id, id, id_type, additional_value, GetTimeCounter(), true} );
|
|
235
|
+
return task_num;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
void StopTask(int thread_id, int id, int id_type = Task::ID_NONE)
|
|
239
|
+
{
|
|
240
|
+
if(!trace_threads && !trace_thread_counter) return;
|
|
241
|
+
tasks[thread_id].push_back( Task{thread_id, id, id_type, 0, GetTimeCounter(), false} );
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
void StartJob(int job_id, const std::type_info & type)
|
|
245
|
+
{
|
|
246
|
+
if(!tracing_enabled) return;
|
|
247
|
+
if(jobs.size() == max_num_events_per_thread)
|
|
248
|
+
StopTracing();
|
|
249
|
+
jobs.push_back( Job{job_id, &type, GetTimeCounter()} );
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
void StopJob()
|
|
253
|
+
{
|
|
254
|
+
if(tracing_enabled)
|
|
255
|
+
jobs.back().stop_time = GetTimeCounter();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void StartLink(int thread_id, int key)
|
|
259
|
+
{
|
|
260
|
+
if(!tracing_enabled) return;
|
|
261
|
+
if(links[thread_id].size() == max_num_events_per_thread)
|
|
262
|
+
StopTracing();
|
|
263
|
+
links[thread_id].push_back( ThreadLink{thread_id, key, GetTimeCounter(), true} );
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
void StopLink(int thread_id, int key)
|
|
267
|
+
{
|
|
268
|
+
if(!tracing_enabled) return;
|
|
269
|
+
if(links[thread_id].size() == max_num_events_per_thread)
|
|
270
|
+
StopTracing();
|
|
271
|
+
links[thread_id].push_back( ThreadLink{thread_id, key, GetTimeCounter(), false} );
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
void SendData(); // MPI parallel data reduction
|
|
275
|
+
|
|
276
|
+
};
|
|
277
|
+
} // namespace ngcore
|
|
278
|
+
|
|
279
|
+
#endif // NETGEN_CORE_PAJE_TRACE_HPP
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
#ifndef NETGEN_CORE_PROFILER_HPP
|
|
2
|
+
#define NETGEN_CORE_PROFILER_HPP
|
|
3
|
+
|
|
4
|
+
#include <array>
|
|
5
|
+
#include <chrono>
|
|
6
|
+
#include <functional>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
#include "array.hpp"
|
|
10
|
+
#include "logging.hpp"
|
|
11
|
+
#include "paje_trace.hpp"
|
|
12
|
+
#include "taskmanager.hpp"
|
|
13
|
+
#include "utils.hpp"
|
|
14
|
+
|
|
15
|
+
namespace ngcore
|
|
16
|
+
{
|
|
17
|
+
class NgProfiler
|
|
18
|
+
{
|
|
19
|
+
public:
|
|
20
|
+
/// maximal number of timers
|
|
21
|
+
enum { SIZE = 8*1024 };
|
|
22
|
+
|
|
23
|
+
struct TimerVal
|
|
24
|
+
{
|
|
25
|
+
TimerVal() = default;
|
|
26
|
+
|
|
27
|
+
double tottime = 0.0;
|
|
28
|
+
TTimePoint starttime=0;
|
|
29
|
+
double flops = 0.0;
|
|
30
|
+
double loads = 0.0;
|
|
31
|
+
double stores = 0.0;
|
|
32
|
+
long count = 0;
|
|
33
|
+
std::string name = "";
|
|
34
|
+
int usedcounter = 0;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
NGCORE_API static std::vector<TimerVal> timers;
|
|
38
|
+
|
|
39
|
+
NGCORE_API static TTimePoint * thread_times;
|
|
40
|
+
NGCORE_API static TTimePoint * thread_flops;
|
|
41
|
+
NGCORE_API static std::shared_ptr<Logger> logger;
|
|
42
|
+
NGCORE_API static std::array<size_t, NgProfiler::SIZE> dummy_thread_times;
|
|
43
|
+
NGCORE_API static std::array<size_t, NgProfiler::SIZE> dummy_thread_flops;
|
|
44
|
+
private:
|
|
45
|
+
|
|
46
|
+
NGCORE_API static std::string filename;
|
|
47
|
+
public:
|
|
48
|
+
NgProfiler();
|
|
49
|
+
~NgProfiler();
|
|
50
|
+
|
|
51
|
+
NgProfiler(const NgProfiler &) = delete;
|
|
52
|
+
NgProfiler(NgProfiler &&) = delete;
|
|
53
|
+
void operator=(const NgProfiler &) = delete;
|
|
54
|
+
void operator=(NgProfiler &&) = delete;
|
|
55
|
+
|
|
56
|
+
static void SetFileName (const std::string & afilename) { filename = afilename; }
|
|
57
|
+
|
|
58
|
+
/// create new timer, use integer index
|
|
59
|
+
NGCORE_API static int CreateTimer (const std::string & name);
|
|
60
|
+
|
|
61
|
+
NGCORE_API static void Reset ();
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/// start timer of index nr
|
|
65
|
+
static void StartTimer (int nr)
|
|
66
|
+
{
|
|
67
|
+
timers[nr].starttime = GetTimeCounter(); timers[nr].count++;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// stop timer of index nr
|
|
71
|
+
static void StopTimer (int nr)
|
|
72
|
+
{
|
|
73
|
+
timers[nr].tottime += (GetTimeCounter()-timers[nr].starttime)*seconds_per_tick;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static void StartThreadTimer (size_t nr, size_t tid)
|
|
77
|
+
{
|
|
78
|
+
thread_times[tid*SIZE+nr] -= GetTimeCounter(); // NOLINT
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static void StopThreadTimer (size_t nr, size_t tid)
|
|
82
|
+
{
|
|
83
|
+
thread_times[tid*SIZE+nr] += GetTimeCounter(); // NOLINT
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static void AddThreadFlops (size_t nr, size_t tid, size_t flops)
|
|
87
|
+
{
|
|
88
|
+
thread_flops[tid*SIZE+nr] += flops; // NOLINT
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// if you know number of flops, provide them to obtain the MFlop - rate
|
|
92
|
+
static void AddFlops (int nr, double aflops) { timers[nr].flops += aflops; }
|
|
93
|
+
static void AddLoads (int nr, double aloads) { timers[nr].loads += aloads; }
|
|
94
|
+
static void AddStores (int nr, double astores) { timers[nr].stores += astores; }
|
|
95
|
+
|
|
96
|
+
static int GetNr (const std::string & name)
|
|
97
|
+
{
|
|
98
|
+
for (int i = SIZE-1; i >= 0; i--)
|
|
99
|
+
if (timers[i].name == name)
|
|
100
|
+
return i;
|
|
101
|
+
return -1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static double GetTime (int nr)
|
|
105
|
+
{
|
|
106
|
+
return timers[nr].tottime;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static double GetTime (const std::string & name)
|
|
110
|
+
{
|
|
111
|
+
for (int i = SIZE-1; i >= 0; i--)
|
|
112
|
+
if (timers[i].name == name)
|
|
113
|
+
return GetTime (i);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static long int GetCounts (int nr)
|
|
118
|
+
{
|
|
119
|
+
return timers[nr].count;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static double GetFlops (int nr)
|
|
123
|
+
{
|
|
124
|
+
return timers[nr].flops;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// change name
|
|
128
|
+
static void SetName (int nr, const std::string & name) { timers[nr].name = name; }
|
|
129
|
+
static std::string GetName (int nr) { return timers[nr].name; }
|
|
130
|
+
/// print profile
|
|
131
|
+
NGCORE_API static void Print (FILE * prof);
|
|
132
|
+
|
|
133
|
+
class RegionTimer
|
|
134
|
+
{
|
|
135
|
+
int nr;
|
|
136
|
+
public:
|
|
137
|
+
/// start timer
|
|
138
|
+
RegionTimer (int anr) : nr(anr) { NgProfiler::StartTimer(nr); }
|
|
139
|
+
/// stop timer
|
|
140
|
+
~RegionTimer () { NgProfiler::StopTimer(nr); }
|
|
141
|
+
|
|
142
|
+
RegionTimer() = delete;
|
|
143
|
+
RegionTimer(const RegionTimer &) = delete;
|
|
144
|
+
RegionTimer(RegionTimer &&) = delete;
|
|
145
|
+
void operator=(const RegionTimer &) = delete;
|
|
146
|
+
void operator=(RegionTimer &&) = delete;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
struct TNoTracing{ static constexpr bool do_tracing=false; };
|
|
152
|
+
struct TTracing{ static constexpr bool do_tracing=true; };
|
|
153
|
+
|
|
154
|
+
struct TNoTiming{ static constexpr bool do_timing=false; };
|
|
155
|
+
struct TTiming{ static constexpr bool do_timing=true; };
|
|
156
|
+
|
|
157
|
+
namespace detail {
|
|
158
|
+
|
|
159
|
+
template<typename T>
|
|
160
|
+
constexpr bool is_tracing_type_v = std::is_same_v<T, TNoTracing> || std::is_same_v<T, TTracing>;
|
|
161
|
+
|
|
162
|
+
template<typename T>
|
|
163
|
+
constexpr bool is_timing_type_v = std::is_same_v<T, TNoTiming> || std::is_same_v<T, TTiming>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[[maybe_unused]] static TNoTracing NoTracing;
|
|
167
|
+
[[maybe_unused]] static TNoTiming NoTiming;
|
|
168
|
+
|
|
169
|
+
template<typename TTracing=TTracing, typename TTiming=TTiming>
|
|
170
|
+
class Timer
|
|
171
|
+
{
|
|
172
|
+
int timernr;
|
|
173
|
+
int Init( const std::string & name )
|
|
174
|
+
{
|
|
175
|
+
return NgProfiler::CreateTimer (name);
|
|
176
|
+
}
|
|
177
|
+
public:
|
|
178
|
+
static constexpr bool do_tracing = TTracing::do_tracing;
|
|
179
|
+
static constexpr bool do_timing = TTiming::do_timing;
|
|
180
|
+
|
|
181
|
+
Timer (const std::string & name) : timernr(Init(name)) { }
|
|
182
|
+
|
|
183
|
+
template<std::enable_if_t< detail::is_tracing_type_v<TTracing>, bool> = false>
|
|
184
|
+
Timer( const std::string & name, TTracing ) : timernr(Init(name)) { }
|
|
185
|
+
|
|
186
|
+
template<std::enable_if_t< detail::is_timing_type_v<TTiming>, bool> = false>
|
|
187
|
+
Timer( const std::string & name, TTiming ) : timernr(Init(name)) { }
|
|
188
|
+
|
|
189
|
+
Timer( const std::string & name, TTracing, TTiming ) : timernr(Init(name)) { }
|
|
190
|
+
|
|
191
|
+
[[deprecated ("Use Timer(name, NoTracing/NoTiming) instead")]] Timer( const std::string & name, int ) : timernr(Init(name)) {}
|
|
192
|
+
|
|
193
|
+
void SetName (const std::string & name)
|
|
194
|
+
{
|
|
195
|
+
NgProfiler::SetName (timernr, name);
|
|
196
|
+
}
|
|
197
|
+
void Start () const
|
|
198
|
+
{
|
|
199
|
+
Start(TaskManager::GetThreadId());
|
|
200
|
+
}
|
|
201
|
+
void Stop () const
|
|
202
|
+
{
|
|
203
|
+
Stop(TaskManager::GetThreadId());
|
|
204
|
+
}
|
|
205
|
+
void Start (int tid, int trace_value = -1) const
|
|
206
|
+
{
|
|
207
|
+
if(tid==0)
|
|
208
|
+
{
|
|
209
|
+
if constexpr(do_timing)
|
|
210
|
+
NgProfiler::StartTimer (timernr);
|
|
211
|
+
if constexpr(do_tracing)
|
|
212
|
+
if(trace) trace->StartTimer(timernr, trace_value);
|
|
213
|
+
}
|
|
214
|
+
else
|
|
215
|
+
{
|
|
216
|
+
if constexpr(do_timing)
|
|
217
|
+
NgProfiler::StartThreadTimer(timernr, tid);
|
|
218
|
+
if constexpr(do_tracing)
|
|
219
|
+
if(trace) trace->StartTask (tid, timernr, PajeTrace::Task::ID_TIMER, trace_value);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
void Stop (int tid) const
|
|
223
|
+
{
|
|
224
|
+
if(tid==0)
|
|
225
|
+
{
|
|
226
|
+
if constexpr(do_timing)
|
|
227
|
+
NgProfiler::StopTimer (timernr);
|
|
228
|
+
if constexpr(do_tracing)
|
|
229
|
+
if(trace) trace->StopTimer(timernr);
|
|
230
|
+
}
|
|
231
|
+
else
|
|
232
|
+
{
|
|
233
|
+
if constexpr(do_timing)
|
|
234
|
+
NgProfiler::StopThreadTimer(timernr, tid);
|
|
235
|
+
if constexpr(do_tracing)
|
|
236
|
+
if(trace) trace->StopTask (tid, timernr, PajeTrace::Task::ID_TIMER);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
void AddFlops (double aflops)
|
|
240
|
+
{
|
|
241
|
+
if constexpr(do_timing)
|
|
242
|
+
NgProfiler::AddFlops (timernr, aflops);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
double GetTime () { return NgProfiler::GetTime(timernr); }
|
|
246
|
+
long int GetCounts () { return NgProfiler::GetCounts(timernr); }
|
|
247
|
+
double GetMFlops ()
|
|
248
|
+
{ return NgProfiler::GetFlops(timernr)
|
|
249
|
+
/ NgProfiler::GetTime(timernr) * 1e-6; }
|
|
250
|
+
operator int () const { return timernr; }
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
Timer object.
|
|
256
|
+
Start / stop timer at constructor / destructor.
|
|
257
|
+
*/
|
|
258
|
+
template<typename TTimer>
|
|
259
|
+
class RegionTimer
|
|
260
|
+
{
|
|
261
|
+
const TTimer & timer;
|
|
262
|
+
int tid;
|
|
263
|
+
public:
|
|
264
|
+
/// start timer
|
|
265
|
+
RegionTimer (const TTimer & atimer, int trace_value = -1) : timer(atimer)
|
|
266
|
+
{
|
|
267
|
+
tid = TaskManager::GetThreadId();
|
|
268
|
+
timer.Start(tid, trace_value);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// stop timer
|
|
272
|
+
~RegionTimer () { timer.Stop(tid); }
|
|
273
|
+
|
|
274
|
+
RegionTimer() = delete;
|
|
275
|
+
RegionTimer(const RegionTimer &) = delete;
|
|
276
|
+
RegionTimer(RegionTimer &&) = delete;
|
|
277
|
+
void operator=(const RegionTimer &) = delete;
|
|
278
|
+
void operator=(RegionTimer &&) = delete;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
class [[deprecated("Use RegionTimer instead (now thread safe)")]] ThreadRegionTimer
|
|
282
|
+
{
|
|
283
|
+
size_t nr;
|
|
284
|
+
size_t tid;
|
|
285
|
+
public:
|
|
286
|
+
/// start timer
|
|
287
|
+
ThreadRegionTimer (size_t _nr, size_t _tid) : nr(_nr), tid(_tid)
|
|
288
|
+
{ NgProfiler::StartThreadTimer(nr, tid); }
|
|
289
|
+
/// stop timer
|
|
290
|
+
~ThreadRegionTimer ()
|
|
291
|
+
{ NgProfiler::StopThreadTimer(nr, tid); }
|
|
292
|
+
|
|
293
|
+
ThreadRegionTimer() = delete;
|
|
294
|
+
ThreadRegionTimer(ThreadRegionTimer &&) = delete;
|
|
295
|
+
ThreadRegionTimer(const ThreadRegionTimer &) = delete;
|
|
296
|
+
void operator=(const ThreadRegionTimer &) = delete;
|
|
297
|
+
void operator=(ThreadRegionTimer &&) = delete;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
class RegionTracer
|
|
301
|
+
{
|
|
302
|
+
int nr;
|
|
303
|
+
int thread_id;
|
|
304
|
+
int type;
|
|
305
|
+
public:
|
|
306
|
+
static constexpr int ID_JOB = PajeTrace::Task::ID_JOB;
|
|
307
|
+
static constexpr int ID_NONE = PajeTrace::Task::ID_NONE;
|
|
308
|
+
static constexpr int ID_TIMER = PajeTrace::Task::ID_TIMER;
|
|
309
|
+
|
|
310
|
+
RegionTracer() = delete;
|
|
311
|
+
RegionTracer(RegionTracer &&) = delete;
|
|
312
|
+
RegionTracer(const RegionTracer &) = delete;
|
|
313
|
+
void operator=(const RegionTracer &) = delete;
|
|
314
|
+
void operator=(RegionTracer &&) = delete;
|
|
315
|
+
|
|
316
|
+
/// start trace
|
|
317
|
+
RegionTracer (int athread_id, int region_id, int id_type = ID_NONE, int additional_value = -1 )
|
|
318
|
+
: thread_id(athread_id)
|
|
319
|
+
{
|
|
320
|
+
if (trace)
|
|
321
|
+
trace->StartTask (athread_id, region_id, id_type, additional_value);
|
|
322
|
+
type = id_type;
|
|
323
|
+
nr = region_id;
|
|
324
|
+
}
|
|
325
|
+
/// start trace with timer
|
|
326
|
+
template<typename TTimer>
|
|
327
|
+
RegionTracer (int athread_id, TTimer & timer, int additional_value = -1 )
|
|
328
|
+
: thread_id(athread_id)
|
|
329
|
+
{
|
|
330
|
+
nr = timer;
|
|
331
|
+
type = ID_TIMER;
|
|
332
|
+
if (trace)
|
|
333
|
+
trace->StartTask (athread_id, nr, type, additional_value);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/// stop trace
|
|
337
|
+
~RegionTracer ()
|
|
338
|
+
{
|
|
339
|
+
if (trace)
|
|
340
|
+
trace->StopTask (thread_id, nr, type);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
// Helper function for timings
|
|
346
|
+
// Run f() at least min_iterations times until max_time seconds elapsed
|
|
347
|
+
// returns minimum runtime for a call of f()
|
|
348
|
+
template<typename TFunc>
|
|
349
|
+
double RunTiming( TFunc f, double max_time = 0.5, int min_iterations = 10 )
|
|
350
|
+
{
|
|
351
|
+
// Make sure the whole test run does not exceed maxtime
|
|
352
|
+
double tend = WallTime()+max_time;
|
|
353
|
+
|
|
354
|
+
// warmup
|
|
355
|
+
f();
|
|
356
|
+
|
|
357
|
+
double tres = std::numeric_limits<double>::max();
|
|
358
|
+
int iteration = 0;
|
|
359
|
+
while(WallTime()<tend || iteration++ < min_iterations)
|
|
360
|
+
{
|
|
361
|
+
double t = -WallTime();
|
|
362
|
+
f();
|
|
363
|
+
t += WallTime();
|
|
364
|
+
tres = std::min(tres, t);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return tres;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
} // namespace ngcore
|
|
371
|
+
|
|
372
|
+
// Helper macro to easily add multiple timers in a function for profiling
|
|
373
|
+
// Usage: NETGEN_TIMER_FROM_HERE("my_timer_name")
|
|
374
|
+
// Effect: define static Timer and RegionTimer with given name and line number
|
|
375
|
+
#define NETGEN_TOKEN_CONCAT(x, y) x ## y
|
|
376
|
+
#define NETGEN_TOKEN_CONCAT2(x, y) NETGEN_TOKEN_CONCAT(x, y)
|
|
377
|
+
#define NETGEN_TIMER_FROM_HERE(name) \
|
|
378
|
+
static Timer NETGEN_TOKEN_CONCAT2(timer_, __LINE__)( string(name)+"_"+ToString(__LINE__)); \
|
|
379
|
+
RegionTimer NETGEN_TOKEN_CONCAT2(rt_,__LINE__)(NETGEN_TOKEN_CONCAT2(timer_,__LINE__));
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
#endif // NETGEN_CORE_PROFILER_HPP
|