On 24 October 2012 16:00, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com" target="_blank">bearophileHUGS@lycos.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Manu:<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
D already has what's required to do some fairly nice (by comparison) simd stuff with good supporting libraries.<br>
</blockquote>
<br></div>
After reading that paper I am not sure you are right. See how their language manages masks by itself. This is from page 3:<br>
<br>
<br>
// vector length of context = 1; current_mask = T<br>
int block[4] v = <0,3,4,1>;<br>
int block[4] w = 3; // <3,3,3,3> via broadcast<br>
bool block[4] m = v < w; // <T,F,F,T><br>
++v; // <1,4,5,2><br>
if (m) {<br>
    // vector length of context = 4; current_mask = m<br>
    v += 2; // <3,4,5,4><br>
} else {<br>
    // vector length of context = 4; current_mask = ~m<br>
    v += 3; // <3,7,8,4><br>
}<br>
// vector length of context = 1; current_mask = T<br></blockquote><div><br></div><div>I agree that if is kinda neat, but it's probably not out of the question for future extension. All the other stuff here is possible.</div>
<div>That said, it's not necessarily optimal either, just conveniently written. The compiler would have to do some serious magic to optimise that; flattening both sides of the if into parallel expressions, and then applying the mask to combine...</div>
<div>I'm personally not in favour of SIMD constructs that are anything less than optimal (but I appreciate I'm probably in the minority here).</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(The simple benchmarks of the paper show a 5-15% performance loss compared to handwritten SIMD code.)<br></blockquote><div><br></div><div>Right, as I suspected.</div></div>