[<<][rtl][>>][..]
Sun Apr 21 08:54:29 EDT 2019

Test case for implementable vectors as loops

Basically, compute the norm of a vector, but leave the vector
representation abstract.

C.hs and Term.hs will need to be extended to support two ideas: loops
and arrays.

The biggest win would be if this can be written in a way that a low
level compiler can eliminate intermediate storage, i.e. perform loop
fusion.

In RAI I do this manually.

E.g. instead of

f3 a =
  let b = fmap f1 a
      c = fmap f2 b

where b is an intermediate vector.  It would be possible to map (f2
. f1) over a and produce c directly, where the 'b' values are only
scalar inside the loop.

I believe this should be easy enough to do as long as the storage
allocation of b is visible only to the function and not outside.

I need to ask somebody with good knowledge of LLVM.

Or, just make a test.

I believe the terms are "fusion" and "deforestation".

void f(const float *src, float *dst) {
     float tmp[10];
     for (int i=0; i<10; i++) {
         tmp[i] = sin(src[i]);
     }
     for (int i=0; i<10; i++) {
         dst[i] = sin(tmp[i]);
     }
}


void f(const float *src, float *dst) {
     for (int i=0; i<10; i++) {
         float tmp = sin(src[i]);
         dst[i]    = sin(tmp);
     }
}


I think it's ok to assume that this will work out fine.

So to implement the loop operations, it should be enough to just
separate declaration and binding.




[Reply][About]
[<<][rtl][>>][..]