{"id":1661,"date":"2024-02-10T08:11:29","date_gmt":"2024-02-10T08:11:29","guid":{"rendered":"https:\/\/mvermeulen.org\/perf\/?page_id=1661"},"modified":"2024-02-10T21:35:22","modified_gmt":"2024-02-10T21:35:22","slug":"primesieve","status":"publish","type":"page","link":"https:\/\/mvermeulen.org\/perf\/workloads\/phoronix\/primesieve\/","title":{"rendered":"primesieve"},"content":{"rendered":"\n<p>Generating prime numbers using a sieve of Eratosthenes implementation. There are two tests with the 1e12 running in ~20 seconds and the 1e13 running in ~140 seconds. This runs almost continuously on all cores.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"960\" src=\"https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/systemtime-50.png\" alt=\"\" class=\"wp-image-1679\" srcset=\"https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/systemtime-50.png 1280w, https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/systemtime-50-1024x768.png 1024w, https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/systemtime-50-768x576.png 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/figure>\n\n\n\n<p>Topdown profile shows some backend stalls but overall a moderate retirement rate and not as many frontend stalls.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"960\" src=\"https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/amdtopdown-52.png\" alt=\"\" class=\"wp-image-1681\" srcset=\"https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/amdtopdown-52.png 1280w, https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/amdtopdown-52-1024x768.png 1024w, https:\/\/mvermeulen.org\/perf\/wp-content\/uploads\/sites\/7\/2024\/02\/amdtopdown-52-768x576.png 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/figure>\n\n\n\n<p>AMD metrics show floating point code and high amount of L2 access but not many L2 misses.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>elapsed              730.330\non_cpu               0.951          # 15.22 \/ 16 cores\nutime                11103.872\nstime                11.206\nnvcsw                2644           # 2.39%\nnivcsw               107828         # 97.61%\ninblock              2320           # 3.18\/sec\nonblock              12712          # 17.41\/sec\ncpu-clock            11116198275008 # 11116.198 seconds\ntask-clock           11116292624354 # 11116.293 seconds\npage faults          3680743        # 331.112\/sec\ncontext switches     113946         # 10.250\/sec\ncpu migrations       345            # 0.031\/sec\nmajor page faults    2              # 0.000\/sec\nminor page faults    3680741        # 331.112\/sec\nalignment faults     0              # 0.000\/sec\nemulation faults     0              # 0.000\/sec\nbranches             6467736098155  # 121.405 branches per 1000 inst\nbranch misses        294969256552   # 4.56% branch miss\nconditional          6085289151533  # 114.226 conditional branches per 1000 inst\nindirect             192854270631   # 3.620 indirect branches per 1000 inst\ncpu-cycles           41078877047663 # 3.48 GHz\ninstructions         53292434507748 # 1.30 IPC\nslots                82146024099060 #\nretiring             19963907311493 # 24.3% (36.0%)\n-- ucode             113680648      #     0.0%\n-- fastpath          19963793630845 #    24.3%\nfrontend             7928985516467  #  9.7% (14.3%)\n-- latency           5791287028344  #     7.0%\n-- bandwidth         2137698488123  #     2.6%\nbackend              24231602760213 # 29.5% (43.7%)\n-- cpu               3875531411835  #     4.7%\n-- memory            20356071348378 #    24.8%\nspeculation          3299885239007  #  4.0% ( 6.0%)\n-- branch mispredict 3215528826507  #     3.9%\n-- pipeline restart  84356412500    #     0.1%\nsmt-contention       26721582492463 # 32.5% ( 0.0%)\ncpu-cycles           41078257306170 # 3.48 GHz\ninstructions         53280411545354 # 1.30 IPC\ninstructions         17760253441937 # 236.184 l2 access per 1000 inst\nl2 hit from l1       2541215747844  # 2.26% l2 miss\nl2 miss from l1      21608662125    #\nl2 hit from l2 pf    1580442451810  #\nl3 hit from l2 pf    55955821749    #\nl3 miss from l2 pf   17075963566    #\ninstructions         17754714307026 # 121.509 float per 1000 inst\nfloat 512            60             # 0.000 AVX-512 per 1000 inst\nfloat 256            388            # 0.000 AVX-256 per 1000 inst\nfloat 128            2157353809593  # 121.509 AVX-128 per 1000 inst\nfloat MMX            0              # 0.000 MMX per 1000 inst\nfloat scalar         0              # 0.000 scalar per 1000 inst\ninstructions         2662617        #\nopcache              992622         # 372.799 opcache per 1000 inst\nopcache miss         532809         # 53.7% opcache miss rate\nl1 dTLB miss         5747           # 2.158 L1 dTLB per 1000 inst\nl2 dTLB miss         1222           # 0.459 L2 dTLB per 1000 inst\ninstructions         2694295        #\nicache               1310298        # 486.323 icache per 1000 inst\nicache miss          112841         #  8.6% icache miss rate\nl1 iTLB miss         19             # 0.007 L1 iTLB per 1000 inst\nl2 iTLB miss         0              # 0.000 L2 iTLB per 1000 inst\ntlb flush            20             # 0.007 TLB flush per 1000 inst\n<\/code><\/pre>\n\n\n\n<p>Intel metrics confirm this mostly fits in L2.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>elapsed              1734.703\non_cpu               0.954          # 15.27 \/ 16 cores\nutime                26481.930\nstime                8.946\nnvcsw                4448           # 1.94%\nnivcsw               224452         # 98.06%\ninblock              232192         # 133.85\/sec\nonblock              1672           # 0.96\/sec\ncpu-clock            26492114005862 # 26492.114 seconds\ntask-clock           26492213728024 # 26492.214 seconds\npage faults          4176737        # 157.659\/sec\ncontext switches     237392         # 8.961\/sec\ncpu migrations       720            # 0.027\/sec\nmajor page faults    1185           # 0.045\/sec\nminor page faults    4175552        # 157.614\/sec\nalignment faults     0              # 0.000\/sec\nemulation faults     0              # 0.000\/sec\nbranches             7993213284230  # 125.831 branches per 1000 inst\nbranch misses        317680959033   # 3.97% branch miss\nconditional          7993213304070  # 125.831 conditional branches per 1000 inst\nindirect             957180953650   # 15.068 indirect branches per 1000 inst\nslots                101458979008178 #\nretiring             38305050542440 # 37.8% (37.8%)\n-- ucode             15622965302918 #    15.4%\n-- fastpath          22682085239522 #    22.4%\nfrontend             15044634792875 # 14.8% (14.8%)\n-- latency           9756766671882  #     9.6%\n-- bandwidth         5287868120993  #     5.2%\nbackend              36285486754358 # 35.8% (35.8%)\n-- cpu               19056232806245 #    18.8%\n-- memory            17229253948113 #    17.0%\nspeculation          12508840876154 # 12.3% (12.3%) high\n-- branch mispredict 12503313301386 #    12.3%\n-- pipeline restart  5527574768     #     0.0%\nsmt-contention       0              #  0.0% ( 0.0%)\ncpu-cycles           58413973424562 # 2.63 GHz\ninstructions         66873400693973 # 1.14 IPC\nl2 access            4534993088315  # 117.338 l2 access per 1000 inst\nl2 miss              124937358537   # 2.75% l2 miss\ncpu-cycles           42799687469272 # 32.2% memory latency\nload stalls          12514227325963 #  0.0% l1 bound\nl1 miss              24697721254255 # 57.1% l2 bound\nl2 miss              245017596355   #  0.4% l3 bound\nl3 miss              85590861371    #  0.2% dram bound\nstore_stalls         1285007532453  #  3.0% store bound\n<\/code><\/pre>\n\n\n\n<p>Process overview shows one primesieve process taking most of the time.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>458 processes\n\t102 primesieve           188624.58   174.53\n\t 68 clinfo                  16.53     6.32\n\t 38 vulkaninfo               1.15     0.96\n\t  4 vulkani:disk$0           0.13     0.11\n\t  6 glxinfo:gdrv0            0.13     0.06\n\t  6 glxinfo:gl0              0.13     0.06\n\t  6 php                      0.08     0.15\n\t  2 llvmpipe-0               0.07     0.06\n\t  2 llvmpipe-1               0.07     0.06\n\t  2 llvmpipe-2               0.07     0.06\n\t  2 llvmpipe-3               0.07     0.06\n\t  2 glxinfo                  0.07     0.02\n\t  2 glxinfo:cs0              0.07     0.02\n\t  2 glxinfo:disk$0           0.07     0.02\n\t  2 glxinfo:sh0              0.07     0.02\n\t  2 glxinfo:shlo0            0.07     0.02\n\t  6 clang                    0.06     0.06\n\t  2 llvmpipe-10              0.06     0.05\n\t  2 llvmpipe-11              0.06     0.05\n\t  2 llvmpipe-12              0.06     0.05\n\t  2 llvmpipe-13              0.06     0.05\n\t  2 llvmpipe-14              0.06     0.05\n\t  2 llvmpipe-15              0.06     0.05\n\t  2 llvmpipe-4               0.06     0.05\n\t  2 llvmpipe-5               0.06     0.05\n\t  2 llvmpipe-6               0.06     0.05\n\t  2 llvmpipe-7               0.06     0.05\n\t  2 llvmpipe-8               0.06     0.05\n\t  2 llvmpipe-9               0.06     0.05\n\t  3 rocminfo                 0.03     0.00\n\t  1 lspci                    0.00     0.02\n\t  1 ps                       0.00     0.01\n\t 84 sh                       0.00     0.00\n\t 13 gcc                      0.00     0.00\n\t 10 gsettings                0.00     0.00\n\t  8 stat                     0.00     0.00\n\t  8 systemd-detect-          0.00     0.00\n\t  6 llvm-link                0.00     0.00\n\t  6 primesieve-test          0.00     0.00\n\t  5 phoronix-test-s          0.00     0.00\n\t  4 gmain                    0.00     0.00\n\t  2 cc                       0.00     0.00\n\t  2 dconf worker             0.00     0.00\n\t  2 lscpu                    0.00     0.00\n\t  2 uname                    0.00     0.00\n\t  2 which                    0.00     0.00\n\t  2 xset                     0.00     0.00\n\t  1 date                     0.00     0.00\n\t  1 dirname                  0.00     0.00\n\t  1 dmesg                    0.00     0.00\n\t  1 dmidecode                0.00     0.00\n\t  1 grep                     0.00     0.00\n\t  1 ifconfig                 0.00     0.00\n\t  1 ip                       0.00     0.00\n\t  1 lsmod                    0.00     0.00\n\t  1 mktemp                   0.00     0.00\n\t  1 qdbus                    0.00     0.00\n\t  1 readlink                 0.00     0.00\n\t  1 realpath                 0.00     0.00\n\t  1 sed                      0.00     0.00\n\t  1 sort                     0.00     0.00\n\t  1 stty                     0.00     0.00\n\t  1 systemctl                0.00     0.00\n\t  1 template.sh              0.00     0.00\n\t  1 wc                       0.00     0.00\n\t  1 xrandr                   0.00     0.00\n0 processes running\n47 maximum processes\n<\/code><\/pre>\n\n\n\n<p>Computation structure is straightforward.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>      405387) primesieve-test  cpu=4 start=6.71  finish=23.67\n        405388) primesieve       cpu=0 start=6.71  finish=23.67\n          405389) primesieve       cpu=6 start=6.71  finish=23.60\n          405390) primesieve       cpu=1 start=6.71  finish=23.59\n          405391) primesieve       cpu=15 start=6.71  finish=23.60\n          405392) primesieve       cpu=8 start=6.71  finish=23.57\n          405393) primesieve       cpu=9 start=6.71  finish=23.57\n          405394) primesieve       cpu=3 start=6.71  finish=23.57\n          405395) primesieve       cpu=4 start=6.72  finish=23.62\n          405396) primesieve       cpu=0 start=6.72  finish=23.58\n          405397) primesieve       cpu=11 start=6.72  finish=23.67\n          405398) primesieve       cpu=10 start=6.72  finish=23.64\n          405399) primesieve       cpu=1 start=6.72  finish=23.65\n          405400) primesieve       cpu=7 start=6.72  finish=23.63\n          405401) primesieve       cpu=11 start=6.72  finish=23.57\n          405402) primesieve       cpu=14 start=6.72  finish=23.60\n          405403) primesieve       cpu=12 start=6.72  finish=23.62\n          405404) primesieve       cpu=13 start=6.72  finish=23.67\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Generating prime numbers using a sieve of Eratosthenes implementation. There are two tests with the 1e12 running in ~20 seconds and the 1e13 running in ~140 seconds. This runs almost continuously on all cores. Topdown profile shows some backend stalls <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/mvermeulen.org\/perf\/workloads\/phoronix\/primesieve\/\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":58,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1661","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/pages\/1661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/comments?post=1661"}],"version-history":[{"count":2,"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/pages\/1661\/revisions"}],"predecessor-version":[{"id":1682,"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/pages\/1661\/revisions\/1682"}],"up":[{"embeddable":true,"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/pages\/58"}],"wp:attachment":[{"href":"https:\/\/mvermeulen.org\/perf\/wp-json\/wp\/v2\/media?parent=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}