{"id":33,"date":"2009-01-16T00:07:00","date_gmt":"2009-01-15T14:07:00","guid":{"rendered":"http:\/\/brnz.org\/hbr\/?p=33"},"modified":"2010-11-09T14:13:45","modified_gmt":"2010-11-09T04:13:45","slug":"funroll-loops","status":"publish","type":"post","link":"https:\/\/brnz.org\/hbr\/?p=33","title":{"rendered":"-funroll-loops"},"content":{"rendered":"<p>In general, C is a lousy language for expressing this kind of parallelism on the SPU.  The original loop that &#8216;inspired&#8217; this nonsense looks something like :<\/p>\n<pre>for (j = 0; j &lt; num_indexes; j += 3) {   \r\n const float *v0, *v1, *v2;\r\n\u00a0v0 = (const float *) (vertices + indexes[j+0] * vertex_size);\r\n\u00a0v1 = (const float *) (vertices + indexes[j+1] * vertex_size);\r\n\u00a0v2 = (const float *) (vertices + indexes[j+2] * vertex_size);\r\n\r\n func(v0, v1, v2);\r\n}<\/pre>\n<p>which is quite clear and straightforward to read, but with hidden complexity &#8211; the lack of quadword alignment, the way it is expressed as three seperate multiply-adds, and the separation into three (unpacked) variables which are repacked inside func().<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In general, C is a lousy language for expressing this kind of parallelism on the SPU. The original loop that &#8216;inspired&#8217; this nonsense looks something like : for (j = 0; j &lt; num_indexes; j += 3) { const float *v0, *v1, *v2; \u00a0v0 = (const float *) (vertices + indexes[j+0] * vertex_size); \u00a0v1 = &hellip; <a href=\"https:\/\/brnz.org\/hbr\/?p=33\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;-funroll-loops&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[37],"_links":{"self":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/33"}],"collection":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33"}],"version-history":[{"count":3,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}