:Author: Francois Cuvelier :Date: 09/10/2013 .. _bench3D-label: 3D benchmarks +++++++++++++ .. contents:: Contents :local: Benchmark usage --------------- .. module:: pyOptFEM.FEM3D.assemblyBench :synopsis: code to see the comparative performance between versions for each assembly matrices in 3d .. moduleauthor:: F. Cuvelier .. function:: pyOptFEM.FEM3D.assemblyBench.assemblyBench(,[assembly=,version=,LN=,meshname=,meshdir=,nbruns=,la=,mu=,Num=,tag=,...]) :noindex: Benchmark code for :math:`P_1`-Lagrange finite element matrices defined in :mod:`FEM3D`. :param assembly: Name of an assembly routine. The string should be : - *'MassAssembling3DP1'*, - *'StiffAssembling3DP1'* (default) - *'StiffElasAssembling3DP1'* :param versions: List of versions. Must be a list of any size whose elements may be *{'base','OptV1','OptV2'}* (default : ``['OptV2','OptV1','base']``) :param meshname: Name of the *medit* mesh files. By default it is an empty string *''*. It means it uses CubeMesh(N) function to generate meshes. :param meshdir: Directory location of *medit* mesh files. Used if meshname is not empty. :param LN: array of integer values. contains the values of N. Used to generate meshes data via Th=CubeMesh(N) function if meshname is empty or via *getMesh* class to read FreeFEM++ meshes Th=getMesh(meshdir+'/'+meshname+str(N)+'.mesh') LN default value is ``range(5, 14, 2)`` :param nbruns: Number of runs on each mesh (default : *1*) :param save: For saving benchmark results in a file (see parameters , and ). (default : *False*) :param plot: For plotting computation times (default : *True*) :param output: Name used to set results file name (default : *'bench2D'*) :param outdir: Directory location of saved results file name (default : *'./results'*). :param tag: Specify a tag string added to filename :param la: the first Lame coefficient in Hooke's law, denoted by :math:`\lambda`. Used by functions for assembling the elastic stiffness matrix. (default : *2*) :param mu: the second Lame coefficient in Hooke's law, denoted by :math:`\mu`. Used by functions for assembling the elastic stiffness matrix. (default : *0.3*) :param Num: Numbering choice. Used by functions for assembling the elastic stiffness matrix. (default : *0*) .. _bench3D_Mass-label: Mass Matrix ----------- - Benchmark of **MassAssembling3DP1** with ``base``, ``OptV1`` and ``OptV2`` versions (see :ref:`FEM3D-MassAssembling-label`) .. table:: MassAssembling23P1 benchmark summary +--------+--------+--------+--------------+--------------+--------------+ | N | nq | ndof | OptV2 | OptV1 | base | +========+========+========+==============+==============+==============+ | 5 | 216 | 216 | 0.0015(s) | 0.0424(s) | 0.8962(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x28.29 | x597.49 | +--------+--------+--------+--------------+--------------+--------------+ | 10 | 1331 | 1331 | 0.0075(s) | 0.3390(s) | 7.1521(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x44.96 | x948.64 | +--------+--------+--------+--------------+--------------+--------------+ | 15 | 4096 | 4096 | 0.0268(s) | 1.1413(s) | 24.2836(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x42.55 | x905.35 | +--------+--------+--------+--------------+--------------+--------------+ | 20 | 9261 | 9261 | 0.0677(s) | 2.7240(s) | 56.9878(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x40.26 | x842.21 | +--------+--------+--------+--------------+--------------+--------------+ | 25 | 17576 | 17576 | 0.1457(s) | 5.2998(s) | 111.0287(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x36.38 | x762.11 | +--------+--------+--------+--------------+--------------+--------------+ | 30 | 29791 | 29791 | 0.2493(s) | 9.2205(s) | 192.1030(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x36.99 | x770.64 | +--------+--------+--------+--------------+--------------+--------------+ | 35 | 46656 | 46656 | 0.4121(s) | 14.6558(s) | 304.5941(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x35.57 | x739.17 | +--------+--------+--------+--------------+--------------+--------------+ This tabular was built with the following code : >>> from pyOptFEM.FEM3D import assemblyBench >>> assemblyBench(assembly='MassAssembling3DP1',LN=range(5,40,5)) CubeMesh(5): -> MassAssembling3DP1OptV2(nq=216, nme=750) run ( 1/ 1) : cputime=0.001254(s) - matrix 216-by-216 ... CubeMesh(35): -> MassAssembling3DP1base(nq=46656, nme=257250) run ( 1/ 1) : cputime=304.594078(s) - matrix 46656-by-46656 We also obtain .. figure:: images/bench_Mass3DP1_01.png :width: 400px :scale: 100% :align: center MassAssembling3DP1 benchmark - Benchmark of **MassAssembling3DP1** with ``OptV2`` and ``OptV1`` versions .. table:: MassAssembling2DP1 benchmark summary +--------+--------+--------+--------------+--------------+ | N | nq | ndof | OptV2 | OptV1 | +========+========+========+==============+==============+ | 10 | 1331 | 1331 | 0.0065(s) | 0.3656(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x56.05 | +--------+--------+--------+--------------+--------------+ | 20 | 9261 | 9261 | 0.0578(s) | 2.6968(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x46.70 | +--------+--------+--------+--------------+--------------+ | 30 | 29791 | 29791 | 0.2195(s) | 9.1710(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x41.77 | +--------+--------+--------+--------------+--------------+ | 40 | 68921 | 68921 | 0.6109(s) | 21.7386(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x35.59 | +--------+--------+--------+--------------+--------------+ | 50 | 132651 | 132651 | 1.1558(s) | 42.1679(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x36.49 | +--------+--------+--------+--------------+--------------+ | 60 | 226981 | 226981 | 2.1182(s) | 73.9066(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x34.89 | +--------+--------+--------+--------------+--------------+ | 70 | 357911 | 357911 | 3.1952(s) | 116.2151(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x36.37 | +--------+--------+--------+--------------+--------------+ | 80 | 531441 | 531441 | 5.1899(s) | 174.4814(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x33.62 | +--------+--------+--------+--------------+--------------+ | 90 | 753571 | 753571 | 7.0460(s) | 247.8245(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x35.17 | +--------+--------+--------+--------------+--------------+ | 100 |1030301 |1030301 | 9.8218(s) | 340.9609(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x34.71 | +--------+--------+--------+--------------+--------------+ This tabular was built with the following code : >>> from pyOptFEM.FEM3D import assemblyBench >>> assemblyBench(assembly='MassAssembling3DP1',versions=['OptV2','OptV1'],LN=range(10,110,10)) CubeMesh(10): -> MassAssembling3DP1OptV2(nq=1331, nme=6000) run ( 1/ 1) : cputime=0.006523(s) - matrix 1331-by-1331 ... CubeMesh(100): -> MassAssembling3DP1OptV1(nq=1030301, nme=6000000) run ( 1/ 1) : cputime=340.960874(s) - matrix 1030301-by-1030301 We also obtain .. figure:: images/bench_Mass3DP1_02.png :width: 400px :scale: 100% :align: center MassAssembling3DP1 benchmark .. _bench3D_Stiff-label: Stiffness Matrix ---------------- - Benchmark of **StiffAssembling3DP1** with ``base``, ``OptV1`` and ``OptV2`` versions .. table:: StiffAssembling3DP1 benchmark summary +--------+--------+--------+--------------+--------------+--------------+ | N | nq | ndof | OptV2 | OptV1 | base | +========+========+========+==============+==============+==============+ | 5 | 216 | 216 | 0.0024(s) | 0.0546(s) | 0.9065(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x23.22 | x385.72 | +--------+--------+--------+--------------+--------------+--------------+ | 10 | 1331 | 1331 | 0.0072(s) | 0.4396(s) | 7.2347(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x60.68 | x998.63 | +--------+--------+--------+--------------+--------------+--------------+ | 15 | 4096 | 4096 | 0.0258(s) | 1.4985(s) | 24.5593(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x58.08 | x951.81 | +--------+--------+--------+--------------+--------------+--------------+ | 20 | 9261 | 9261 | 0.0652(s) | 3.4915(s) | 57.9647(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x53.55 | x888.96 | +--------+--------+--------+--------------+--------------+--------------+ | 25 | 17576 | 17576 | 0.1315(s) | 6.7851(s) | 112.9478(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x51.61 | x859.14 | +--------+--------+--------+--------------+--------------+--------------+ | 30 | 29791 | 29791 | 0.2479(s) | 11.8616(s) | 195.8290(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x47.85 | x790.05 | +--------+--------+--------+--------------+--------------+--------------+ | 35 | 46656 | 46656 | 0.4126(s) | 18.3069(s) | 310.0601(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x44.37 | x751.46 | +--------+--------+--------+--------------+--------------+--------------+ This tabular was built with the following code : >>> from pyOptFEM.FEM3D import assemblyBench >>> assemblyBench(assembly='StiffAssembling3DP1',LN=range(5,40,5)) CubeMesh(5): -> StiffAssembling3DP1OptV2(nq=216, nme=750) run ( 1/ 1) : cputime=0.002350(s) - matrix 216-by-216 ... CubeMesh(35): -> StiffAssembling3DP1base(nq=46656, nme=257250) run ( 1/ 1) : cputime=310.060121(s) - matrix 46656-by-46656 We also obtain .. figure:: images/bench_Stiff3DP1_01.png :width: 400px :scale: 100% :align: center StiffAssembling3DP1 benchmark - Benchmark of **StiffAssembling3DP1** with ``OptV2`` and ``OptV1`` versions .. table:: StiffAssembling3DP1 benchmark summary +--------+--------+--------+--------------+--------------+ | N | nq | ndof | OptV2 | OptV1 | +========+========+========+==============+==============+ | 10 | 1331 | 1331 | 0.0071(s) | 0.4329(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x60.68 | +--------+--------+--------+--------------+--------------+ | 20 | 9261 | 9261 | 0.0652(s) | 3.4323(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x52.64 | +--------+--------+--------+--------------+--------------+ | 30 | 29791 | 29791 | 0.2525(s) | 11.6349(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x46.07 | +--------+--------+--------+--------------+--------------+ | 40 | 68921 | 68921 | 0.7178(s) | 27.6186(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x38.48 | +--------+--------+--------+--------------+--------------+ | 50 | 132651 | 132651 | 1.5883(s) | 53.9955(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x34.00 | +--------+--------+--------+--------------+--------------+ | 60 | 226981 | 226981 | 2.8236(s) | 93.1197(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x32.98 | +--------+--------+--------+--------------+--------------+ | 70 | 357911 | 357911 | 4.6881(s) | 147.6608(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x31.50 | +--------+--------+--------+--------------+--------------+ | 80 | 531441 | 531441 | 7.4632(s) | 220.7232(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x29.57 | +--------+--------+--------+--------------+--------------+ | 90 | 753571 | 753571 | 10.6093(s) | 314.8404(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x29.68 | +--------+--------+--------+--------------+--------------+ | 100 |1030301 |1030301 | 14.7064(s) | 427.0878(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x29.04 | +--------+--------+--------+--------------+--------------+ This tabular was built with the following code : >>> from pyOptFEM.FEM3D import assemblyBench >>> assemblyBench(assembly='StiffAssembling3DP1',versions=['OptV2','OptV1'],LN=range(10,110,10)) CubeMesh(10): -> StiffAssembling3DP1OptV2(nq=1331, nme=6000) run ( 1/ 1) : cputime=0.007133(s) - matrix 1331-by-1331 ... CubeMesh(100): -> StiffAssembling3DP1OptV1(nq=1030301, nme=6000000) run ( 1/ 1) : cputime=427.087812(s) - matrix 1030301-by-1030301 We also obtain .. figure:: images/bench_Stiff3DP1_02.png :width: 400px :scale: 100% :align: center StiffAssembling3DP1 benchmark Elastic Stiffness Matrix --------------------------- - Benchmark of **StiffAssembling3DP1** with ``base``, ``OptV1`` and ``OptV2`` versions .. table:: StiffAssembling3DP1 benchmark summary +--------+--------+--------+--------------+--------------+--------------+ | N | nq | ndof | OptV2 | OptV1 | base | +========+========+========+==============+==============+==============+ | 3 | 64 | 192 | 0.0056(s) | 0.0626(s) | 0.6896(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x11.23 | x123.60 | +--------+--------+--------+--------------+--------------+--------------+ | 5 | 216 | 648 | 0.0085(s) | 0.2877(s) | 3.1838(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x33.87 | x374.88 | +--------+--------+--------+--------------+--------------+--------------+ | 7 | 512 | 1536 | 0.0183(s) | 0.7933(s) | 8.7350(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x43.43 | x478.25 | +--------+--------+--------+--------------+--------------+--------------+ | 10 | 1331 | 3993 | 0.0493(s) | 2.3134(s) | 25.5321(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x46.91 | x517.74 | +--------+--------+--------+--------------+--------------+--------------+ | 13 | 2744 | 8232 | 0.1061(s) | 5.0799(s) | 55.8011(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x47.89 | x526.04 | +--------+--------+--------+--------------+--------------+--------------+ | 17 | 5832 | 17496 | 0.2426(s) | 11.3663(s) | 126.2934(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x46.86 | x520.66 | +--------+--------+--------+--------------+--------------+--------------+ | 20 | 9261 | 27783 | 0.4317(s) | 18.6554(s) | 205.4239(s) | +--------+--------+--------+--------------+--------------+--------------+ | | | | x1.00 | x43.22 | x475.90 | +--------+--------+--------+--------------+--------------+--------------+ This tabular was built with the following code : >>> from pyOptFEM.FEM3D import assemblyBench >>> from numpy import * >>> assemblyBench(assembly='StiffElasAssembling3DP1',LN=array([3,5,7,10,13,17,20])) CubeMesh(3): -> StiffElasAssembling3DP1OptV2(nq=64, nme=162) run ( 1/ 1) : cputime=0.005579(s) - matrix 192-by-192 ... CubeMesh(20): -> StiffElasAssembling3DP1base(nq=9261, nme=48000) run ( 1/ 1) : cputime=205.423872(s) - matrix 27783-by-27783 We also obtain .. figure:: images/bench_StiffElas3DP1_01.png :width: 400px :scale: 100% :align: center StiffElasAssembling3DP1 benchmark - Benchmark of **StiffAssembling3DP1** with ``OptV1`` and ``OptV2`` versions .. table:: StiffAssembling3DP1 benchmark summary +--------+--------+--------+--------------+--------------+ | N | nq | ndof | OptV2 | OptV1 | +========+========+========+==============+==============+ | 10 | 1331 | 3993 | 0.0497(s) | 2.2711(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x45.73 | +--------+--------+--------+--------------+--------------+ | 20 | 9261 | 27783 | 0.4325(s) | 18.1990(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x42.07 | +--------+--------+--------+--------------+--------------+ | 30 | 29791 | 89373 | 1.7316(s) | 61.6716(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x35.62 | +--------+--------+--------+--------------+--------------+ | 40 | 68921 | 206763 | 4.5098(s) | 146.4793(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x32.48 | +--------+--------+--------+--------------+--------------+ | 50 | 132651 | 397953 | 9.3904(s) | 284.8776(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x30.34 | +--------+--------+--------+--------------+--------------+ | 60 | 226981 | 680943 | 17.2215(s) | 494.1435(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x28.69 | +--------+--------+--------+--------------+--------------+ | 70 | 357911 |1073733 | 28.1707(s) | 785.3533(s) | +--------+--------+--------+--------------+--------------+ | | | | x1.00 | x27.88 | +--------+--------+--------+--------------+--------------+ This tabular was built with the following code : >>> from pyOptFEM.FEM3D import assemblyBench >>> assemblyBench(assembly='StiffElasAssembling3DP1',versions=['OptV2','OptV1'],LN=range(10,80,10)) CubeMesh(10): -> StiffElasAssembling3DP1OptV2(nq=1331, nme=6000) run ( 1/ 1) : cputime=0.049666(s) - matrix 3993-by-3993 ... CubeMesh(70): -> StiffElasAssembling3DP1OptV1(nq=357911, nme=2058000) run ( 1/ 1) : cputime=785.353305(s) - matrix 1073733-by-1073733 We also obtain .. figure:: images/bench_StiffElas3DP1_02.png :width: 400px :scale: 100% :align: center StiffElasAssembling3DP1 benchmark