Force unroll loop directive?

I have a kernel of the form:

for d in list_of_length_6.iter() {
  for z in 0 .. 4 {
    for y in 0 .. 4 {
      for x in 0 .. 4 {
        very short instrc;
      }
    }
  }
}

Is there some attribute/hack/way where I can tell the compiler to force unroll the x, the y (and possibly even the z) ?

Here's a very dumb macro to do it. It could doubtless be improved in multiple ways.

1 Like