On Sat, 15 Aug 2020, Damian McGuckin wrote:

> I have a little loop which is either 1, 2 or 4 iterations long.
> 
> I want it unrolled by the compiler so its index should be a param.
> 
> Its upper and lower limits are all param which are 0 and #size.
> 
>       param block = 0 .. #size

I think the first problem is that the compiler isn't complaining about 
this line.  The language spec's section on params says that params are 
limited to primitive and enumerated types, which I don't believe includes 
ranges.

If I change the "for param b in block" to 
"for param b in 0..#size", the compiler doesn't complain about that line.


> where size is a param itself.
> 
> Chapel complains in its 3 usages below, namely
> 
>       [param b in block]

This construct is equivalent to a forall expression, and there's no such 
thing as a param forall expression.


>       var x = [param b in block] u[r + b, j];

Unfortunately, there's also no param for expression, just a param for 
statement.  So I don't think you can get this loop unrolled and used for 
initialization.  Though you could use split initialization to hand-unroll 
it for the legal values of size.

Alternately,

        var x = [b in block] u[r + b, j];


Lastly,

>       [param b in block] u[r + b, k] = x[s];

This one can be an unrolled param for statement, or a forall loop; not 
both.


If I change it to a "for param b in 0..#size" style loop in addition to 
the above changes, the only thing the compiler complains about is that s 
is out of scope there.


Paul




> and
>       for b in block
> 
> What am I doing wrong?
> 
> Yes, I can manually unroll the loop myself and have three instances of the
> routine but that is messy.
> 
> The usage is below.
> 
> inline proc vmRot(jk : range, r : int, param size : int, q : [] ?C, u : [] ?R)
> {
>       const (j, k) = (jk.first, jk.last);
>       param block = 0..#size;
>       var x = [param b in block] u[r + b, j];
> 
>       for i in j+1 .. k do
>       {
>               const gi = g[i];
>               const c = gi.re;
>               const s = -gi.im;
> 
>               for param b in block do
>               {
>                       const yi = u[r + b, i];
>                       const xi = x[b];
>                       const cxi = c * xi;
>                       const cyi = c * yi;
> 
>                       u[r + s, i - 1] = cxi - s * yi;
>                       x[s] = cyi + s * xi;
>               }
>       }
> 
>       [param b in block] u[r + b, k] = x[s];
> }
> 
> Thanks - Damian
> 
> Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
> Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
> Views & opinions here are mine and not those of any past or present employer
> 
> 
> _______________________________________________
> Chapel-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/chapel-developers
> 


_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to