<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hello Project Panama, <div><br></div><div>Apologies, if this is the wrong place - first time. I’ve been benchmarking index generation (I want to do linear algebra) with Panama, and obtained the following (surprising to me) results. </div><div><br></div><div><div>Benchmark (len) Mode Cnt Score Error Units</div><div><div>IndexBenchmark.index_loop 10000 thrpt 3 476661.430 ± 333415.679 ops/s</div><div>IndexBenchmark.index_vec 10000 thrpt 3 821343.888 ± 22086.257 ops/s</div><div>IndexBenchmark.index_vec_bad 10000 thrpt 3 31524.934 ± 59643.768 ops/s</div></div></div><div><br></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">The first two implementations are the “obvious” ones. The third one attempts to instantiate the species differently. My ultimate goal, is to get as DoubleVector SPECIES_PREFFERED, and then calculate indexes for each, then put it in an array (i.e. have half the number of the preferred integer species for the platform). </span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></span></div><div><br></div><div><div style="color: rgb(64, 64, 64); background-color: rgb(255, 255, 255); font-family: "Fira Code", Menlo, Monaco, "Courier New", monospace; font-size: 12px; line-height: 18px; white-space: pre;"><div> <span style="color: rgb(157, 78, 150);">@</span><span style="color: rgb(70, 224, 192);">Benchmark</span></div><div> <span style="color: rgb(157, 78, 150);">def</span> <span style="color: rgb(99, 99, 36);">index_loop</span>(<span style="color: rgb(9, 89, 132);">bh</span>: <span style="color: rgb(70, 224, 192);">Blackhole</span>) <span style="color: rgb(54, 54, 54);">=</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">arr</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">Array</span>.<span style="color: rgb(99, 99, 36);">ofDim</span>[<span style="color: rgb(70, 224, 192);">Int</span>](<span style="color: rgb(9, 89, 132);">lenInt</span>)</div><div> <span style="color: rgb(157, 78, 150);">var</span> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(73, 104, 57);">0</span></div><div> <span style="color: rgb(157, 78, 150);">while</span> (<span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(99, 99, 36);"><</span> <span style="color: rgb(9, 89, 132);">lenInt</span>) <span style="color: rgb(157, 78, 150);">do</span></div><div> <span style="color: rgb(15, 157, 235);">arr</span>(<span style="color: rgb(9, 89, 132);">i</span>) <span style="color: rgb(54, 54, 54);">+=</span> <span style="color: rgb(73, 104, 57);">1</span></div><div> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(54, 54, 54);">+=</span> <span style="color: rgb(73, 104, 57);">1</span></div><div><span style="color: rgb(157, 78, 150);"> </span><span style="color: rgb(157, 78, 150);">end</span><span style="color: rgb(157, 78, 150);"> </span><span style="color: rgb(157, 78, 150);">while</span></div><br><div> <span style="color: rgb(9, 89, 132);">bh</span>.<span style="color: rgb(99, 99, 36);">consume</span>(<span style="color: rgb(15, 157, 235);">arr</span>);</div><div> <span style="color: rgb(157, 78, 150);">end</span> <span style="color: rgb(99, 99, 36);">index_loop</span></div><br><div> <span style="color: rgb(157, 78, 150);">@</span><span style="color: rgb(70, 224, 192);">Benchmark</span></div><div> <span style="color: rgb(157, 78, 150);">def</span> <span style="color: rgb(99, 99, 36);">index_vec</span>(<span style="color: rgb(9, 89, 132);">bh</span>: <span style="color: rgb(70, 224, 192);">Blackhole</span>) <span style="color: rgb(54, 54, 54);">=</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">arr</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">Array</span>.<span style="color: rgb(99, 99, 36);">ofDim</span>[<span style="color: rgb(70, 224, 192);">Int</span>](<span style="color: rgb(9, 89, 132);">lenInt</span>)</div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">sp</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">IntVector</span>.<span style="color: rgb(15, 157, 235);">SPECIES_PREFERRED</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">l</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(15, 157, 235);">sp</span>.<span style="color: rgb(99, 99, 36);">length</span>()</div><div> <span style="color: rgb(157, 78, 150);">var</span> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(73, 104, 57);">0</span></div><br><div> <span style="color: rgb(157, 78, 150);">while</span> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(99, 99, 36);"><</span> <span style="color: rgb(15, 157, 235);">sp</span>.<span style="color: rgb(99, 99, 36);">loopBound</span>(<span style="color: rgb(9, 89, 132);">lenInt</span>) <span style="color: rgb(157, 78, 150);">do</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">v</span> <span style="color: rgb(54, 54, 54);">:</span> <span style="color: rgb(70, 224, 192);">IntVector</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">IntVector</span>.<span style="color: rgb(99, 99, 36);">broadcast</span>(<span style="color: rgb(15, 157, 235);">sp</span>, <span style="color: rgb(9, 89, 132);">i</span>).<span style="color: rgb(99, 99, 36);">addIndex</span>(<span style="color: rgb(73, 104, 57);">1</span>)</div><div> <span style="color: rgb(15, 157, 235);">v</span>.<span style="color: rgb(99, 99, 36);">intoArray</span>(<span style="color: rgb(15, 157, 235);">arr</span>, <span style="color: rgb(9, 89, 132);">i</span>)</div><div> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(54, 54, 54);">+=</span> <span style="color: rgb(15, 157, 235);">l</span></div><div><span style="color: rgb(157, 78, 150);"> </span><span style="color: rgb(157, 78, 150);">end</span><span style="color: rgb(157, 78, 150);"> </span><span style="color: rgb(157, 78, 150);">while</span></div><br><div> <span style="color: rgb(9, 89, 132);">bh</span>.<span style="color: rgb(99, 99, 36);">consume</span>(<span style="color: rgb(15, 157, 235);">arr</span>);</div><div> <span style="color: rgb(157, 78, 150);">end</span> <span style="color: rgb(99, 99, 36);">index_vec</span></div><br><br><div> <span style="color: rgb(157, 78, 150);">@</span><span style="color: rgb(70, 224, 192);">Benchmark</span></div><div> <span style="color: rgb(157, 78, 150);">def</span> <span style="color: rgb(99, 99, 36);">index_vec_bad</span>(<span style="color: rgb(9, 89, 132);">bh</span>: <span style="color: rgb(70, 224, 192);">Blackhole</span>) <span style="color: rgb(54, 54, 54);">=</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">arr</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">Array</span>.<span style="color: rgb(99, 99, 36);">ofDim</span>[<span style="color: rgb(70, 224, 192);">Int</span>](<span style="color: rgb(9, 89, 132);">lenInt</span>)</div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">spi</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">IntVector</span>.<span style="color: rgb(15, 157, 235);">SPECIES_PREFERRED</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">sp</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">VectorSpecies</span>.<span style="color: rgb(99, 99, 36);">of</span>(<span style="color: rgb(70, 224, 192);">java</span>.<span style="color: rgb(70, 224, 192);">lang</span>.<span style="color: rgb(70, 224, 192);">Integer</span>.<span style="color: rgb(15, 157, 235);">TYPE</span>, <span style="color: rgb(15, 157, 235);">spi</span>.<span style="color: rgb(99, 99, 36);">vectorShape</span>())</div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">l</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(15, 157, 235);">sp</span>.<span style="color: rgb(99, 99, 36);">length</span>()</div><div> <span style="color: rgb(157, 78, 150);">var</span> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(73, 104, 57);">0</span></div><br><div> <span style="color: rgb(157, 78, 150);">while</span> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(99, 99, 36);"><</span> <span style="color: rgb(15, 157, 235);">sp</span>.<span style="color: rgb(99, 99, 36);">loopBound</span>(<span style="color: rgb(9, 89, 132);">lenInt</span>) <span style="color: rgb(157, 78, 150);">do</span></div><div> <span style="color: rgb(157, 78, 150);">val</span> <span style="color: rgb(15, 157, 235);">v</span> <span style="color: rgb(54, 54, 54);">:</span> <span style="color: rgb(70, 224, 192);">IntVector</span> <span style="color: rgb(54, 54, 54);">=</span> <span style="color: rgb(70, 224, 192);">IntVector</span>.<span style="color: rgb(99, 99, 36);">broadcast</span>(<span style="color: rgb(15, 157, 235);">sp</span>, <span style="color: rgb(9, 89, 132);">i</span>).<span style="color: rgb(99, 99, 36);">addIndex</span>(<span style="color: rgb(73, 104, 57);">1</span>)</div><div> <span style="color: rgb(15, 157, 235);">v</span>.<span style="color: rgb(99, 99, 36);">intoArray</span>(<span style="color: rgb(15, 157, 235);">arr</span>, <span style="color: rgb(9, 89, 132);">i</span>)</div><div> <span style="color: rgb(9, 89, 132);">i</span> <span style="color: rgb(54, 54, 54);">+=</span> <span style="color: rgb(15, 157, 235);">l</span></div><div><span style="color: rgb(157, 78, 150);"> </span><span style="color: rgb(157, 78, 150);">end</span><span style="color: rgb(157, 78, 150);"> </span><span style="color: rgb(157, 78, 150);">while</span></div><br><div> <span style="color: rgb(9, 89, 132);">bh</span>.<span style="color: rgb(99, 99, 36);">consume</span>(<span style="color: rgb(15, 157, 235);">arr</span>);</div><div> <span style="color: rgb(157, 78, 150);">end</span> <span style="color: rgb(99, 99, 36);">index_vec_bad</span></div><br></div></div><div><br></div><div><br></div><div>However, constructing the VectorSpecies through the VectorSpecies.of method, appears to have a catastrophic performance impact. Would that be expected? Am I doing something obviously wrong here? </div><div><br></div><div>Kind Regards, </div><div>Simon</div><div><br></div></body></html>