On Tue, Oct 18, 2011 at 3:10 PM, Mikko Lehtonen<[email protected]>  wrote:
  Personally, I would be pretty happy with types like
  simd::float4  made available with the most obvious operators.

  Especially if I can wrap it something like


import simd::float4;
import math;

type vec3f = simd::float4;

fn length_squared(v: vec3f) ->  float { v[0] * v[0] + v[1] * v[1] + v[2] *
v[2] }
fn length(v: vec3f) ->  float { math::sqrt(length_squared(v)); }

fn normalize(v:vec3f) ->  vec3f { v / length(v) }


On 10/24/11 6:48 PM, Lindsey Kuper wrote:

Mikko, supposing this code were real, what is the compiler being told
to parallelize here?

Lindsey


  Ah excellent question, my example was kind of stupid in that respect.
  In this case, not really much.

  I wrote the code more to illustrate how it could look, not how to use
  it to full effect.

  Of course, the code that benefits from this is more like
  vec3f force = vec3f(0.0, -1.0, 0.0);
  float timestep = 0.16;
  // in loop for lots of points etc..
  vec3f new_pos = old_pos + force * timestep ;

  Or if you want to take full effect of the four vector elements,
  it needs to be transposed so it's doing it for xxxx,
  yyyy, zzzz, if the transposing doesn't eat the advantage, or the
  memory layout can be changed to accommodate that.

  I'm not a certified SIMD expert, I've only done some game
  related coding, so take this with a appropriate grain of salt.

  Given the lack of "generic simd stuff" support from any of the newer
  programming languages of late, even languages claiming to be for
  "system programming", I can only infer that it just isn't as simple
  to implement them.
  And thinking about it more, it may be difficult to have anything
  predictable. There are more restrictions to alignments, not all types
  have all the some operations available for them orthogonally, not all
  platforms have the same way of achieving some operations..

  So I guess what I'm saying, if llvm makes it easy to implement them,
  in a simple, semi-predictable way, it would be really useful,
  I'm all for it. And it would be really shame if there wasn't any way
  to use them, but I'm not sure what alternative way there is to
  implement then. Expose simd::sse::_mm_setzero_ps  etc. ?


--
Mikko Lehtonen



_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to