Next: Cross-compilation, Previous: Proper use of conditionals, Up: Tips and Tricks [Contents][Index]
As described in Generated code, the
c_generic
backend (and therefore all derived
backends) generates programs that run by executing a sequence of
events in an event list. While this form of program execution makes
it possible to hoist a significant amount of computation out of the
timing loop, it does imply that a program’s memory requirements are
proportional to the number of statements that the program
executes.
coNCePTuaL’s memory usage can be reduced by taking advantage of
repeat counts within statements that support such a construct. The
language’s <send_stmt> (see
Sending),
<receive_stmt> (see Receiving), and
<touch_stmt> (see Touching memory) are all
examples of statements that accept repeat counts. For other
statements and for groups of statements that repeat, the FOR
…
REPETITIONS
statement produces a single
EV_REPEAT
event followed by a single instance of the events in the loop body.
This technique is valid because coNCePTuaL knows a priori
that every iteration is identical to every other iteration. In
contrast, the more general FOR EACH
statement can induce
different behavior each iteration based on the value of the loop
variable so programs must conservatively instantiate the events in
the loop body for every iteration. Consider the following
examples:
‘FOR EACH i IN {1, ..., 1000} TASK 0 TOUCHES A 1 WORD
MEMORY REGION’
(1000
EV_TOUCH
events on task 0)
‘FOR 1000 REPETITIONS TASK 0 TOUCHES A 1 WORD MEMORY
REGION’
(an
EV_REPEAT
event and an EV_TOUCH
event on
task 0)
‘TASK 0 TOUCHES A 1 WORD MEMORY REGION 1000
TIMES’
(one
EV_TOUCH
event on task 0)
‘FOR EACH i IN {1, ..., 1000} TASK 0 SENDS A 32 KILOBYTE
MESSAGE TO TASK 1’
(1000
EV_SEND
events on task 0 and 1000 EV_RECV
events on task 1)
‘FOR 1000 REPETITIONS TASK 0 SENDS A 32 KILOBYTE MESSAGE
TO TASK 1’
(an
EV_REPEAT
event and an EV_SEND
event on
task 0
plus an EV_REPEAT
event and an
EV_RECV
event on task 1)
‘TASK 0 SENDS 1000 32 KILOBYTE MESSAGES TO TASK
1’
(currently the same as the above although a future release of
coNCePTuaL may reduce this to a single
EV_SEND
event on task 0 and a single
EV_RECV
event on task 1)
Next: Cross-compilation, Previous: Proper use of conditionals, Up: Tips and Tricks [Contents][Index]