<story><title>BLAS-level CPU Performance in 100 Lines of C</title><url>https://cs.stanford.edu/people/shadjis/blas.html</url></story><parent_chain></parent_chain><comment><author>Traster</author><text>I guess that&amp;#x27;s an thorough way of saying &amp;quot;The problem with building a library is supporting all the use cases of a library, not solving the simple underlying problem&amp;quot;. Sure, you&amp;#x27;ve got BLAS level performance &lt;i&gt;on this one CPU&lt;/i&gt;, but you&amp;#x27;ve literally hard coded stuff according to the exact cache size of each of your caches and the exact low level ISA extensions your CPU has. I think it would have been far more interesting to take this and then put it on a Threadripper to see &amp;quot;Given I&amp;#x27;ve optimized the hell out of this for one CPU, how portable is it&amp;quot;.</text></comment>
<story><title>BLAS-level CPU Performance in 100 Lines of C</title><url>https://cs.stanford.edu/people/shadjis/blas.html</url></story><parent_chain></parent_chain><comment><author>olliej</author><text>The core of their multiplication is in&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;HazyResearch&amp;#x2F;blocking-tutorial&amp;#x2F;blob&amp;#x2F;master&amp;#x2F;matrix_kernel_vectorized.cpp#L64&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;HazyResearch&amp;#x2F;blocking-tutorial&amp;#x2F;blob&amp;#x2F;maste...&lt;/a&gt;&lt;p&gt;Where they implement the matrix inner product.&lt;p&gt;And their example implementations using that start at&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;HazyResearch&amp;#x2F;blocking-tutorial&amp;#x2F;blob&amp;#x2F;master&amp;#x2F;compare_blas.cpp#L90&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;HazyResearch&amp;#x2F;blocking-tutorial&amp;#x2F;blob&amp;#x2F;maste...&lt;/a&gt;&lt;p&gt;The inner multiply is all AVX2(w&amp;#x2F;FMA extension) so it&amp;#x27;s probably making some degree of LoC win from not needing to handle hardware capabilities or being portable, but still it is impressive.&lt;p&gt;It is also worth noting that the inner product is c++ templates - it could probably be turned into a horrific macro to make it pure C, but I&amp;#x27;d say it isn&amp;#x27;t worth it. But then I prefer C++ to C :D</text></comment>