On Sat, May 23, 2015 at 09:10:37PM -0400, Zach Etienne wrote:
Thanks for your tips. After many hours of looking into this problem, and even trying (unsuccessfully) to use Carpet macros, I conclude that I am being held back by a bug in Cactus scheduling.
Yes and no. The Cactus scheduling is fine, but the interaction with the Carpet modes is often surprising, and so it is here.
This is (please correct me), how the interaction between Cactus and Carpet works:
Cactus -> Carpet: please schedule stuff in Analysis for all modes in Carpet (and levels and components if applicable): Carpet -> Cactus: call all functions in Analysis for all functions in Analysis: Cactus -> Carpet: Call function Carpet: if function should be called in current mode: call otherwise: ignore
Given this, can you see why your thorn hangs?
You schedule the initialization of the while-variable in 'global'. 'global-early' comes before that, so Cactus gets the task to loop while 'counter' in global-early, on an uninitialized variable, and inside that loop nothing touches that variable, so the loop never stops.
Yes, this is kind of backward, and feels a bit strange. And it is. We do have plans to make this simpler.
What you have to do to make this work: - hold the loop variable at 0 whenever you don't want to loop, especially: initialize it right at the start to 0 and make sure it doesn't go below 0. ( also, but you already do this: - make sure you initialize the loop variable (to the number of loops) in the same mode as the function that decrements it )
Btw: probably not connected to this problem: I am surprised to see that "SCHEDULE InitializeCounter before InitializeCounter" actually works. Is there any reason for that? :)
Frank